[Help]How do i make a jail?
#1

So i am making a cops and robbers server and i have made an arrest cmd and when i arrest a player he goes in jail but there is no timer.So basically he is trapped in jail and also how can i make it so he can't use ex:/kill and kill him self in jail?
Reply
#2

Hi, Use a system like this:

PHP код:
forward SetPlayerUnjail(); 
at OnGameModeInit

PHP код:
SetTimer("SetPlayerUnjail"1000true); 
the public
PHP код:
public SetPlayerUnjail()
{
    foreach(
Player,i)
    {
         if(
PlayerInfo[i][pJail] > 0)
            {
                          if(
PlayerInfo[i][pJailTime] > 0)
                {
                    
PlayerInfo[i][pJailTime]--;
                    
Update(ipJailTimex);
                }
                if(
PlayerInfo[i][pJailTime] <= 1)
                {
                    
PlayerInfo[i][pJailTime] = 0;
                    
Update(ipJailTimex);
                    if(
PlayerInfo[i][pJail] == 1)
                    {
                        
SetPlayerInterior(i0);
                        
SetPlayerPos(i,x,y,z);
                    }
                    
PlayerInfo[i][pJail] = 0;
                    
Update(ipJailx);
                    
SendClientMessage(iCOLOR_GRAD1,"   Jail is over.");
                    
format(stringsizeof(string), "~g~You are ~w~FREE!");
                    
GameTextForPlayer(istring50003);
                }
            }
           
        }
       return 
1;

Reply
#3

show your jail command please we will be able to see some magics from there
Reply
#4

Код:
CMD:cuff(playerid,params[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
    	if(GetPlayerClass[playerid] == COP_CLASS)
		{
	    	if(GetPlayerWantedLevel(i) >= 3)
	    	{
	    	    if(GetDistanceBetweenPlayers(playerid,i) <= 2.5)
      			{
 			     	if(sscanf(params,"ud", i)) return SendClientMessage(playerid, -1,"USAGE: /cuff [player id]");
     				SetPlayerSpecialAction(i,24);
					SetPlayerAttachedObject(i, 0, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977, -81.700035, 0.891999, 1.000000, 1.168000);
					Cuffed[i] = 1;
				}
			}
		}
	}
	return 1;
}
CMD:arrest(playerid, params[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
	{
	    if(GetPlayerState(i) == PLAYER_STATE_DRIVER || GetPlayerState(i) == PLAYER_STATE_PASSENGER)
		{
			SendClientMessage(playerid,-1,"You cannot arrest a suspect they are in a vehicle. Get them to exit the vehicle first.");
			return 1;
		}
	    new string[128];
    	if(GetPlayerClass[playerid] == COP_CLASS)
    	{
        	if(GetPlayerWantedLevel(i) >= 3)
        	{
        	    if(Cuffed[i] = 0) return SendClientMessage(playerid, -1, "You Can't Cuff Innocents!");
        	    {
        	        if(sscanf(params,"ud", i)) return SendClientMessage(playerid, -1,"USAGE: /arrest [player id]");
            		GivePlayerMoney(playerid, 3000);
			  		SetPlayerScore(playerid, GetPlayerScore(playerid)+1);
			  		Jailed[i] = 1;
			  		JailTime[i] = 60;
			  		Cuffed[i] = 0;
			  		SetPlayerVirtualWorld(playerid, 10);
					SetPlayerFacingAngle(playerid, 360.0);
			  		SetPlayerInterior(i, 3);
			  		SetPlayerPos(i, 197.5662, 175.4800, 1004.0);
			  		SetPlayerWantedLevel(i, 0);
			  		SetPlayerHealth(i,99999);
			  		ResetPlayerWeapons(i);
			  		format(string,sizeof(string),"Police Officer %s(%d) Has arrested wanted suspect %s(%d).",GetNamee(playerid),playerid,GetNamee(i),i);
			  		SendClientMessageToAll(COLOR_ORANGE,string);
			  		return 1;
			  	}
			}
    	}
   }
	return 1;
}
Reply
#5

PHP код:

public SetPlayerUnjail() 

    foreach(
Player,i
    { 
         if(
Jailed[i] > 0
            { 
                if(
JailTime[i] > 0)                     JailTime[i]--; 
                if(
JailTime[i] <= 1
                { 
                    
JailTime[i] = 0
                    
Jailed[i] = 0;
                    
SetPlayerInterior(i0); 
                    
SetPlayerPos(i,x,y,z); 
                    
SendClientMessage(iCOLOR_GRAD1,"   Jail is over."); 
                    
format(stringsizeof(string), "~g~You are ~w~FREE!"); 
                    
GameTextForPlayer(istring50003); 
                } 
            } 
            
        } 
       return 
1

Reply
#6

How can i make it so the player can't use cmds ex:kill so he can't kill him self in jail?
Reply
#7

Код:
/kill
if (PlayerData[playerid][pJailed] == 1) {
scm(pid, color, You can't do that right now);
else
setplayerhealth(pid, 0);
return 1;
}
Reply
#8

error 021: symbol already defined: "SetTimer"
SetTimer("SetPlayerUnjail", 60000, true);
I have only 1 SetTimer

error 001: expected token: ";", but found "if"
line:if(Jailed[i] > 0)
Reply
#9

You put this on your command and you done

PHP код:
if(pJail[playerid] > 0)  return SendClientMessage(playerid,-1,"You are in jail, you can not use this command"); 
Dont' make forward setplayerunjail like my model, i write if you dont't haved

put this on your SetPlayerUnjail

PHP код:

  
for(new i;i<MAX_PLAYERS;i++) 
         if(
Jailed[i] > 0)  
            {  
                if(
JailTime[i] > 0)                     JailTime[i]--;  
                if(
JailTime[i] <= 1)  
                {  
                    
JailTime[i] = 0;  
                    
Jailed[i] = 0
                    
SetPlayerInterior(i0);  
                    
SetPlayerPos(i,x,y,z);  
                    
SendClientMessage(iCOLOR_GRAD1,"   Jail is over.");  
                    
format(stringsizeof(string), "~g~You are ~w~FREE!");  
                    
GameTextForPlayer(istring50003);  
                }  
            }  
             
        }  
       return 
1
YOUR TIMER NEED TO BE FOR 1000 MILISECONDS NOT 60000
Reply
#10

Does jail time need to be there or? (READ PAGE 2)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)