Set Ammo - 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: Set Ammo (
/showthread.php?tid=193626)
Set Ammo -
Lars_Frederiksen - 26.11.2010
How can I make it so it sets the players ammo to -30-30 when they get in a car? I've tryed SetPlayerAmmo(playerid,gun,-30);
GivePlayerWeapon(playerid,gun,-30);
Also how could I make it so when the player is looking left/right in a car, and they try and fire, it will like, slap them out of the car? <<-- Nevermind I figured that out
But I still need help figuring out the -30 ammo thing.
Re: Set Ammo -
DaneAMattie - 26.11.2010
Quote:
Originally Posted by Lars_Frederiksen
How can I make it so it sets the players ammo to -30-30 when they get in a car? I've tryed SetPlayerAmmo(playerid,gun,-30);
GivePlayerWeapon(playerid,gun,-30);
Also how could I make it so when the player is looking left/right in a car, and they try and fire, it will like, slap them out of the car? <<-- Nevermind I figured that out
But I still need help figuring out the -30 ammo thing.
|
you could remove the weapon and let it remember the ammo it had, then add the same weapon with the remembered ammo - 30
Respuesta: Set Ammo -
OwlCity - 26.11.2010
You should use:
pawn Код:
new ammo = GetPlayerAmmo(playerid);
ammo -=30;
SetPlayerAmmo(playerid,gun,ammo);
Re: Set Ammo -
Lars_Frederiksen - 26.11.2010
Neither of those two work... I think the SetPlayerAmmo thing is bugged or something, here's my code.
pawn Код:
switch(GetPlayerWeapon(playerid)) // mp5, tech 9, mac 10 by lars
{
case 29, 28, 32:
{
new gun = GetPlayerWeapon(playerid);
new ammo = GetPlayerAmmo(playerid);
ammo -=30;
SetPlayerAmmo(playerid,gun,ammo);
//RemovePlayerWeapon(playerid, gun);
PlayerInfo[playerid][pHadGun] = 1;
PlayerInfo[playerid][pHadGunID] = gun;
}
}
This literally doesn't do anything, player still has all his ammo.
Re: Set Ammo -
The_Moddler - 26.11.2010
Just set it's ammo to 0.
Or make a variable saving the players weapons and ammo, then you reset hes ammo, and when they get out of their car you give his weapons again..
Re: Set Ammo -
Lars_Frederiksen - 26.11.2010
Okay which gun slot would the MP5, Tech 9, Mac 10 save in? I have pAmmo1, pAmmo2, pAmmo3, pAmmo4, pAmmo5
Re: Set Ammo -
XoSarahMoX - 26.11.2010
The guns are slot 4, if you need anymore slots here:
https://sampwiki.blast.hk/wiki/Weapons
Re: Set Ammo -
Lars_Frederiksen - 26.11.2010
pawn Код:
new gun = GetPlayerWeapon(playerid);
new ammo = -30;
RemovePlayerWeapon(playerid, gun);
PlayerInfo[playerid][pAmmo4] = ammo;
GivePlayerWeapon(playerid, gun, ammo);
PlayerInfo[playerid][pHadGun] = 1;
PlayerInfo[playerid][pHadGunID] = gun;
Nah not workin.
Re: Set Ammo -
The_Moddler - 26.11.2010
pawn Код:
new Weapon[MAX_PLAYERS][13];
new Ammo[MAX_PLAYERS][13];
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
for(new i = 0; i < 13; i++)
{
GetPlayerWeaponData(playerid, i, Weapon[playerid][i], Ammo[playerid][i]);
ResetPlayerWeapons(playerid);
}
}
else if(newstate == PLAYER_STATE_ONFOOT)
{
for(new i = 0; i < 13; i++)
{
GivePlayerWeapon(playerid, Weapon[playerid][i], Ammo[playerid][i]);
}
}
return 1;
}
There you go.