26.03.2016, 18:41
So I have created an array that contains the ID's of weapons that are valid in terms that I want them to be valid in my gamemode and those that I am not planning to use invalid. Now the problem is that the function that removes the weapon using that array does not function properly and causes my command to become unknown.
The issue is that the command does not execute properly as it should have, when it reaches RemoveWeaponFromPlayer it becomes unknown and the function itself does not exectue.
pawn Код:
new e_ValidWeapon[] =
{
0,
3,
4,
5,
8,
9,
15,
22,
23,
24,
25,
27,
28,
29,
30,
31,
32,
33,
34,
41,
42,
43
};
pawn Код:
RemoveWeaponFromPlayer(playerid, weaponid)
{
new Ammo;
SetPlayerArmedWeapon(playerid, weaponid);
Ammo = GetPlayerAmmo(playerid);
if(weaponid != e_ValidWeapon[weaponid]) return false;
else if(weaponid == e_ValidWeapon[weaponid])
{
print("Executed.");
GivePlayerWeapon(playerid, weaponid, -Ammo);
return true;
}
return false;
}
pawn Код:
CMD:offduty(playerid, params[])
{
new string[250];
if(GetPlayerInterior(playerid) == 6 && pInfo[playerid][USER_FACTION] == SCSD)
{
if(pInfo[playerid][USER_FACTIONRANK] == 1)
{
SetPlayerArmour(playerid, 0.0);
SetPlayerHealth(playerid, 100.0);
RemoveWeaponFromPlayer(playerid, 3);
RemoveWeaponFromPlayer(playerid, 24);
RemoveWeaponFromPlayer(playerid, 41);
SetPlayerDuty(playerid, false);
format(string, sizeof(string), "** Cadet %s is now off-duty! **", RemoveUnderscore(playerid));
SendMessageToFaction(SCSD, string);
return 1;
}
else if(pInfo[playerid][USER_FACTIONRANK] == 2)
{
SetPlayerArmour(playerid, 0.0);
SetPlayerHealth(playerid, 100.0);
RemoveWeaponFromPlayer(playerid, 3);
RemoveWeaponFromPlayer(playerid, 24);
RemoveWeaponFromPlayer(playerid, 41);
SetPlayerDuty(playerid, false);
format(string, sizeof(string), "** Deputy I %s is now off-duty! **", RemoveUnderscore(playerid));
SendMessageToFaction(SCSD, string);
return 1;
}
else if(pInfo[playerid][USER_FACTIONRANK] == 3)
{
SetPlayerArmour(playerid, 0.0);
SetPlayerHealth(playerid, 100.0);
RemoveWeaponFromPlayer(playerid, 3);
RemoveWeaponFromPlayer(playerid, 24);
RemoveWeaponFromPlayer(playerid, 41);
SetPlayerDuty(playerid, false);
format(string, sizeof(string), "** Deputy II %s is now off-duty! **", RemoveUnderscore(playerid));
SendMessageToFaction(SCSD, string);
return 1;
}
else if(pInfo[playerid][USER_FACTIONRANK] == 4)
{
SetPlayerArmour(playerid, 0.0);
SetPlayerHealth(playerid, 100.0);
RemoveWeaponFromPlayer(playerid, 3);
RemoveWeaponFromPlayer(playerid, 24);
RemoveWeaponFromPlayer(playerid, 41);
SetPlayerDuty(playerid, false);
format(string, sizeof(string), "** Corporal %s is now off-duty! **", RemoveUnderscore(playerid));
SendMessageToFaction(SCSD, string);
return 1;
}
else if(pInfo[playerid][USER_FACTIONRANK] == 5)
{
SetPlayerArmour(playerid, 0.0);
SetPlayerHealth(playerid, 100.0);
RemoveWeaponFromPlayer(playerid, 3);
RemoveWeaponFromPlayer(playerid, 24);
RemoveWeaponFromPlayer(playerid, 41);
SetPlayerDuty(playerid, false);
format(string, sizeof(string), "** Sergeant %s is now off-duty! **", RemoveUnderscore(playerid));
SendMessageToFaction(SCSD, string);
return 1;
}
else if(pInfo[playerid][USER_FACTIONRANK] == 6)
{
SetPlayerArmour(playerid, 0.0);
SetPlayerHealth(playerid, 100.0);
RemoveWeaponFromPlayer(playerid, 3);
RemoveWeaponFromPlayer(playerid, 24);
RemoveWeaponFromPlayer(playerid, 41);
SetPlayerDuty(playerid, false);
format(string, sizeof(string), "** Lieutenant %s is now off-duty! **", RemoveUnderscore(playerid));
SendMessageToFaction(SCSD, string);
return 1;
}
else if(pInfo[playerid][USER_FACTIONRANK] == 7)
{
SetPlayerArmour(playerid, 0.0);
SetPlayerHealth(playerid, 100.0);
RemoveWeaponFromPlayer(playerid, 3);
RemoveWeaponFromPlayer(playerid, 24);
RemoveWeaponFromPlayer(playerid, 41);
SetPlayerDuty(playerid, false);
format(string, sizeof(string), "** Captain %s is now off-duty! **", RemoveUnderscore(playerid));
SendMessageToFaction(SCSD, string);
return 1;
}
else if(pInfo[playerid][USER_FACTIONRANK] == 8)
{
SetPlayerArmour(playerid, 0.0);
SetPlayerHealth(playerid, 100.0);
RemoveWeaponFromPlayer(playerid, 3);
RemoveWeaponFromPlayer(playerid, 24);
RemoveWeaponFromPlayer(playerid, 41);
SetPlayerDuty(playerid, false);
format(string, sizeof(string), "** Major %s is now off-duty! **", RemoveUnderscore(playerid));
SendMessageToFaction(SCSD, string);
return 1;
}
else if(pInfo[playerid][USER_FACTIONRANK] == 9)
{
SetPlayerArmour(playerid, 0.0);
SetPlayerHealth(playerid, 100.0);
RemoveWeaponFromPlayer(playerid, 3);
RemoveWeaponFromPlayer(playerid, 24);
RemoveWeaponFromPlayer(playerid, 41);
SetPlayerDuty(playerid, false);
format(string, sizeof(string), "** Undersheriff %s is now off-duty! **", RemoveUnderscore(playerid));
SendMessageToFaction(SCSD, string);
return 1;
}
else if(pInfo[playerid][USER_FACTIONRANK] == 10)
{
SetPlayerArmour(playerid, 0.0);
SetPlayerHealth(playerid, 100.0);
RemoveWeaponFromPlayer(playerid, 3);
RemoveWeaponFromPlayer(playerid, 24);
RemoveWeaponFromPlayer(playerid, 41);
SetPlayerDuty(playerid, false);
format(string, sizeof(string), "** Sheriff %s is now off-duty! **", RemoveUnderscore(playerid));
SendMessageToFaction(SCSD, string);
return 1;
}
return 1;
}
return 1;
}