29.09.2012, 14:14
(
Последний раз редактировалось xMCx; 30.09.2012 в 17:51.
)
Beginning
This tutorial as the title says about making " jail and unjail" commands for admins, its quite simple but useful
Requirements:
1-
sscanf here
zcmd here
2-
general knowledge of these two.
Lets start
use zcmd command style,
or [pawn]COMMAND:mycmd(playerid,params[])[/pawno]
so now:
on the top of the script add:
after that we need to check if the player is an admin, because this command is only for admins so, here we go:
now we need to define new things as the id the time and the reason,:
now lets start in the deep!
we need to check if the player already jailed or not so we do:
now we need to send a message to all players saying that admin[name] has jailed[name]!
now we need to set the player pos in the jail and take his gun!
now we finished the jail command lets start with the unjail.ill explain it in a fast way
and we are done , i hope i explained it in a good way ive learned this recently so i wanted to share it, dont be tough with comments , hope i helped you!
This tutorial as the title says about making " jail and unjail" commands for admins, its quite simple but useful
Requirements:
1-
sscanf here
zcmd here
2-
general knowledge of these two.
Lets start
use zcmd command style,
pawn Код:
CMD:mycmd(playerid,params[])
so now:
on the top of the script add:
pawn Код:
new JailTimer[MAX_PLAYERS];// for the timer
new Jailed[MAX_PLAYERS];//for the players in jail
pawn Код:
CMD:jail(playerid,params[]){// we opened a bracket here
pawn Код:
if(IsPlayerAdmin(playerid)) {// we closed 2 brackets 1 for the player id and the other for the IsPlayerAdmin
pawn Код:
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
pawn Код:
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
pawn Код:
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
pawn Код:
if(Jailed[id] == 1) return SendClientMessage(playerid, red, "ERROR: Player is already jailed.");// 1 jailed 0 is not jailed
pawn Код:
GetPlayerName(id, PlayerName, sizeof(PlayerName));// the jailed person id
GetPlayerName(playerid, GPlayerName, sizeof(GPlayerName));// the admin id
pawn Код:
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
pawn Код:
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;
}
pawn Код:
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;
}