Anit -DB bagged - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Anit -DB bagged (
/showthread.php?tid=174072)
Anti Drive-By bagged -
Cypress - 04.09.2010
Okay. here i made a anti db only for 1 weapon, M5.
I did so when a player enter to any vehicle as driver his weapon ammo will go to 0 (-30 ingame)
So when player exit from vehicle he loses he's weapon. I want to get the player weapon back and he's ammo too.
pawn Код:
new WeaponId;
new ammo;
if((newstate == PLAYER_STATE_DRIVER))
{
for(new i=0;i<11;i++)
{
if(GetPlayerWeapon(playerid) == 29)
{
GetPlayerWeaponData(playerid, i, WeaponId, ammo);
SetPlayerAmmo(playerid, 29, 0);
}
}
}
if((newstate == PLAYER_STATE_ONFOOT) && ((oldstate == PLAYER_STATE_DRIVER)))
{
GivePlayerWeapon(playerid,29, ammo);
}
return 1;
}
How to give him the weapon back with ammo that he had before incar?
How to use Use GetPlayerWeaponData ? Make it for me
Re: Anit -DB bagged -
LarzI - 04.09.2010
Use GetPlayerWeaponData
Re: Anit -DB bagged -
Cypress - 04.09.2010
Quote:
Originally Posted by LarzI
Use GetPlayerWeaponData
|
I can't, can u make it please for me?
Re: Anit -DB bagged -
LarzI - 04.09.2010
Is the code you posted above what you use already?
Re: Anit -DB bagged -
Cypress - 04.09.2010
Quote:
Originally Posted by LarzI
Is the code you posted above what you use already?
|
Well as you see i already triyed the WeaponData. Maybe i didn't made it right?
Re: Anit -DB bagged -
General Abe - 04.09.2010
pawn Код:
new gun, ammo;
if(newstate == PLAYER_STATE_DRIVER && GetPlayerWeapon(playerid) == 29)
{
if(GetPlayerWeapon(playerid) == 29)
{
GetPlayerWeaponData(playerid, 4, gun, ammo); // An MP5 was, is, and always will be slot 4. You don't need a loop for a constant value.
SetPlayerAmmo(playerid, 4, 0); // SetPlayerAmmo works on the SLOT, not the weapon.
}
}
if(newstate == 1 && oldstate == 2)
{
GivePlayerWeapon(playerid, 29, ammo);
}
return 1;
}
There's one way to do it, but the other...
pawn Код:
public OnPlayerStateChange(playerid, oldstate, newstate)
{
if(newstate == 2) SetPlayerArmedWeapon(playerid, 0);
return 1;
}
Re: Anit -DB bagged -
Cypress - 04.09.2010
Quote:
Originally Posted by Brian.
pawn Код:
new gun, ammo;
if(newstate == PLAYER_STATE_DRIVER && GetPlayerWeapon(playerid) == 29) { if(GetPlayerWeapon(playerid) == 29) { GetPlayerWeaponData(playerid, 4, gun, ammo); // An MP5 was, is, and always will be slot 4. You don't need a loop for a constant value. SetPlayerAmmo(playerid, 4, 0); // SetPlayerAmmo works on the SLOT, not the weapon. } } if(newstate == 1 && oldstate == 2) { GivePlayerWeapon(playerid, 29, ammo); } return 1; }
There's one way to do it, but the other...
pawn Код:
public OnPlayerStateChange(playerid, oldstate, newstate) { if(newstate == 2) SetPlayerArmedWeapon(playerid, 0); return 1; }
|
Not working dude.
Re: Anit -DB bagged -
General Abe - 05.09.2010
Are you sure ammo is a global variable?
Re: Anit -DB bagged -
Cypress - 05.09.2010
Quote:
Originally Posted by Brian.
Are you sure ammo is a global variable?
|
Yes i'm sure. When i enter to a vehicle nothing happen. My ammo stay as it was before and i can shot.
Re: Anit -DB bagged -
Calgon - 05.09.2010
pawn Код:
public OnPlayerStateChange(playerid, oldstate, newstate)
{
if(newstate == 2) GivePlayerWeapon(playerid, 0, 6666); // Give the player fists with an arbitrary ammo value
return 1;
}
Pretty sure SetPlayerArmedWeapon doesn't work in cars.