Help with script... -
The_Moddler - 05.10.2010
Well, I need some help with this code..
pawn Код:
#define GivePlayerWeaponEx(%0,%1,%2) SetPVarInt(%0,"Weap",%1), GivePlayerWeapon(%0,%1,%2)
#define GetPlayerWeaponDataEx(%0,%1,%2,%3) GetPlayerWeaponData(%0,%1,%2,%3)
#define ResetPlayerWeaponsEx(%0) ResetPlayerWeapons(%0)
#define GetPlayerWeaponEx(%0) GetPlayerWeapon(%0)
So, what I need, is that
GetPlayerWeaponDataEx will get the variable "
Weapon" for the weapon ID that the player has.. I tryed this:
pawn Код:
#define GetPlayerWeaponDataEx(%0,%1,%2,%3) GetPlayerWeaponData(%0,%1,GetPVarInt(%0,"Weap"),%3)
And didn't work
Thanks
Re: Help with script... -
Mauzen - 05.10.2010
The &weapon parameter in GetPlayerWeaponData is just a reference, that is filled with the weapon id, the player has in the specified slot.
You could use GetPlayerAmmo, but it will only work, if the player has the weapon equipped.
Other ways would be, to define something to get the weapon slot from a weapon id
It could look like this (
https://sampwiki.blast.hk/wiki/Control_Structures):
#define GetWeaponSlot(%0) (%0 == 22 || %0 == 23 || %0 == 24) ? (2) : ((%0 == 25 || %0 == 26 || %0 == 27) ? (3) : (and so on for all slots)
This would be a long define, you can also make a stock function with switch doing the same thing.
Re: Help with script... -
The_Moddler - 05.10.2010
Hmm.. will this work?
pawn Код:
stock GetWeaponSlot(wid)
{
switch(wid)
{
case 0, 1: return 0;
case 2..9: return 1;
case 22..24: return 2;
case 25..27: return 3;
case 28, 29, 32: return 4;
case 30, 31: return 5;
case 33, 34: return 6;
case 35..38: return 7;
case 16..19, 39: return 8;
case 41..43: return 9;
case 10..15: return 10;
case 44..46: return 11;
case 40: return 12;
default: return -1;
}
return -1;
}
EDIT: No, it won't, it even doesn't get the player weapon to check lol, I will make one by my self xD
Thanks
EDIT2:
Well, it was going to work, but I found this one
pawn Код:
stock GetWeaponSlot(weaponid)
{
switch (weaponid)
{
case 0, 1: return 0; // Unarmed
case 2 .. 9: return 1; // Melee
case 22 .. 24: return 2; // Pistol
case 25 .. 27: return 3; // Shotgun
case 28, 29, 32: return 4; // SMG
case 30, 31: return 5; // Machinegun
case 33, 34: return 6; // Rifle
case 35 .. 38: return 7; // Heavy
case 16, 18, 39: return 8; // Projectile
case 42, 43: return 9; // Special
case 14 : return 10; // Gifts
case 44 .. 46: return 11; // Special
case 40 : return 12; // Detonator
}
return 0;
}
Now, what should I do?
Thanks again
Re: Help with script... -
Mauzen - 05.10.2010
Ah ok^^
You can now use this to get the data (you need the ammo of the weapon i guess) of the weapon stored in the pvar.
Due to the two reference variables in GetPlayerWeaponData it would be hard to use it in a define, so the best would be to create a stock for this, too.
It could look like this then:
pawn Код:
stock GetPlayerWeaponDataEx(playerid)
{
new weapon, ammo;
GetPlayerWeaponData(playerid, GetWeaponSlot(GetPVarInt(playerid,"Weap")), weapon, ammo);
return ammo;
}
This now just returns the ammo of the pvar-weapon, not as simple as a define, but still comfortable to use.
Re: Help with script... -
The_Moddler - 05.10.2010
Yes!! Thanks