14.12.2012, 09:24
Hey
I am creating a jail command now, and i need some help.
I have created the command, and everything and it work just fine. But...
When i quit the game in jail, and return back i go back in to the jail.
That's fine as well, but i stay in jail forever. The save/spawn is bad, and i tried for like 4 hours to fix it...
OnPlayerSpawn
OnPlayerDisconnect
Command, and the forward
Thanks!
I am creating a jail command now, and i need some help.
I have created the command, and everything and it work just fine. But...
When i quit the game in jail, and return back i go back in to the jail.
That's fine as well, but i stay in jail forever. The save/spawn is bad, and i tried for like 4 hours to fix it...
OnPlayerSpawn
pawn Код:
IfJail[playerid] = dini_Int(file, "Jail");
}
if(IfJail[playerid] == 1)
{
new randomcell = random(sizeof(jailcell));
SetPlayerPos(playerid, jailcell[randomcell][0], jailcell[randomcell][1], jailcell[randomcell][2]);
SetPlayerInterior(playerid, 10);
SendClientMessage(playerid, COLOR_RED, "*-SFPD-* {FFFFFF}Still jailtime left{FF0000} *-SFPD-*");
SetTimerEx("UnJail",JailTime[playerid]*1000*60,false,"d",playerid);
}
pawn Код:
if(JailTime[playerid]!=0)
{
new file[128], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(file, sizeof(file), "\\save\\%s.ini", pname);
if(!dini_Exists(file))
dini_Create(file);
dini_IntSet(file, "JailTime", JailTime[playerid]);
}
pawn Код:
COMMAND:jailplayer(playerid, params[])
{
if(gTeam[playerid] == TEAM_PD)
{
new targetid;
new timer;
new reason[25];
if(sscanf(params, "uns",targetid, timer, reason)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /jailplayer [ID] [Min] [Reason]");
{
new str[512];
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
new target[MAX_PLAYER_NAME];
GetPlayerName(targetid, target, sizeof(target));
format(str,sizeof str,"You were jailed by: %s for: %i minute(s), reason: %s",name,timer,reason);
SendClientMessage(targetid,COLOR_RED,str);
format(str,sizeof str,"You jailed : %s for: %i minute(s), reason: %s",target,timer,reason);
SendClientMessage(playerid,COLOR_PDBLUE,str);
new randomcell = random(sizeof(jailcell));
SetPlayerPos(targetid, jailcell[randomcell][0], jailcell[randomcell][1], jailcell[randomcell][2]);
SetPlayerInterior(targetid, 10);
IfJail[targetid] = 1;
JailTime[targetid] = SetTimerEx("UnJail",timer*1000*60,false,"d",targetid);
return 1;
}
}
else SendClientMessage(playerid, COLOR_ERROR, "Your are not outside jail.");
return 1;
}
forward UnJail(targetid);
public UnJail(targetid)
{
JailTime[targetid]--;
if(JailTime[targetid] == 0)
{
KillTimer(JailTime[targetid]);
SetPlayerPos(targetid,217.8000,115.4000,999.0);
SendClientMessage(targetid, 0xFF0000AA, "You Have Ben Released From Jail!");
IfJail[targetid] = 0;
JailTime[targetid] = 0;
}
return 1;
}