/givewep not working properly
#1

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);
	}
Reply
#2

Show the function : PlayerHasWeapon please.
Reply
#3

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.
Reply
#4

damn 3 checks for heavy weapon :O
Код:
PlayerHasWeapon
Show it
Reply
#5

Ah, I forgot to give player a weapon when PlayerHasHeavyWeapon check fails. :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)