Please Help With Jail Command Please -
Scripter12345 - 03.04.2012
Hello i have made a /jail command but there is a problem with it, when i jail someone i glitches my whole world out so i cant see no objects, it also says im jailed but im not
Please Help
Код:
stock PlayerName(playerid)
{
new pName[25];
GetPlayerName(playerid, pName, sizeof(pName));
return pName;
}
Код:
new JailTimer[MAX_PLAYERS],
bool:inJail[MAX_PLAYERS];
Код:
CMD:jail(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 4)
{
new targetid, minutes; //define the player's name and the minutes of jailing
if(sscanf(params, "ri", targetid, minutes)) return SendClientMessage(playerid, COLOR_RED,"Usage: /jail <playerid> <minutes>"); //detects the wrong params and show the usage
if(minutes <= 0 || minutes > 60) return SendClientMessage(playerid, COLOR_RED, "Minutes can't be less than 0 or more than 60!"); //we won't let a player suffer more than 1 hour, and not less than 1 minute
if(targetid == playerid) return SendClientMessage(playerid, COLOR_RED, "You can't jail yourself!"); //comment this line out, if you wanna test this command on yourself!
if(PlayerInfo[targetid][pAdmin] > PlayerInfo[playerid][pAdmin]) return SendClientMessage(playerid, COLOR_RED, "You can't jail higher level admins!"); //the performer can't jail higher admins!
else
{
new str[128]; //create a new string
format(str, sizeof(str), "Administrator %s has jailed %s for %d minutes!", Name(playerid), Name(targetid), minutes); //get the admin's name, the player's and show the minutes
SendClientMessageToAll(COLOR_LIGHTBLUE,str); //let everybody know what you did, this will send the message to everyone
JailTimer[targetid] = SetTimer("Unjail", minutes*60*1000, false); //now HERE we're setting the jailtimer from the variable created, it will calculate the milliseconds to seconds, multiplicated with the amount of minutes we gave
SetPlayerPos(targetid, 264.4176, 77.8930, 1001.0391); //Sets the player's position to the jail in LS
SetPlayerInterior(playerid, 6); //this will set the player's interior to an jail-interior
inJail[targetid] = true; //now, here we'll check, if the player's in jail, we'll set the value to "true", means that he IS in jail
GameTextForPlayer(playerid, "~p~JAILED", 10000, 6); //this is for decorating and writing a big "JAILED" for the player
PlayerPlaySound(targetid,1057,0.0,0.0,0.0); //that's also a small sound, for decoration
}
}
else return SendClientMessage(playerid, COLOR_RED, "You have to be level 4 to use this command!"); //if he isn't allowed to use this command, send him this message
return 1;
}
Код:
forward Unjail(playerid);
public Unjail(playerid) //this was the name of the timer (Unjail), if you remember
{
SpawnPlayer(playerid); //spawn the player normally again
SetPlayerInterior(playerid, 0); //we'll set the interior to "0", which means to the normal world
inJail[playerid] = false; //we'll set the value of the variable to "false" here, that means he isn't in jail anymore
KillTimer(JailTimer[playerid]); //execute the timer, so it'll stop counting
GameTextForPlayer(playerid, "~g~Unjailed", 5000, 6); //this is for decoration again, will display "UNJAILED"
PlayerPlaySound(playerid,1057,0.0,0.0,0.0); //a smart "success-sound" again
}
Please Help Please
Re: Please Help With Jail Command Please -
Cjgogo - 03.04.2012
In your code I see SetPlayerInterior(playerid,6) instead of SetPlayerInterior(targetid,6) and GameTextForPlayer(playerid,~g~JAILED) instead of GameTextForPlayer(targetid,~g~JAILED)
Re: Please Help With Jail Command Please -
Cjgogo - 03.04.2012
pawn Код:
CMD:jail(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 4)
{
new targetid, minutes; //define the player's name and the minutes of jailing
if(sscanf(params, "ri", targetid, minutes)) return SendClientMessage(playerid, COLOR_RED,"Usage: /jail <playerid> <minutes>"); //detects the wrong params and show the usage
if(minutes <= 0 || minutes > 60) return SendClientMessage(playerid, COLOR_RED, "Minutes can't be less than 0 or more than 60!"); //we won't let a player suffer more than 1 hour, and not less than 1 minute
if(targetid == playerid) return SendClientMessage(playerid, COLOR_RED, "You can't jail yourself!"); //comment this line out, if you wanna test this command on yourself!
if(PlayerInfo[targetid][pAdmin] > PlayerInfo[playerid][pAdmin]) return SendClientMessage(playerid, COLOR_RED, "You can't jail higher level admins!"); //the performer can't jail higher admins!
else
{
new str[128]; //create a new string
format(str, sizeof(str), "Administrator %s has jailed %s for %d minutes!", Name(playerid), Name(targetid), minutes); //get the admin's name, the player's and show the minutes
SendClientMessageToAll(COLOR_LIGHTBLUE,str); //let everybody know what you did, this will send the message to everyone
JailTimer[targetid] = SetTimer("Unjail", minutes*60*1000, false); //now HERE we're setting the jailtimer from the variable created, it will calculate the milliseconds to seconds, multiplicated with the amount of minutes we gave
SetPlayerPos(targetid, 264.4176, 77.8930, 1001.0391); //Sets the player's position to the jail in LS
SetPlayerInterior(targetid, 6); //this will set the player's interior to an jail-interior
inJail[targetid] = true; //now, here we'll check, if the player's in jail, we'll set the value to "true", means that he IS in jail
GameTextForPlayer(targetid, "~p~JAILED", 10000, 6); //this is for decorating and writing a big "JAILED" for the player
PlayerPlaySound(targetid,1057,0.0,0.0,0.0); //that's also a small sound, for decoration
}
}
else return SendClientMessage(playerid, COLOR_RED, "You have to be level 4 to use this command!"); //if he isn't allowed to use this command, send him this message
return 1;
}
There try it,AND please when you paste a cod use [pawn] tag