Jail timer command problem.
#1

Hello
i have a problem that i made a arrest command so i added a code that will realese me from jail like if i jail someone
he has a timer but i have waited the time i have seted it in the gamemode but it dosent realse me
and if someone can also make me like a gametext timer for jail it will be awesome
here is my code:

pawn Код:
CMD:ar(playerid,params[])
{
    new targetid;
    new string[128];
    if(sscanf(params, "u", targetid))
    {
        SendClientMessage(playerid,COLOR_ERROR,"USAGE: /ar (Player Name/ID)");
        return 1;
    }
    if(gTeam[playerid] != Team_Cop)
    {
        SendClientMessage(playerid,COLOR_ERROR,"Only law enforcement can arrest wanted suspects.");
        return 1;
    }
    if(!IsPlayerConnected(targetid))
    {
        format(string,sizeof(string),"The player ID (%d) is not connected to the server. You cannot arrest them.",targetid);
        SendClientMessage(playerid,COLOR_ERROR,string);
        return 1;
    }
    if(GetDistanceBetweenPlayers(playerid,targetid) > 4)
    {
        format(string,sizeof(string),"%s(%d) is too far away. You cannot reach him to arrest him.",GetName(targetid),targetid);
        SendClientMessage(playerid,COLOR_ERROR,string);
        return 1;
    }
    if(GetPVarInt(targetid, "Cuffed") == 0)
    {
        format(string,sizeof(string),"%s(%d) is not cuffed. You have to place the suspect in cuffs before attempted to arrest them.",GetName(targetid),targetid);
        SendClientMessage(playerid,COLOR_ERROR,string);
        return 1;
    }
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER || GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
    {
        SendClientMessage(playerid,COLOR_ERROR,"You cannot arrest a suspect while in a vehicle. Exit the vehicle first.");
        return 1;
    }
    if(GetPlayerState(targetid) == PLAYER_STATE_DRIVER || GetPlayerState(targetid) == PLAYER_STATE_PASSENGER)
    {
        SendClientMessage(playerid,COLOR_ERROR,"You cannot arrest a suspect they are in a vehicle. Get them to exit the vehicle first.");
        return 1;
    }
    if(playerid == targetid)
    {
        SendClientMessage(playerid,COLOR_ERROR,"You cannot arrest yourself, why would you do that anyway?");
        return 1;
    }
    if(GetPlayerWantedLevel(targetid) < 3)
    {
        format(string,sizeof(string),"%s(%d)'s wanted level is too low. You cannot jail them. Use /ticket (Player ID).",GetName(targetid),targetid);
        SendClientMessage(playerid,COLOR_ERROR,string);
        return 1;
    }
    new pwl = GetPlayerWantedLevel(targetid);
    if(pwl == 4)
    {
        GivePlayerMoney(playerid, 3000);
        IncreaseScore(playerid, 1);
        IncreaseCoprank(playerid, 1);
        SetPVarInt(targetid, "JailTime", 45);
        SetPlayerInterior(targetid, 10);
        new rnd = random(sizeof(PrisonSpawn));
        SetPlayerPos(targetid, PrisonSpawn[rnd][0], PrisonSpawn[rnd][1], PrisonSpawn[rnd][2]);
        SendClientMessage(playerid, COLOR_GREY, "**LOS SANTOS PRISON**");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "[PRISON] You have been sent to prison. You will be released soon.");
        TogglePlayerControllable(targetid, 1);
        SetPlayerWantedLevel(targetid, 0);
        return 1;
    }
    return 1;
}
Reply
#2

Please Replay to this thread as quick as you can
i really want to do that succesfully
Reply
#3

https://sampforum.blast.hk/showthread.php?tid=381425

+

https://sampforum.blast.hk/showthread.php?tid=467486

my posts
Reply
#4

It didnt help me very much can you post like a code for this command
like what to add so he will be in a timer
Reply
#5

Put this OnPlayerUpdate public
Код:
for(new i = 0; i <= MAX_PLAYERS; i++)
{
if(JailTime[i] > 1)
{
	            //Timer
	            format(string,sizeof(string),"Total Jailtime: %d",JailTime[i]);
	            GameTextForPlayer(playerid,JailTime[i],5);
	            
	            JailTime[i] --;
}
			if(JailTime[i] == 1)
			{
			    format(string,sizeof(string),"[JAIL] {FFFFFF}%s(%d) has been released from jail. {00FF00}[Served his time]",pname,i);
			    SendClientMessageToAll(COLOR_YELLOW,string);

				TotalJailTime[i] =0;
				JailTime[i] =0;
				
				SetPlayerPos(i,225.8451,112.8976,1003.2188);
				SetPlayerFacingAngle(i,1.0816);
				SetCameraBehindPlayer(i);
				SetPlayerHealth(i,100);
				SetPlayerInterior(i,10);
				
			}
}
Hope it works for you
feel free to edit it
Reply
#6

This are the errors that i get
Код:
C:\Program Files (x86)\Microsoft Power\GTA San Andreas\TeamDeathMatch\gamemodes\CNR.pwn(1260) : error 017: undefined symbol "JailTime"
C:\Program Files (x86)\Microsoft Power\GTA San Andreas\TeamDeathMatch\gamemodes\CNR.pwn(1260) : warning 215: expression has no effect
C:\Program Files (x86)\Microsoft Power\GTA San Andreas\TeamDeathMatch\gamemodes\CNR.pwn(1260) : error 001: expected token: ";", but found "]"
C:\Program Files (x86)\Microsoft Power\GTA San Andreas\TeamDeathMatch\gamemodes\CNR.pwn(1260) : error 029: invalid expression, assumed zero
C:\Program Files (x86)\Microsoft Power\GTA San Andreas\TeamDeathMatch\gamemodes\CNR.pwn(1260) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#7

Please help me
Reply
#8

Can someone help me solve this
Reply
#9

In the command put:

pawn Код:
SetTimerEx("Release", 1000, false, "i", targetid); // Jail the target for 45 seconds

// Somewhere else
forward Release(playerid);
public Release(playerid)
{
    if(GetPVarInt(playerid, "JailTime") <= 0)
    {
        // He's released from jail, do something
        return 1;
    }
    else
    {
        new str[50];
        format(str, sizeof(str), "You will be released in: %d", GetPVarInt(playerid, "JailTime"));
        SendClientMessage(playerid, -1, str); // Change it if you want
    }

    SetPVarInt(playerid, "JailTime", GetPVarInt(playerid, "JailTime") - 1); // Decrease the player's jail time

    SetTimerEx("Release", 1000, false, "i", playerid);
    return 0;
}
Reply
#10

Quote:
Originally Posted by -Prodigy-
Посмотреть сообщение
In the command put:

pawn Код:
SetTimerEx("Release", 1000, false, "i", targetid); // Jail the target for 45 seconds

// Somewhere else
forward Release(playerid);
public Release(playerid)
{
    if(GetPVarInt(playerid, "JailTime") <= 0)
    {
        // He's released from jail, do something
        return 1;
    }
    else
    {
        new str[50];
        format(str, sizeof(str), "You will be released in: %d", GetPVarInt(playerid, "JailTime"));
        SendClientMessage(playerid, -1, str); // Change it if you want
    }

    SetPVarInt(playerid, "JailTime", GetPVarInt(playerid, "JailTime") - 1); // Decrease the player's jail time

    SetTimerEx("Release", 1000, false, "i", playerid);
    return 0;
}
Please tell me how to change the msg to a gametext
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)