Why does this repeat?
#1

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
Reply
#2

What about to make it under OnPlayerPickUpPickup? OnPlayerUpdate seems unnessacary in this case.
Reply
#3

But still wont it repeat?
Reply
#4

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.
Reply
#5

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?
Reply
#6

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.
Reply
#7

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)