Why does this repeat? - 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: Why does this repeat? (
/showthread.php?tid=158564)
Why does this repeat? -
Lorenc_ - 10.07.2010
Well hello, Im making a GunBox minigame which is sorta like Sandras CashBox minigame.
So i made a little thing where if your out of ammo it resets the gunbox minigame. I just dont get it, when i test the gunbox minigame and waste my ammo the client messages repeat.
heres my code:
pawn Код:
if(IsGunBoxPickedUp == 1)
{
if(GetPlayerWeapon(playerid) == 38 && GetPlayerAmmo(playerid) == 0)
{
new str[128];
SendClientMessageToAll(0xFFD700AA, "A new game of GunBox will start in 20 minutes!");
SetTimer("StartNewGunBoxGame", GunBoxTimer, 0);
new pName[MAX_PLAYER_NAME];
GetPlayerName(GunBoxOwner, pName, 24);
format(str, 128, "%s (ID: %d) had the gun box and ran out of ammo.", pName, playerid);
SendClientMessageToAll(0xFFD700AA, str);
GunBoxMinigameStarted = 0;
DestroyPickup(GunBoxPickup);
PlayerWastedAmmo = 1;
}
}
return 1;
Im not sure how to fix it.
Should i add a timer?
Thanks
-Lorenc
Re: Why does this repeat? -
DeathOnaStick - 10.07.2010
What about to make it under OnPlayerPickUpPickup? OnPlayerUpdate seems unnessacary in this case.
Re: Why does this repeat? -
Lorenc_ - 10.07.2010
But still wont it repeat?
Re: Why does this repeat? -
DeathOnaStick - 10.07.2010
I dont think so, because it is just called after picking up the pickup and after you picked it up once with this code, it will be destroyed, so the messages cant be called again, due to the fact that the pickup cannot be picked up again.
Re: Why does this repeat? -
Lorenc_ - 10.07.2010
But onplayerpickuppickup is already in use. That part is the main part of the script. And still idgi why do you need to pickup something to check if the player has a minigun with 0 ammo?
Re: Why does this repeat? -
DeathOnaStick - 10.07.2010
Quote:
Originally Posted by ((Lorenc))
But onplayerpickuppickup is already in use. That part is the main part of the script. And still idgi why do you need to pickup something to check if the player has a minigun with 0 ammo?
|
Your code says 'IsGunBoxPickedUp' so it seems to me like a pickup would be in use. If not, just give the player 1 ammo minigun.
Re: Why does this repeat? -
Lorenc_ - 10.07.2010
And that code is excuted there.
pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
if(pickupid == GunBoxPickup)
{
IsGunBoxPickedUp = 1; // do you see?
}
}
And no i dont want to player to have 1 ammo, that would be boring and a waste of gameplay on this minigame