Questions about command.
#1

I think I have seen commands that could only be used once per life. Which I mean is, like for example I spawn once, probably as a Cop , I use the command for example, /spikestrip and then the object is released but I can't use the command until I respawn. Is it like possible? One command per life. Another example, a simpler one. Ok, lets say I m playing a DM match and its free that everyone has a health kit. Once the player is hurt, he can use the /kit to heal himself. But the command can only be used once. The next time he can use it is when he respawns. Is this possible? Secondly, I wanted to know the same thing but a little different than the command above. Is it also possible that a player could use a command but then he can use it only again after 1/2 mins. He doesn't have to respawn? Are this even possible. Hope someone could answer my problems on this topic. Thanks in advance.
Reply
#2

You would want to look into OnPlayerDeath to process the first two requests. As for the final one, that is relatively simple.

pawn Код:
// Toward the top of your script.

new UsedKit[MAX_PLAYERS];

// Under OnPlayerConnect

UsedKit[playerid] = 0;

// Under your /kit Command:

if(UsedKit[playerid] == 1) return SendClientMessage(playerid,-1,"[SERVER]: You've already used your one Medical Kit.");

// below that:

UsedKit[playerid] = 1;

// Under OnPlayerDeath

UsedKit[playerid] = 0;
The above code (if implemented correctly) will allow the said player to only use /kit once before respawning. As for the cooldown, you'd want a timer.

pawn Код:
// Under your /kit command

SetTimerEx("ResetKit",(60000*2),0,"d",playerid); // This will disallow the player from using /kit for two minutes.

// Bottom of your script.
forward ResetKit(playerid);
public ResetKit(playerid)
{
    UsedKit[playerid] = 0;
    return 1;
}
Reply
#3

Thanks for the reply. +Rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)