21.05.2011, 12:41
You should know that the function GetPlayerWeapon don't work for passengers, so i'll explain how to solve this problem.
First, store the player weapon when he enter in a vehicle in a PVar(or common variable).
Make sure that if the player receiving a gun, his pVar is updated. For this, is needed to create a function that give the player weapon and store your id.
And finally, you need to create a function to get the player data stored in PVar, or you can use this directly.
Doing this, you can get the player weapon as passenger, you can do the same thing for GetPlayerAmmo.
First, store the player weapon when he enter in a vehicle in a PVar(or common variable).
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(ispassenger)
{
SetPVarInt(playerid, "HandWeapon", GetPlayerWeapon(playerid));
}
}
pawn Код:
GivePlayerWeaponAndUpdate(playerid, weaponid, ammo)
{
GivePlayerWeapon(playerid, weaponid, ammo);
SetPVarInt(playerid, "HandWeapon", weaponid);
return 1;
}
pawn Код:
GetPlayerWeaponEx(playerid)
{
return GetPVarInt(playerid, "HandWeapon");
}
//or simply:
GetPVarInt(playerid, "HandWeapon");
//or even, if you understand about Macros:
#define GetPlayerWeaponEx(%0) GetPVarInt(%0, "HandWeapon")