if(strcmp(cmd, "/jail", true) == 0)
{
//new tmp[256];
// new time;
if(PlayerInfo[playerid][playerteam]==COPS || PlayerInfo[playerid][playerteam]==SASF || PlayerInfo[playerid][playerteam]==FBI)
{
//new tmp[256];
new tmp[256];
new hour,minute,second;
new day,month,year;
gettime(hour,minute,second);
getdate(year,month,day);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientUsage(playerid, cmd, "[Name/ID] [Time] [reason]");
return 1;
}
if(!IsNumeric(tmp) && (PlayerID(tmp)==-2 || PlayerID(tmp)==-1))
{
SendClientError(playerid, "Not found. Invalid part of name or more than one result");
return 1;
}
if(!IsNumeric(tmp) && PlayerID(tmp)>=0) giveplayerid = PlayerID(tmp);
if(IsNumeric(tmp)) giveplayerid = strval(tmp);
if(!IsPlayerConnected(giveplayerid))
{
SendClientError(playerid, "Not found or not online");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientUsage(playerid, cmd, "[Name/ID] [Time] [reason]");
return 1;
}
new time;
time = strval(tmp);
if(time > 25)
{
SendClientWarning(playerid, "Max time 25 minutes");
return 1;
}
if(PlayerInfo[giveplayerid][bail]==777)
{
SendClientWarning(playerid, "Nice try!!");
return 1;
}
tmp=strrest(cmdtext,idx);
if(!strlen(tmp))
{
SendClientUsage(playerid, cmd, "[Name/ID] [Time] [reason]");
return 1;
}
if((IsPlayerInSphere(playerid,193.41,175.51,1003.02,6) && IsPlayerInSphere(giveplayerid,193.41,175.51,1003.02,6)) || (IsPlayerInSphere(playerid,2292.64,2451.54,10.56,6) && IsPlayerInSphere(giveplayerid,2292.64,2451.54,10.56,6)) || (IsPlayerInSphere(playerid,2268.3320,2448.9216,3.5313,6) && IsPlayerInSphere(giveplayerid,2268.3320,2448.9216,3.5313,6)))
{
Jail2(giveplayerid,time*60,time*120);
new message[MAX_STRING];// Default bail %d$ ,time*120
new msg[MAX_STRING];
if(PlayerInfo[playerid][playerteam]==COPS)
{
ircecho("arrest cop %d %s %d %s %d %d",playerid,PlayerName(playerid),giveplayerid,PlayerName(giveplayerid),time,time*120);
format(message,sizeof(message),"* %s %s arrested suspect %s for %d minutes. Reason %s *",PlayerInfo[playerid][RankName],PlayerName(playerid),PlayerName(giveplayerid),time,tmp);
format(msg,sizeof(msg),"{778899}[%d:%d:%d || %d/%d/%d] %s has been jailed by %s %s for %d years for %s",hour,minute,second,day,month,year,PlayerName(giveplayerid),PlayerInfo[playerid][RankName],PlayerName(playerid),time,tmp);
dUserSet(PlayerName(giveplayerid)).("mdc1",msg);
myStrcpy(PlayerInfo[giveplayerid][mdc1],msg);
}
if(PlayerInfo[playerid][playerteam]==SASF)
{
ircecho("arrest sasf %d %s %d %s %d %d",playerid,PlayerName(playerid),giveplayerid,PlayerName(giveplayerid),time,time*120);
format(message,sizeof(message),"* %s %s arrested suspect %s for %d minutes. Reason %s *",PlayerInfo[playerid][RankName],PlayerName(playerid),PlayerName(giveplayerid),time,tmp);
format(msg,sizeof(msg),"{778899}[%d:%d:%d || %d/%d/%d] %s has been jailed by %s %s for %d years for %s",hour,minute,second,day,month,year,PlayerName(giveplayerid),PlayerInfo[playerid][RankName],PlayerName(playerid),time,tmp);
dUserSet(PlayerName(giveplayerid)).("mdc1",msg);
myStrcpy(PlayerInfo[giveplayerid][mdc1],msg);
}
if(PlayerInfo[playerid][playerteam]==FBI)
{
ircecho("arrest fbi %d %s %d %s %d %d",playerid,PlayerName(playerid),giveplayerid,PlayerName(giveplayerid),time,time*120);
format(message,sizeof(message),"Stranger arrested suspect %s for %d minutes. Reason %s *",PlayerName(giveplayerid),time,tmp);
format(msg,sizeof(msg),"{778899}[%d:%d:%d || %d/%d/%d] %s has been jailed by %s %s for %d years for %s",hour,minute,second,day,month,year,PlayerName(giveplayerid),PlayerInfo[playerid][RankName],PlayerName(playerid),time,tmp);
dUserSet(PlayerName(giveplayerid)).("mdc1",msg);
myStrcpy(PlayerInfo[giveplayerid][mdc1],msg);
}
SendClientMessageToAll(COLOR_RED,message);
return 1;
}
else if((IsPlayerInSphere(playerid,-2446.1494,522.7754,30.1753,6) && IsPlayerInSphere(giveplayerid,-2446.1494,522.7754,30.1753,6)) || (IsPlayerInSphere(playerid,267.7177,77.7217,1001.0391,6) && IsPlayerInSphere(giveplayerid,267.7177,77.7217,1001.0391,6)))
{
Jail2(giveplayerid,time*60,time*120);
new message[MAX_STRING];
new msg[MAX_STRING];
if(PlayerInfo[playerid][playerteam]==COPS)
{
ircecho("arrest cop %d %s %d %s %d %d",playerid,PlayerName(playerid),giveplayerid,PlayerName(giveplayerid),time,time*120);
format(message,sizeof(message),"* %s %s arrested suspect %s for %d minutes. Reason %s *",PlayerInfo[playerid][RankName],PlayerName(playerid),PlayerName(giveplayerid),time,tmp);
format(msg,sizeof(msg),"{778899}[%d:%d:%d || %d/%d/%d] %s has been jailed by %s %s for %d years for %s",hour,minute,second,day,month,year,PlayerName(giveplayerid),PlayerInfo[playerid][RankName],PlayerName(playerid),time,tmp);
dUserSet(PlayerName(giveplayerid)).("mdc1",msg);
myStrcpy(PlayerInfo[giveplayerid][mdc1],msg);
}
if(PlayerInfo[playerid][playerteam]==SASF)
{
ircecho("arrest SASF %d %s %d %s %d %d",playerid,PlayerName(playerid),giveplayerid,PlayerName(giveplayerid),time,time*120);
format(message,sizeof(message),"* %s %s arrested suspect %s for %d minutes. Reason %s *",PlayerInfo[playerid][RankName],PlayerName(playerid),PlayerName(giveplayerid),time,tmp);
format(msg,sizeof(msg),"{778899}[%d:%d:%d || %d/%d/%d] %s has been jailed by %s %s for %d years for %s",hour,minute,second,day,month,year,PlayerName(giveplayerid),PlayerInfo[playerid][RankName],PlayerName(playerid),time,tmp);
dUserSet(PlayerName(giveplayerid)).("mdc1",msg);
myStrcpy(PlayerInfo[giveplayerid][mdc1],msg);
}
if(PlayerInfo[playerid][playerteam]==FBI)
{
ircecho("arrest fbi %d %s %d %s %d %d",playerid,PlayerName(playerid),giveplayerid,PlayerName(giveplayerid),time,time*120);
format(message,sizeof(message),"Stranger arrested suspect %s for %d minutes. Reason %s *",PlayerName(giveplayerid),time,tmp);
format(msg,sizeof(msg),"{778899}[%d:%d:%d || %d/%d/%d] %s has been jailed by %s %s for %d years for %s",hour,minute,second,day,month,year,PlayerName(giveplayerid),PlayerInfo[playerid][RankName],PlayerName(playerid),time,tmp);
dUserSet(PlayerName(giveplayerid)).("mdc1",msg);
myStrcpy(PlayerInfo[giveplayerid][mdc1],msg);
}
SendClientMessageToAll(COLOR_RED,message);
return 1;
}
else SendClientWarning(playerid, "You and he must be near to jail");
return 1;
}
return 1;
}
if(strcmp(cmd, "/ajail", true) == 0)
{
if(PlayerInfo[playerid][power]>0)
{
new tmp[256];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientUsage(playerid, cmd, "[Name/ID] [Time] [reason]");
return 1;
}
if(!IsNumeric(tmp) && (PlayerID(tmp)==-2 || PlayerID(tmp)==-1))
{
SendClientError(playerid, "Not found. Invalid part of name or more than one result");
return 1;
}
if(!IsNumeric(tmp) && PlayerID(tmp)>=0) giveplayerid = PlayerID(tmp);
if(IsNumeric(tmp)) giveplayerid = strval(tmp);
if(!IsPlayerConnected(giveplayerid))
{
SendClientError(playerid, "Not found or not online");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientUsage(playerid, cmd, "[Name/ID] [Time] [reason]");
return 1;
}
new time;
time = strval(tmp);
if(time > 400)
{
SendClientWarning(playerid, "Max time 400 minutes/6 hours");
return 1;
}
tmp=strrest(cmdtext,idx);
if(!strlen(tmp))
{
SendClientUsage(playerid, cmd, "[Name/ID] [Time] [reason]");
return 1;
}
Jail(giveplayerid,time*60,777);
new message[MAX_STRING];
format(message,sizeof(message),"{FF0000}[Admin]{FF6347} %s jailed %s for %d minutes for: %s",PlayerName(playerid),PlayerName(giveplayerid),time,tmp);
if(PlayerInfo[playerid][power]!=53) SendClientMessageToAll(COLOR_RED,message);
AppendTo(ajaillog,message);
if(PlayerInfo[playerid][power]!=53) ircecho("unformatted %s",message);
format(message,sizeof(message),"{FF0000}[Admin]{FF6347} Anon jailed %s for %d minutes for: %s",PlayerName(giveplayerid),time,tmp);
if(PlayerInfo[playerid][power] >= 53) SendClientMessageToAll(COLOR_RED,message);
AppendTo(ajaillog,message);
myStrcpy(PlayerInfo[giveplayerid][jailedby],PlayerName(playerid));
myStrcpy(PlayerInfo[giveplayerid][jailedbyreason],tmp);
dUserSet(PlayerName(giveplayerid)).("jailedby",PlayerName(playerid));
dUserSet(PlayerName(giveplayerid)).("jailedbyreason",tmp);
return 1;
}
return 1;
}
stock Jail(playerid,time,bailcost){
cuffed[playerid]=0; tazed[playerid]=0;
SetPlayerPos(playerid,2541.0,-3762.0,25.0);
FreezePlayer(playerid);
PlayerInfo[playerid][jail]=1;
SetPlayerInterior(playerid,0);
SetPlayerWantedLevel(playerid,0);
PlayerInfo[playerid][jailtime]=time;
PlayerInfo[playerid][bail]=bailcost;
GivePlayerMoneyEx(playerid,-PlayerInfo[playerid][bail]);
//PlayerTemp[playerid][oldmoney]=PlayerInfo[playerid][bank]+GetPlayerMoney(playerid);
dUserSetINT(PlayerName(playerid)).("jailtime",PlayerInfo[playerid][jailtime]);
dUserSetINT(PlayerName(playerid)).("jail",PlayerInfo[playerid][jail]);
dUserSetINT(PlayerName(playerid)).("bail",PlayerInfo[playerid][bail]);
ResetPlayerWeapons(playerid);
new jailmsg[MAX_STRING];
format(jailmsg,MAX_STRING,"[JAIL] Jailed for %d seconds, if you kill someone in jail, BAN",time);
SendClientMessage(playerid,COLOR_RED,jailmsg);
return 1;
}
stock Jail2(playerid,time,bailcost){
cuffed[playerid]=0; tazed[playerid]=0;
SetPlayerInterior(playerid,3);
SetPlayerVirtualWorld(playerid,20);
SetPlayerPos(playerid,193.41,175.51,1002.82);
PlayerInfo[playerid][jail]=2;
SetPlayerWantedLevel(playerid,0);
PlayerInfo[playerid][jailtime]=time;
PlayerInfo[playerid][bail]=bailcost;
TogglePlayerControllableEx(playerid,true);
GivePlayerMoneyEx(playerid,-PlayerInfo[playerid][bail]);
//PlayerTemp[playerid][oldmoney]=PlayerInfo[playerid][bank]+GetPlayerMoney(playerid);
dUserSetINT(PlayerName(playerid)).("jailtime",PlayerInfo[playerid][jailtime]);
dUserSetINT(PlayerName(playerid)).("jail",PlayerInfo[playerid][jail]);
dUserSetINT(PlayerName(playerid)).("bail",PlayerInfo[playerid][bail]);
ResetPlayerWeapons(playerid);
new jailmsg[MAX_STRING];
format(jailmsg,MAX_STRING,"[JAIL] Jailed for %d seconds, if you kill someone in jail, BAN",time);
SendClientMessage(playerid,COLOR_RED,jailmsg);
return 1;
}
stock Jail3(playerid,time,bailcost){
cuffed[playerid]=0; tazed[playerid]=0;
//SetPlayerInterior(playerid,3);
//SetPlayerVirtualWorld(playerid,20);
SetPlayerPos(playerid,271.1057,1816.1927,1.0078);
PlayerInfo[playerid][jail]=3;
SetPlayerWantedLevel(playerid,0);
PlayerInfo[playerid][jailtime]=time;
PlayerInfo[playerid][bail]=bailcost;
// TogglePlayerControllableEx(playerid,false);
GivePlayerMoneyEx(playerid,-PlayerInfo[playerid][bail]);
//PlayerTemp[playerid][oldmoney]=PlayerInfo[playerid][bank]+GetPlayerMoney(playerid);
dUserSetINT(PlayerName(playerid)).("jailtime",PlayerInfo[playerid][jailtime]);
dUserSetINT(PlayerName(playerid)).("jail",PlayerInfo[playerid][jail]);
dUserSetINT(PlayerName(playerid)).("bail",PlayerInfo[playerid][bail]);
// SetPlayerWorldBounds(playerid, 337.5694,101.5826,1940.9759,1798.7453);
ResetPlayerWeapons(playerid);
new jailmsg[MAX_STRING];
format(jailmsg,MAX_STRING,"[JAIL] Jailed for %d seconds, if you kill someone in jail, BAN",time);
SendClientMessage(playerid,COLOR_RED,jailmsg);
return 1;
}
I made ajail and jail system, everything works fine but if I jail some one and he relogs, server is crashing.
It will crash anytime the jailed player is attempting to log in. pawn Code:
pawn Code:
|
if(PlayerInfo[playerid][playerteam] == COPS || PlayerInfo[playerid][playerteam] == SASF || PlayerInfo[playerid][playerteam] == FBI)