Help whit this command please -
Guss - 10.03.2015
Hi guys, I have this code for remove the driving license:
PHP код:
new pid;
new str[68], pName[MAX_PLAYER_NAME],Float:x, Float:y, Float:z;
GetPlayerName(pid, pName, sizeof(pName));
if(sscanf(params, "u", pid)) return SendClientMessage(playerid, -1, "Usage: /nodriving [id]");
if(!IsPlayerConnected(pid)) return SendClientMessage(playerid, COLOR_RED, "ERROR: Player is not online.");
RemovePlayerFromVehicle(pid);
format(str, sizeof(str), "%s loses her driving license", pName);
SendClientMessageToAll(RED, str);
GetPlayerPos(playerid, x, y, z);
SetPlayerPos(playerid, x, y, z);
nocar[pid] = true;
}
return true;
I did the command but am new to pawn. I want the duration of the function is 10 minutes and at the end of 10 minutes will automatically return the license to the player. No how, need help please. regards
Re: Help whit this command please -
CalvinC - 11.03.2015
You could use
SetTimerEx to set a timer of 10 minutes, and return his drivers license back after that.
Or you could have a timer of 1 second, where you decrease a player array by 1, this way you can just set that array to 600(10 minutes in seconds), and give back the drivers license when it reaches 0 again.
For a player array, declare it in the top of your script so it's global:
pawn Код:
new MyArray[MAX_PLAYERS];
And in your command, set it to 600.
Then create a repeating timer with
SetTimer in
OnGameModeInit, where the public should look something like this:
pawn Код:
forward MyTimer(); // When creating a public function or callback, you always need to forward it
public MyTimer() // Use SetTimer first to set a repeating timer of 1 second that calls this function
{
foreach(new i : Player) // Loops through all online players, and defines them as "i"
{
if(MyArray[i] == 1) // If MyArray is 1, give him his driver license back
// Once you gave him the drivers license back above, MyArray will be resetted to 0 underneath again
// The reason we're using 1, is because otherwise it would keep giving him his drivers license again if we checked for 0
if(MyArray[i] > 0) MyArray[i] --;
// If MyArray's value is higher than 0, it decreases it by 1 with --
}
}
Respuesta: Help whit this command please -
Guss - 11.03.2015
Thanks man, but I don't understand. there will be some simpler way? I appreciate your great help!