25.10.2016, 09:20
Hello, I am building a weapon attachment system, and I've encountered a problem.
The script is okay, no errors but the public where I call the timer each half a second to check whether a player switched weapon and should be on his back is wrong. Nitestick, baseball bat, Deagle, Colt, M4, AK47 and Sniper are all working, but SMGs and shotguns not. There is the timer public:
The script is okay, no errors but the public where I call the timer each half a second to check whether a player switched weapon and should be on his back is wrong. Nitestick, baseball bat, Deagle, Colt, M4, AK47 and Sniper are all working, but SMGs and shotguns not. There is the timer public:
pawn Код:
public weaponatt_Attach()
{
new fuckingammo;
foreach(new px : Player)
{
if(IsPlayerInAnyVehicle(px))
{
if(IsPlayerAttachedObjectSlotUsed(px, 5)) RemovePlayerAttachedObject(px, 5);
if(IsPlayerAttachedObjectSlotUsed(px, 6)) RemovePlayerAttachedObject(px, 6);
if(IsPlayerAttachedObjectSlotUsed(px, 8)) RemovePlayerAttachedObject(px, 8);
if(IsPlayerAttachedObjectSlotUsed(px, 9)) RemovePlayerAttachedObject(px, 9);
weaponatt_wep[px] = -1;
continue;
}
if(weaponatt_wep[px] != GetPlayerWeapon(px))
{
for(new a; a < 12; a++)
{
GetPlayerWeaponData(px, a, weaponatt_weps[a], fuckingammo);
switch(a)
{
case 1:
{
if(IsPlayerAttachedObjectSlotUsed(px, 5)) RemovePlayerAttachedObject(px, 5);
switch(weaponatt_weps[a])
{
case 3: if(GetPlayerWeapon(px) != 3 && WeaponDat[px][Hide][0]) SetPlayerAttachedObject( px, 5, 334, WeaponDat[px][WeaponBone][0], WeaponDat[px][WeaponRotX][0],WeaponDat[px][WeaponRotY][0],WeaponDat[px][WeaponRotZ][0], WeaponDat[px][WeaponX][0],WeaponDat[px][WeaponY][0],WeaponDat[px][WeaponZ][0]);
case 5: if(GetPlayerWeapon(px) != 5 && WeaponDat[px][Hide][1]) SetPlayerAttachedObject( px, 5, 336, WeaponDat[px][WeaponBone][1], WeaponDat[px][WeaponRotX][1],WeaponDat[px][WeaponRotY][1],WeaponDat[px][WeaponRotZ][1], WeaponDat[px][WeaponX][1],WeaponDat[px][WeaponY][1],WeaponDat[px][WeaponZ][1]);
}
}
case 2:
{
if(IsPlayerAttachedObjectSlotUsed(px, 6)) RemovePlayerAttachedObject(px, 6);
switch(weaponatt_weps[a])
{
case 22: if(GetPlayerWeapon(px) != 22 && WeaponDat[px][Hide][2]) SetPlayerAttachedObject( px, 6, 346, WeaponDat[px][WeaponBone][2], WeaponDat[px][WeaponRotX][2],WeaponDat[px][WeaponRotY][2],WeaponDat[px][WeaponRotZ][2], WeaponDat[px][WeaponX][2],WeaponDat[px][WeaponY][2],WeaponDat[px][WeaponZ][2]);
case 24: if(GetPlayerWeapon(px) != 24 && WeaponDat[px][Hide][3]) SetPlayerAttachedObject( px, 6, 348, WeaponDat[px][WeaponBone][3], WeaponDat[px][WeaponRotX][3],WeaponDat[px][WeaponRotY][3],WeaponDat[px][WeaponRotZ][3], WeaponDat[px][WeaponX][3],WeaponDat[px][WeaponY][3],WeaponDat[px][WeaponZ][3]);
}
}
case 3:
{
if(IsPlayerAttachedObjectSlotUsed(px, 8)) RemovePlayerAttachedObject(px, 8);
switch(weaponatt_weps[a])
{
case 25: if(GetPlayerWeapon(px) != 25 && WeaponDat[px][Hide][4]) SetPlayerAttachedObject( px, 8, 349,WeaponDat[px][WeaponBone][4], WeaponDat[px][WeaponRotX][4],WeaponDat[px][WeaponRotY][4],WeaponDat[px][WeaponRotZ][4], WeaponDat[px][WeaponX][4],WeaponDat[px][WeaponY][4],WeaponDat[px][WeaponZ][4]);
case 27: if(GetPlayerWeapon(px) != 27 && WeaponDat[px][Hide][5]) SetPlayerAttachedObject( px, 8, 350, WeaponDat[px][WeaponBone][5], WeaponDat[px][WeaponRotX][5],WeaponDat[px][WeaponRotY][5],WeaponDat[px][WeaponRotZ][5], WeaponDat[px][WeaponX][5],WeaponDat[px][WeaponY][5],WeaponDat[px][WeaponZ][5]);
}
}
case 4:
{
if(IsPlayerAttachedObjectSlotUsed(px, 8)) RemovePlayerAttachedObject(px, 8);
switch(weaponatt_weps[a])
{
case 28: if(GetPlayerWeapon(px) != 28 && WeaponDat[px][Hide][6]) SetPlayerAttachedObject( px, 8, 352, WeaponDat[px][WeaponBone][6], WeaponDat[px][WeaponRotX][6],WeaponDat[px][WeaponRotY][6],WeaponDat[px][WeaponRotZ][6], WeaponDat[px][WeaponX][6],WeaponDat[px][WeaponY][6],WeaponDat[px][WeaponZ][6]);
case 29: if(GetPlayerWeapon(px) != 29 && WeaponDat[px][Hide][7]) SetPlayerAttachedObject( px, 8, 353, WeaponDat[px][WeaponBone][7], WeaponDat[px][WeaponRotX][7],WeaponDat[px][WeaponRotY][7],WeaponDat[px][WeaponRotZ][7], WeaponDat[px][WeaponX][7],WeaponDat[px][WeaponY][7],WeaponDat[px][WeaponZ][7]);
case 32: if(GetPlayerWeapon(px) != 32 && WeaponDat[px][Hide][10]) SetPlayerAttachedObject( px, 8, 372, WeaponDat[px][WeaponBone][10], WeaponDat[px][WeaponRotX][10],WeaponDat[px][WeaponRotY][10],WeaponDat[px][WeaponRotZ][10], WeaponDat[px][WeaponX][10],WeaponDat[px][WeaponY][10],WeaponDat[px][WeaponZ][10]);
}
}
case 5:
{
if(IsPlayerAttachedObjectSlotUsed(px, 8)) RemovePlayerAttachedObject(px, 8);
switch(weaponatt_weps[a])
{
case 30: if(GetPlayerWeapon(px) != 30 && WeaponDat[px][Hide][8]) SetPlayerAttachedObject( px, 8, 355, WeaponDat[px][WeaponBone][8], WeaponDat[px][WeaponRotX][8],WeaponDat[px][WeaponRotY][8],WeaponDat[px][WeaponRotZ][8], WeaponDat[px][WeaponX][8],WeaponDat[px][WeaponY][8],WeaponDat[px][WeaponZ][8]);
case 31: if(GetPlayerWeapon(px) != 31 && WeaponDat[px][Hide][9]) SetPlayerAttachedObject( px, 8, 356, WeaponDat[px][WeaponBone][9], WeaponDat[px][WeaponRotX][9],WeaponDat[px][WeaponRotY][9],WeaponDat[px][WeaponRotZ][9], WeaponDat[px][WeaponX][9],WeaponDat[px][WeaponY][9],WeaponDat[px][WeaponZ][9]);
}
}
case 6:
{
if(IsPlayerAttachedObjectSlotUsed(px, 9)) RemovePlayerAttachedObject(px, 9);
switch(weaponatt_weps[a])
{
case 34: if(GetPlayerWeapon(px) != 34 && WeaponDat[px][Hide][11]) SetPlayerAttachedObject( px, 9, 358, WeaponDat[px][WeaponBone][11], WeaponDat[px][WeaponRotX][11],WeaponDat[px][WeaponRotY][11],WeaponDat[px][WeaponRotZ][11], WeaponDat[px][WeaponX][11],WeaponDat[px][WeaponY][11],WeaponDat[px][WeaponZ][11]);
}
}
}
}
weaponatt_wep[px] = GetPlayerWeapon(px);
}
}
return 1;
}