CMD:mycmd(playerid,params[])
new JailTimer[MAX_PLAYERS];// for the timer
new Jailed[MAX_PLAYERS];//for the players in jail
CMD:jail(playerid,params[]){// we opened a bracket here
if(IsPlayerAdmin(playerid)) {// we closed 2 brackets 1 for the player id and the other for the IsPlayerAdmin
new id,time,reason[100],PlayerName[MAX_PLAYER_NAME],GPlayerName[MAX_PLAYER_NAME];//id = the targetid, time = the jailing time, reason[100]= the reason string in this tutorial i think you know about strings,playername and Gplayername for the jailing names ill explain later
if(sscanf(params,"dds",id,time,reason)) return SendClientMessage(playerid, lb, "USAGE: /jail <playerid> <time> <reason>");// this is sscanf routine , d=integer and s= string
if (!IsPlayerConnected(id)) return SendClientMessage(playerid, red, "ERROR: Player is not connected.");// now we are checking if the targetid is online ! = not and id= targetid and if the id isnt on will send the message etc
if(Jailed[id] == 1) return SendClientMessage(playerid, red, "ERROR: Player is already jailed.");// 1 jailed 0 is not jailed
GetPlayerName(id, PlayerName, sizeof(PlayerName));// the jailed person id
GetPlayerName(playerid, GPlayerName, sizeof(GPlayerName));// the admin id
format(szString, sizeof(szString), "AdmSys-: %s (ID:%d) has been jailed for %d minutes; Reason: %s", PlayerName, id, time, reason);
SendClientMessageToAll(color, szString);//%s = name . %d = number
SetPlayerInterior(id, 3);//sets player interior
SetPlayerVirtualWorld(id, 10);//sets player vw
SetPlayerFacingAngle(id, 360.0);//player angle
SetPlayerPos(id, 197.5662, 175.4800, 1004.0);//player pos
SetPlayerHealth(id, 9999999999.0);//player cannot be killed
ResetPlayerWeapons(id);//resets his weapons
JailTimer[id] = SetTimerEx("Unjail",time*60000, false, "i", id);//jail timer
}
else {
return 0;//sends : Server:Unknown Command.
}
return 1;
}
CMD:unjail(playerid,params[]) {
new id;
if(IsPlayerAdmin(playerid)) {//checks if the player is admin
if(sscanf(params,"u",id)) return SendClientMessage(playerid, lb, "USAGE: /unjail <playerid>");//sscanf routine
if (!IsPlayerConnected(id)) return SendClientMessage(playerid, red, "ERROR: Player is not connected.");//checks if the targetid is connected
if(Jailed[id] == 0) return SendClientMessage(playerid, red, "ERROR: Player is not jailed.");//checks if the id is jailed and if he isnt it will send an error.
Jailed[id] = 0;// sets his jail to 0 = unjailed
SetPlayerInterior(id, 0);//normal int
SetPlayerVirtualWorld(id, 0);//normal vw
SpawnPlayer(id);//respawns player
SetPlayerHealth(id, 100);//sets his health back as 100
KillTimer(JailTimer[id]);//kills the timer
}
else {
return 0;// sends: Server:Unknown Command.
}
return 1;
}
if(IsPlayerAdmin(playerid)) == 2)
new isplayeradmin [MAX_PLAYERS] // you'll need this too
CMD:unjail(playerid,params[]) {
new id;
if(IsPlayerAdmin(playerid)) // some fixed :
if(sscanf(params,"d",id)) return SendClientMessage(playerid, lb, "USAGE: /unjail <playerid>");//sscanf routine
if (!IsPlayerConnected(id)) return SendClientMessage(playerid, red, "ERROR: Player is not connected.");//checks if the targetid is connected
if(Jailed[id] == 0) return SendClientMessage(playerid, red, "ERROR: Player is not jailed.");//checks if the id is jailed and if he isnt it will send an error.
Jailed[id] = 0);// you had missed ) here .
SetPlayerInterior(id, 0);//normal int
SetPlayerVirtualWorld(id, 0);//normal vw
SpawnPlayer(id);//respawns player
SetPlayerHealth(id, 100);//sets his health back as 100
KillTimer(JailTimer[id]);//kills the timer
}
else {
return 0;// sends: Server:Unknown Command.
}
return 1;
}
That's nice man. and only for rcon admins ? so how about this ?
pawn Код:
|
if(JailTimer[playerid] > -1)
KillTimer(JailTimer[playerid]);
JailTimer[playerid] = -1;
CMD:jail(playerid,params[])
{
if(!IsPlayerAdmin(playerid)) return 0;
new id,time,reason[100];
if(sscanf(params,"udS(No Reason)[100]",id,time,reason)) SendClientMessage(playerid, lb, "USAGE: /jail <playerid / Part of Name> <time> <reason>");// this is sscanf routine , d=integer and s= string
else if(id == INVALID_PLAYER_ID || !IsPlayerConnected(id)) SendClientMessage(playerid, red, "ERROR: Player is not connected.");// now we are checking if the targetid is online ! = not and id= targetid and if the id isnt on will send the message etc
else if(JailTimer[id] > -1) SendClientMessage(playerid, red, "ERROR: Player is already jailed.");// 1 jailed 0 is not jailed
else{
new szPlayerName[MAX_PLAYER_NAME + 1];
GetPlayerName(id, szPlayerName, MAX_PLAYER_NAME);// the jailed person id
SetPlayerInterior(id, 3);//sets player interior
SetPlayerVirtualWorld(id, 10);//sets player vw
SetPlayerPos(id, 197.5662, 175.4800, 1004.0);//player pos
SetPlayerFacingAngle(id, 360.0);//player angle
SetPlayerHealth(id, 9999999999.0);//player cannot be killed
ResetPlayerWeapons(id);//resets his weapons
JailTimer[id] = SetTimerEx("Unjail", time*60000, false, "i", id);//jail timer
format(szString, sizeof(szString), "AdmSys-: %s (ID:%d) has been jailed for %d minutes. Reason: %s", PlayerName, id, time, reason);
SendClientMessageToAll(color, szString);//%s = name . %d = number
}
return 1;
}
CMD:unjail(playerid,params[])
{
if(!IsPlayerAdmin(playerid)) return 0;
new id;
if(sscanf(params,"u",id)) SendClientMessage(playerid, lb, "USAGE: /unjail <playerid / Part of Name>"); //sscanf routine
else if(id == INVALID_PLAYER_ID || !IsPlayerConnected(id)) SendClientMessage(playerid, red, "ERROR: Player is not connected."); //checks if the targetid is connected
else if(JailTimer[id] < 0) SendClientMessage(playerid, red, "ERROR: Player is not jailed."); //checks if the id is jailed and if he isnt it will send an error.
else{
KillTimer(JailTimer[id]);//kills the timer
JailTimer[id] = -1;
SetPlayerInterior(id, 0);//normal int
SetPlayerVirtualWorld(id, 0);//normal vw
SetPlayerHealth(id, 100);//sets his health back as 100
SpawnPlayer(id);//respawns player
}
return 1;
}
D:\Desktop\jdfreeroam\gamemodes\jdfreeroam.pwn(2834) : error 017: undefined symbol "szString" D:\Desktop\jdfreeroam\gamemodes\jdfreeroam.pwn(2834) : error 017: undefined symbol "szString" D:\Desktop\jdfreeroam\gamemodes\jdfreeroam.pwn(2834) : error 029: invalid expression, assumed zero
format(szString, sizeof(szString), "AdmSys-: %s (ID:%d) has been jailed for %d minutes; Reason: %s", PlayerName, id, time, reason);
Code:
D:\Desktop\jdfreeroam\gamemodes\jdfreeroam.pwn(2834) : error 017: undefined symbol "szString" D:\Desktop\jdfreeroam\gamemodes\jdfreeroam.pwn(2834) : error 017: undefined symbol "szString" D:\Desktop\jdfreeroam\gamemodes\jdfreeroam.pwn(2834) : error 029: invalid expression, assumed zero Code:
format(szString, sizeof(szString), "AdmSys-: %s (ID:%d) has been jailed for %d minutes; Reason: %s", PlayerName, id, time, reason); |