16.04.2012, 20:04
How to make:
/jail id time ?
After time it SpawnPlayer and /jail puts the player in a coord...
/jail id time ?
After time it SpawnPlayer and /jail puts the player in a coord...
//Top of script
forward PlayerJailed();
new PlayerIsJailed[MAX_PLAYERS];
//Under OnPlayerConnect
PlayerIsJailed[playerid] = 0;
CMD:jail(playerid, params[])
{
if(/*Playeradminvariable*/ == /*level of admin*/)
{
new targetid, time;
if(sscanf(params, "id", targetid, time)) return SendClientMessage(playerid, -1, "Usage: /jail <playerid> <time>");
if(IsPlayerConnected(targetid))
{
//Should add a variable here that sets the ammount of time *global variable* that checks when the player logs inm if they are jailed
SetPlayerPos(targetid, /*posx*/, /*posy*/, /*posz*/);
SetTimer("PlayerJailed", time /*inmiliseconds*/, false);
PlayerIsJailed[playerid] = 1;
}
}
else return SendClientMessage(playerid, -1, "You are not authorized to use this command!");
return 1;
}
//Somewhere else
public PlayerJailed()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(PlayerIsJailed[i] == 1)
{
SetPlayerPos(i, /*posx*/, /*posy*/, /*posz*/);
PlayerIsJailed[i] = 0;
}
}
}
CMD:jail(playerid, params[])
{
if(/*Playeradminvariable*/ == /*level of admin*/)
{
new targetid, time;
if(sscanf(params, "ud", targetid, time)) return SendClientMessage(playerid, -1, "Usage: /jail <playerid> <time>");
if(IsPlayerConnected(targetid))
{
//Should add a variable here that sets the ammount of time *global variable* that checks when the player logs inm if they are jailed
SetPlayerPos(targetid, /*posx*/, /*posy*/, /*posz*/);
SetTimer("PlayerJailed", time /*inmiliseconds*/, false);
PlayerIsJailed[playerid] = 1;
}
}
else return SendClientMessage(playerid, -1, "You are not authorized to use this command!");
return 1;
}
Do not make script request threads, this is like the most simplest things to make.
pawn Код:
Hint: Next time, actually try something before making a thread. PS: Some stuff may not be needed, for example, the if(PlayerIsJailed[i] == 1) as I do not see why this would be needed, but I added it anyways. EDIT: I see, wasn't paying much attention. Thanks below. |