ammo -
Zonoya - 01.09.2011
i have no script and i dont want it made for me but i want to be pointed in the right direction
i want to know how to make a script that when u run out of ammo it sends a message to the player saying you Are Out Of Ammo then the player type's /reload and it restores the player's ammo of the gun he is holding at the moment. if u can show me an example or point me in the right direction
regards.
[Nuclear]Phoebe.
AW: ammo -
Padarom - 01.09.2011
I would try to create a very frequent timer (or maybe OnPlayerUpdate) and a boolean like bool:ToldOutOfAmmo[MAX_PLAYERS];
Every time the timer passing you check wether or not the player has a weapon (just check his weapon-id) and then GetPlayerAmmo. If it's 0 check if ToldOutOfAmmo is true, else send a message to him and set it to true.
For the /reload just use SetPlayerAmmo then.
Hope it helped.
AW: ammo -
Zonoya - 01.09.2011
ok i get /reload but i dont get the rest
Re: ammo -
Vince - 01.09.2011
You could try using
https://sampwiki.blast.hk/wiki/GetPlayerWeaponState with one of these:
https://sampwiki.blast.hk/wiki/Weapon_States
Re: ammo -
Zonoya - 01.09.2011
ive made my reload cmd but i cant grasp the out of bullets thing
AW: ammo -
Padarom - 01.09.2011
pawn Код:
new bool:ToldOutOfAmmo[MAX_PLAYERS]=false;
// Under OnPlayerUpdate:
if(GetPlayerWeaponState(playerid) == 0)
{
if(ToldOutOfAmmo[playerid] == false)
{
ToldOutOfAmmo[playerid] = true;
SendClientMessage(playerid, COLOR_RED, "You're out of ammo. Type /reload");
}
}
Used WeaponStates from the link Vince posted. Something like this is what you can do.
Of course you have to reset the boolean on your /reload command.
Re: ammo -
Zonoya - 01.09.2011
ty Dude
Re: ammo -
Zonoya - 01.09.2011
but wouldn't it when u have no ammo remove the gun from ur hand?
Respuesta: ammo -
Alex_Obando - 01.09.2011
ResetPlayerWeapons(playerid);
Re: ammo -
Zonoya - 01.09.2011
no dude i dont want it to remove the weapon
AW: ammo -
Padarom - 01.09.2011
@Bella: Good question, haven't used weapons in gta a long time now... You could check for WeaponState 2 instead of 1 (Last bullet instead of empty weapon) and save the weaponid in a PVar for the player. and with /reload the weapon saved within the PVar gets reloaded.
Re: ammo -
Zonoya - 01.09.2011
confused already
help me on this one
AW: ammo -
Padarom - 01.09.2011
Of course
pawn Код:
new bool:ToldOutOfAmmo[MAX_PLAYERS]=false;
//OnPlayerCommandText
if(!strcmp(cmdtext, "/reload", true) == 0)
{
if(GetPVarInt(playerid,"weaponid") != 0)
{
GivePlayerWeapon(playerid, GetPVarInt(playerid,"weaponid"), 100); // Give the player the weapon + ammo
ToldOutOfAmmo[playerid]=false; // Reset out of ammo message
SetPVarInt(playerid,"weaponid",0) // Reset weaponid
SendClientMessage(playerid,COLOR_RED,"Weapon reloaded.");
}
else SendClientMessage(playerid,COLOR_RED,"You are not out of ammo.");
return 1;
}
// Under OnPlayerUpdate
if(GetPlayerWeaponState(playerid) == 1)
{
if(ToldOutOfAmmo[playerid] == false)
{
ToldOutOfAmmo[playerid] = true;
SetPVarInt(playerid,"weaponid",GetPlayerWeapon(playerid));
SendClientMessage(playerid, COLOR_RED, "You're out of ammo. Type /reload");
}
}
I think this is all you wanted to know and hope it helped
Re: ammo -
Zonoya - 02.09.2011
thanks dude!