S4T3K

s_accessoires_fix

Apr 24th, 2014
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.83 KB | None | 0 0
  1. #include <a_samp>
  2. #include <YSI\y_hooks>
  3.  
  4. #define HOLDING(%0) \
  5.     ((newkeys & (%0)) == (%0))
  6.  
  7. #define RELEASED(%0) \
  8.     (((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
  9.  
  10. #define KEY_AIM KEY_HANDBRAKE
  11.  
  12. #if defined ALS_ZOOM_FIX_INCLUDED
  13.     #endinput
  14. #else
  15.     #define ALS_ZOOM_FIX_INCLUDED
  16. #endif
  17.  
  18. enum FIX_aInfo
  19. {
  20.     model,
  21.     pdc,
  22.     Float:o[9],
  23.     col[2],
  24. };
  25.  
  26. new FIX_pAcc[MAX_PLAYERS][10][FIX_aInfo];
  27.  
  28. hook OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  29. {
  30.     if(HOLDING(KEY_AIM))
  31.     {
  32.         if(GetPlayerWeapon(playerid) == 34 || GetPlayerWeapon(playerid) == 43)
  33.         {
  34.             for(new s = 0; s < 10; s++)
  35.             {
  36.                 if(IsPlayerAttachedObjectSlotUsed(playerid, s)) RemovePlayerAttachedObject(playerid, s);
  37.             }
  38.             return 1;
  39.         }
  40.     }
  41.  
  42.     if(RELEASED(KEY_AIM))
  43.     {
  44.         if(GetPlayerWeapon(playerid) == 34 || GetPlayerWeapon(playerid) == 43)
  45.         {
  46.             for(new s = 0; s < 10; s++)
  47.             {
  48.                 if(FIX_pAcc[playerid][s][model] == 0) continue;
  49.                 SetPlayerAttachedObject(playerid, s, FIX_pAcc[playerid][s][model], FIX_pAcc[playerid][s][pdc], FIX_pAcc[playerid][s][o][0], FIX_pAcc[playerid][s][o][1], FIX_pAcc[playerid][s][o][2], FIX_pAcc[playerid][s][o][3], FIX_pAcc[playerid][s][o][4], FIX_pAcc[playerid][s][o][5], FIX_pAcc[playerid][s][o][6], FIX_pAcc[playerid][s][o][7], FIX_pAcc[playerid][s][o][8], FIX_pAcc[playerid][s][col][0], FIX_pAcc[playerid][s][col][1]);
  50.             }
  51.         }
  52.         return 1;
  53.     }
  54.  
  55.     return 0;
  56. }
  57.  
  58. stock S_SetPlayerAttachedObject(playerid, index, modelid, bone, Float:fOffsetX = 0.0, Float:fOffsetY = 0.0, Float:fOffsetZ = 0.0, Float:fRotX = 0.0, Float:fRotY = 0.0, Float:fRotZ = 0.0, Float:fScaleX = 0.0, Float:fScaleY = 0.0, Float:fScaleZ = 0.0, materialcolor1 = 0, materialcolor2 = 0)
  59. {
  60.     SetPlayerAttachedObject(playerid, index, modelid, bone, fOffsetX, fOffsetY, fOffsetZ, fRotX, fRotY, fRotZ, fScaleX, fScaleY, fScaleZ, materialcolor1, materialcolor2);
  61.     FIX_pAcc[playerid][index][model] = modelid;
  62.     FIX_pAcc[playerid][index][pdc] = bone;
  63.     FIX_pAcc[playerid][index][o][0] = fOffsetX;
  64.     FIX_pAcc[playerid][index][o][1] = fOffsetY;
  65.     FIX_pAcc[playerid][index][o][2] = fOffsetZ;
  66.     FIX_pAcc[playerid][index][o][3] = fRotX;
  67.     FIX_pAcc[playerid][index][o][4] = fRotY;
  68.     FIX_pAcc[playerid][index][o][5] = fRotZ;
  69.     FIX_pAcc[playerid][index][o][6] = fScaleX;
  70.     FIX_pAcc[playerid][index][o][7] = fScaleY;
  71.     FIX_pAcc[playerid][index][o][8] = fScaleZ;
  72.     FIX_pAcc[playerid][index][col][0] = materialcolor1;
  73.     FIX_pAcc[playerid][index][col][1] = materialcolor2;
  74.     return 1;
  75. }
  76.  
  77. stock S_RemovePlayerAttachedObject(playerid, index)
  78. {
  79.     if(!IsPlayerAttachedObjectSlotUsed(playerid, index)) return 0;
  80.     FIX_pAcc[playerid][index][model] = 0;
  81.     FIX_pAcc[playerid][index][pdc] = 0;
  82.     for(new i = 0; i < 9; i++) { FIX_pAcc[playerid][index][o][i] = 0.0; }
  83.     FIX_pAcc[playerid][index][col][0] = 0;
  84.     FIX_pAcc[playerid][index][col][1] = 0;
  85.     return RemovePlayerAttachedObject(playerid, index);
  86. }
  87.  
  88.  
  89.  
  90. stock RemovePlayerAttachedObjectModel(playerid, modelid)
  91. {
  92.     new bool:done = false;
  93.     for(new i = 0; i < 10; i++)
  94.     {
  95.         if(!IsPlayerAttachedObjectSlotUsed(playerid, i)) continue;
  96.         if(FIX_pAcc[playerid][i][model] == modelid) RemovePlayerAttachedObject(playerid, i), done = true;
  97.     }
  98.     if(done) return 1;
  99.     return 0;
  100. }
  101.  
  102. stock GetPlayerAttachedObject(playerid, index)
  103. {
  104.     if(!IsPlayerAttachedObjectSlotUsed(playerid, index)) return 0;
  105.     else return FIX_pAcc[playerid][index][model];
  106. }
  107.  
  108. stock GetPlayerBodyPartUsed(playerid, index)
  109. {
  110.     if(!IsPlayerAttachedObjectSlotUsed(playerid, index)) return 0;
  111.     else return FIX_pAcc[playerid][index][pdc];
  112. }
  113.  
  114. stock GetPlayerIndexByModel(playerid, model)
  115. {
  116.     for(new i = 0; i < 10; i++)
  117.     {
  118.         if(!IsPlayerAttachedObjectSlotUsed(playerid, i)) continue;
  119.         else
  120.         {
  121.             if(FIX_pAcc[playerid][i][model] == model) return i;
  122.             else return 0;
  123.         }
  124.     }
  125. }
  126.  
  127. stock GetPlayerAccOffSet(playerid, index, &Float:offsetX, &Float:offsetY, &Float:offsetZ)
  128. {
  129.     if(!IsPlayerAttachedObjectSlotUsed(playerid, index)) return 0;
  130.     else
  131.     {
  132.         offsetX = FIX_pAcc[playerid][index][o][0];
  133.         offsetY = FIX_pAcc[playerid][index][o][1];
  134.         offsetZ = FIX_pAcc[playerid][index][o][2];
  135.         return 1;
  136.     }
  137. }
  138.  
  139. stock GetPlayerAccRot(playerid, index, &Float:rotX, &Float:rotY, &Float:rotZ)
  140. {
  141.     if(!IsPlayerAttachedObjectSlotUsed(playerid, index)) return 0;
  142.     else
  143.     {
  144.         rotX = FIX_pAcc[playerid][index][o][3];
  145.         rotY = FIX_pAcc[playerid][index][o][4];
  146.         rotZ = FIX_pAcc[playerid][index][o][5];
  147.         return 1;
  148.     }
  149. }
  150.  
  151. stock GetPlayerAccScale(playerid, index, &Float:scaleX, &Float:scaleY, &Float:scaleZ)
  152. {
  153.     if(!IsPlayerAttachedObjectSlotUsed(playerid, index)) return 0;
  154.     else
  155.     {
  156.         scaleX = FIX_pAcc[playerid][index][o][6];
  157.         scaleY = FIX_pAcc[playerid][index][o][7];
  158.         scaleZ = FIX_pAcc[playerid][index][o][8];
  159.         return 1;
  160.     }
  161. }
  162.  
  163. stock GetPlayerAccMaterial(playerid, index, &col1, &col2)
  164. {
  165.     if(!IsPlayerAttachedObjectSlotUsed(playerid, index)) return 0;
  166.     else
  167.     {
  168.         col1 = FIX_pAcc[playerid][index][col][0];
  169.         col2 = FIX_pAcc[playerid][index][col][1];
  170.         return 1;
  171.     }
  172. }
  173.  
  174. #if defined _ALS_SetPlayerAttachedObject
  175.     #undef SetPlayerAttachedObject
  176. #else
  177.     #define _ALS_SetPlayerAttachedObject
  178. #endif
  179.  
  180. #define SetPlayerAttachedObject S_SetPlayerAttachedObject
  181.  
  182. #if defined _ALS_RemovePlayerAttachedObject
  183.     #undef RemovePlayerAttachedObject
  184. #else
  185.     #define _ALS_RemovePlayerAttachedObject
  186. #endif
  187. #define RemovePlayerAttachedObject S_RemovePlayerAttachedObject
  188.    
  189. native GetPlayerAttachedObject(playerid, index);
  190. native GetPlayerBodyPartUsed(playerid, index);
  191. native GetPlayerIndexByModel(playerid, model);
  192. native GetPlayerAccOffSet(playerid, index, &Float:offsetX, &Float:offsetY, &Float:offsetZ);
  193. native GetPlayerAccRot(playerid, index, &Float:rotX, &Float:rotY, &Float:rotZ);
  194. native GetPlayerAccScale(playerid, index, &Float:scaleX, &Float:scaleY, &Float:scaleZ);
  195. native GetPlayerAccMaterial(playerid, index, &col1, &col2);
  196. native RemovePlayerAttachedObjectModel(playerid, modelid);
Advertisement
Add Comment
Please, Sign In to add comment