jail command problem help rep++
#1

when is player jailed and when he disconnect he is not in jail??

Код:
CMD:jail(playerid, params[])
{
    if(pInfo[playerid][pLevel] >= 1)
    {
        new id, time = 0, reason[50];
        if(isnull(params)) return SendClientMessage(playerid, yellow, "Usage: /Jail <Player ID> <Minutes> <Reason>");
        sscanf(params, "uis[50]", id, time, reason);
        if(IsPlayerConnected(id) && id != playerid)
        {
            if(pInfo[id][Jailed] == 1) return SendClientMessage(playerid,red,"This player is already jailed. see /jailed");
            if(pInfo[playerid][pLevel] <= pInfo[id][pLevel]) return ShowMessage(playerid, red, 6);
            if(!isnull(reason) && time == 0)
		    format(Jstring,sizeof(Jstring),"Administrator %s has jailed player '%s' | Reason: %s",GetName(playerid),GetName(id),reason);
		    else if(!isnull(reason) && time >= 1) format(Jstring,sizeof(Jstring),"Administrator %s has jailed '%s' for %d minutes (reason: %s)",GetName(playerid),GetName(id), time, reason);
		    else if(isnull(reason) && time >= 1) format(Jstring,sizeof(Jstring),"Administrator %s has jailed '%s' for %d minutes",GetName(playerid),GetName(id), time);
		    else format(Jstring,sizeof(Jstring),"Administrator %s has jailed '%s'",GetName(playerid),GetName(id));
		    CommandToAdmins(playerid,"jail");
		    SendClientMessageToAll(red,Jstring);
		    pInfo[id][Jailed] = 1;
		    TogglePlayerControllable(id, false);
		    new Float:x, Float:y, Float:z;
			GetPlayerPos(id,x,y,z);
			SetPlayerCameraPos(id,x+7,y,z+5);
			SetPlayerCameraLookAt(id,x,y,z);
			JPlayer[id] = SetTimerEx("JailPlayer",3000,0,"d",id);
			if(GetPlayerState(id) == PLAYER_STATE_ONFOOT) SetPlayerSpecialAction(id,SPECIAL_ACTION_HANDSUP);
		    if(time >= 1)
			{
		    	Jtimer[id] = SetTimerEx("Unjail",time*1000*60,0,"u",id);
		    }
			return 1;
		}
		else return ShowMessage(playerid, red, 3);
    }
    else return ShowMessage(playerid, red, 1);
}
Reply
#2

You have to detect if he's in jail under OnPlayerSpawn, and if he is, set him back into jail.
Reply
#3

send code
Reply
#4

You have to make it yourself, if you want to request scripts, hire someone to do it for you here.
Reply
#5

help there : http://forum.sa-mp.com/showthread.ph...24#post3401524
Reply
#6

bump
Quote:
Originally Posted by oliverrud
Посмотреть сообщение
It would be more appropriate to make a thread in scripting help for this kinda question.

You need to save the players jailed time when they disconnect and load up that info when he connects again, then check onplayerspawn if he has any remaining time, if he does, put him in jail again.
Reply
#7

Quote:
Originally Posted by Mijata
Посмотреть сообщение
bump
I misunderstood your post in looking for scripters, thinking you were looking for advice. If you don't wanna actually do the code yourself. Then yeah you should stay in looking for scripters. Apologies.
Reply
#8

other cmd for jail.

Код:
CMD:jail(playerid,params[]) {
	if(PlayerInfo[playerid][LoggedIn] == 1) {
		if(PlayerInfo[playerid][Level] >= 1) {
		    new tmp[256], tmp2[256], tmp3[256], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index), tmp3 = strtok(params,Index);
		    if(isnull(params)) return SendClientMessage(playerid, red, "USAGE: /jail [playerid] [minutes] [reason]");
	    	new player1, playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], string[128];
			player1 = strval(tmp);

		 	if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && (PlayerInfo[player1][Level] != ServerInfo[MaxAdminLevel]) ) {
				if(PlayerInfo[player1][Jailed] == 0) {
					GetPlayerName(player1, playername, sizeof(playername)); GetPlayerName(playerid, adminname, sizeof(adminname));
					new jtime = strval(tmp2);
					if(jtime == 0) jtime = 9999;

			       	CMDMessageToAdmins(playerid,"JAIL");
					PlayerInfo[player1][JailTime] = jtime*1000*60;
    			    JailPlayer(player1);
    			    Jail1(player1);
		        	PlayerInfo[player1][Jailed] = 1;

					if(jtime == 9999) {
						if(!strlen(params[strlen(tmp2)+1])) format(string,sizeof(string),"Administrator %s has jailed %s ",adminname, playername);
						else format(string,sizeof(string),"Administrator %s has jailed %s [reason: %s]",adminname, playername, params[strlen(tmp)+1] );
   					} else {
						if(!strlen(tmp3)) format(string,sizeof(string),"Administrator %s has jailed %s for %d minutes",adminname, playername, jtime);
						else format(string,sizeof(string),"Administrator %s has jailed %s for %d minutes [reason: %s]",adminname, playername, jtime, params[strlen(tmp2)+strlen(tmp)+1] );
					}
	    			return SendClientMessageToAll(blue,string);
				} else return SendClientMessage(playerid, red, "Player is already in jail");
			} else return SendClientMessage(playerid, red, "Player is not connected or is the highest level admin");
		} else return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
	} else return SendClientMessage(playerid,red,"ERROR: You must be logged in to use this commands");
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)