Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <YSI\y_hooks>
- #define HOLDING(%0) \
- ((newkeys & (%0)) == (%0))
- #define RELEASED(%0) \
- (((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
- #define KEY_AIM KEY_HANDBRAKE
- #if defined ALS_ZOOM_FIX_INCLUDED
- #endinput
- #else
- #define ALS_ZOOM_FIX_INCLUDED
- #endif
- enum FIX_aInfo
- {
- model,
- pdc,
- Float:o[9],
- col[2],
- };
- new FIX_pAcc[MAX_PLAYERS][10][FIX_aInfo];
- hook OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(HOLDING(KEY_AIM))
- {
- if(GetPlayerWeapon(playerid) == 34 || GetPlayerWeapon(playerid) == 43)
- {
- for(new s = 0; s < 10; s++)
- {
- if(IsPlayerAttachedObjectSlotUsed(playerid, s)) RemovePlayerAttachedObject(playerid, s);
- }
- return 1;
- }
- }
- if(RELEASED(KEY_AIM))
- {
- if(GetPlayerWeapon(playerid) == 34 || GetPlayerWeapon(playerid) == 43)
- {
- for(new s = 0; s < 10; s++)
- {
- if(FIX_pAcc[playerid][s][model] == 0) continue;
- 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]);
- }
- }
- return 1;
- }
- return 0;
- }
- 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)
- {
- SetPlayerAttachedObject(playerid, index, modelid, bone, fOffsetX, fOffsetY, fOffsetZ, fRotX, fRotY, fRotZ, fScaleX, fScaleY, fScaleZ, materialcolor1, materialcolor2);
- FIX_pAcc[playerid][index][model] = modelid;
- FIX_pAcc[playerid][index][pdc] = bone;
- FIX_pAcc[playerid][index][o][0] = fOffsetX;
- FIX_pAcc[playerid][index][o][1] = fOffsetY;
- FIX_pAcc[playerid][index][o][2] = fOffsetZ;
- FIX_pAcc[playerid][index][o][3] = fRotX;
- FIX_pAcc[playerid][index][o][4] = fRotY;
- FIX_pAcc[playerid][index][o][5] = fRotZ;
- FIX_pAcc[playerid][index][o][6] = fScaleX;
- FIX_pAcc[playerid][index][o][7] = fScaleY;
- FIX_pAcc[playerid][index][o][8] = fScaleZ;
- FIX_pAcc[playerid][index][col][0] = materialcolor1;
- FIX_pAcc[playerid][index][col][1] = materialcolor2;
- return 1;
- }
- stock S_RemovePlayerAttachedObject(playerid, index)
- {
- if(!IsPlayerAttachedObjectSlotUsed(playerid, index)) return 0;
- FIX_pAcc[playerid][index][model] = 0;
- FIX_pAcc[playerid][index][pdc] = 0;
- for(new i = 0; i < 9; i++) { FIX_pAcc[playerid][index][o][i] = 0.0; }
- FIX_pAcc[playerid][index][col][0] = 0;
- FIX_pAcc[playerid][index][col][1] = 0;
- return RemovePlayerAttachedObject(playerid, index);
- }
- stock RemovePlayerAttachedObjectModel(playerid, modelid)
- {
- new bool:done = false;
- for(new i = 0; i < 10; i++)
- {
- if(!IsPlayerAttachedObjectSlotUsed(playerid, i)) continue;
- if(FIX_pAcc[playerid][i][model] == modelid) RemovePlayerAttachedObject(playerid, i), done = true;
- }
- if(done) return 1;
- return 0;
- }
- stock GetPlayerAttachedObject(playerid, index)
- {
- if(!IsPlayerAttachedObjectSlotUsed(playerid, index)) return 0;
- else return FIX_pAcc[playerid][index][model];
- }
- stock GetPlayerBodyPartUsed(playerid, index)
- {
- if(!IsPlayerAttachedObjectSlotUsed(playerid, index)) return 0;
- else return FIX_pAcc[playerid][index][pdc];
- }
- stock GetPlayerIndexByModel(playerid, model)
- {
- for(new i = 0; i < 10; i++)
- {
- if(!IsPlayerAttachedObjectSlotUsed(playerid, i)) continue;
- else
- {
- if(FIX_pAcc[playerid][i][model] == model) return i;
- else return 0;
- }
- }
- }
- stock GetPlayerAccOffSet(playerid, index, &Float:offsetX, &Float:offsetY, &Float:offsetZ)
- {
- if(!IsPlayerAttachedObjectSlotUsed(playerid, index)) return 0;
- else
- {
- offsetX = FIX_pAcc[playerid][index][o][0];
- offsetY = FIX_pAcc[playerid][index][o][1];
- offsetZ = FIX_pAcc[playerid][index][o][2];
- return 1;
- }
- }
- stock GetPlayerAccRot(playerid, index, &Float:rotX, &Float:rotY, &Float:rotZ)
- {
- if(!IsPlayerAttachedObjectSlotUsed(playerid, index)) return 0;
- else
- {
- rotX = FIX_pAcc[playerid][index][o][3];
- rotY = FIX_pAcc[playerid][index][o][4];
- rotZ = FIX_pAcc[playerid][index][o][5];
- return 1;
- }
- }
- stock GetPlayerAccScale(playerid, index, &Float:scaleX, &Float:scaleY, &Float:scaleZ)
- {
- if(!IsPlayerAttachedObjectSlotUsed(playerid, index)) return 0;
- else
- {
- scaleX = FIX_pAcc[playerid][index][o][6];
- scaleY = FIX_pAcc[playerid][index][o][7];
- scaleZ = FIX_pAcc[playerid][index][o][8];
- return 1;
- }
- }
- stock GetPlayerAccMaterial(playerid, index, &col1, &col2)
- {
- if(!IsPlayerAttachedObjectSlotUsed(playerid, index)) return 0;
- else
- {
- col1 = FIX_pAcc[playerid][index][col][0];
- col2 = FIX_pAcc[playerid][index][col][1];
- return 1;
- }
- }
- #if defined _ALS_SetPlayerAttachedObject
- #undef SetPlayerAttachedObject
- #else
- #define _ALS_SetPlayerAttachedObject
- #endif
- #define SetPlayerAttachedObject S_SetPlayerAttachedObject
- #if defined _ALS_RemovePlayerAttachedObject
- #undef RemovePlayerAttachedObject
- #else
- #define _ALS_RemovePlayerAttachedObject
- #endif
- #define RemovePlayerAttachedObject S_RemovePlayerAttachedObject
- native GetPlayerAttachedObject(playerid, index);
- native GetPlayerBodyPartUsed(playerid, index);
- native GetPlayerIndexByModel(playerid, model);
- native GetPlayerAccOffSet(playerid, index, &Float:offsetX, &Float:offsetY, &Float:offsetZ);
- native GetPlayerAccRot(playerid, index, &Float:rotX, &Float:rotY, &Float:rotZ);
- native GetPlayerAccScale(playerid, index, &Float:scaleX, &Float:scaleY, &Float:scaleZ);
- native GetPlayerAccMaterial(playerid, index, &col1, &col2);
- native RemovePlayerAttachedObjectModel(playerid, modelid);
Advertisement
Add Comment
Please, Sign In to add comment