01.02.2013, 16:05
Hey guys,
I want to create a command you can only type ones.
How can I do it ?
Tnx
I want to create a command you can only type ones.
How can I do it ?

Tnx

command(once, playerid, params[])
{
new pressed = false;
if(pressed == false)
{
pressed = true;
// do your code now!
}
return 1;
}
new
bool: g_bCmdUsed[ MAX_PLAYERS ]
;
if( !g_bCmdUsed[ playerid ] ) //if it's false
{
//do command
g_bCmdUsed[ playerid ] = true;
}
pawn Код:
|
new
typedCommand[MAX_PLAYERS];
CMD:once(playerid, params[])
{
if(!typedCommand[playerid])
{
typedCommand[playerid] = 1;
// Whatever you want the command to do
}
else
{
// Error message saying that they already used it
}
return 1;
}
public OnPlayerConnect(playerid)
{
typedCommand[playerid] = 0; // Here we reset the variable so other players who join with same ID can use the command later
return 1;
}
// You can also save the variable in player's file
@Blackraven: Not quite. The variable would reset each time you did the command, because you declare the variable inside it. You would have to declare it globally for it to work, like I've done below.
_________ You would need to declare a global boolean, for example: pawn Код:
pawn Код:
|