/givewep not working properly -
GoldenLion - 11.07.2016
Hi, I've made some changes to the /givewep in my script, but it doesn't seem to work properly now. It compiles all good, I can give all weapons except "heavy weapons" (shotgun, mp5, ak, etc). When I try to give them to myself, it does nothing. Here are the codes:
Stocks:
Код:
stock IsAHeavyWeapon(weaponid)
{
switch (weaponid) {
case 25, 27, 29, 30, 31, 33, 34: return 1;
}
return 0;
}
stock PlayerHasHeavyWeapon(playerid)
{
if (PlayerHasWeapon(playerid, 25) || PlayerHasWeapon(playerid, 27) || PlayerHasWeapon(playerid, 29) || PlayerHasWeapon(playerid, 30) || PlayerHasWeapon(playerid, 31) || PlayerHasWeapon(playerid, 33) || PlayerHasWeapon(playerid, 34)) return 1;
return 0;
}
Part of givewep that is not working:
Код:
if (IsAHeavyWeapon(weaponid))
{
if (PlayerHasHeavyWeapon(userid))
{
if (PlayerHasWeapon(userid, weaponid))
{
GiveWeaponToPlayer(userid, weaponid, ammo);
SendServerMessage(playerid, "You have gave %s a %s with %d ammo.", ReturnName(userid, 0), ReturnWeaponName(weaponid), ammo);
}
else SendErrorMessage(playerid, "The specified player has already a heavy weapon.");
}
}
else
{
GiveWeaponToPlayer(userid, weaponid, ammo);
SendServerMessage(playerid, "You have gave %s a %s with %d ammo.", ReturnName(userid, 0), ReturnWeaponName(weaponid), ammo);
}
Re: /givewep not working properly -
Dayrion - 11.07.2016
Show the function : PlayerHasWeapon please.
Re: /givewep not working properly -
GoldenLion - 11.07.2016
Quote:
Originally Posted by Dayrion
Show the function : PlayerHasWeapon please.
|
Код:
stock PlayerHasWeapon(playerid, weaponid)
{
new
weapon,
ammo;
for (new i = 0; i < 13; i ++) if (PlayerData[playerid][pGuns][i] == weaponid) {
GetPlayerWeaponData(playerid, i, weapon, ammo);
if (weapon == weaponid && ammo > 0) return 1;
}
return 0;
}
There's really no need in that, because it works properly, I'm 100% sure because it works everywhere else.
Re: /givewep not working properly -
gurmani11 - 11.07.2016
damn 3 checks for heavy weapon :O
Show it
Re: /givewep not working properly -
GoldenLion - 11.07.2016
Ah, I forgot to give player a weapon when PlayerHasHeavyWeapon check fails. :P