help with arrest command
#1

Im making an /arrest command for cops, but i need to make something that a plyer get timed depends on his/her wanted level. Is it possible and if it is can someone show me an exaple of what i should make.
Reply
#2

hmm code?
Reply
#3

pawn Код:
CMD:arrest(playerid,params[])
{
    if(gTeam[playerid] == TEAM_POLICE)
    {
        new pId;
        if(sscanf(params, "dds", pId, time, params[3])) return SendClientMessage(playerid, red, "Usage: /arrest [ID] ");
            else if(!IsPlayerConnected(pId)) return SendClientMessage(playerid, 0xFF0000AA, "Invalid Id.");
                else
                {
                    new pname[MAX_PLAYER_NAME], jname[MAX_PLAYER_NAME];
                    GetPlayerName(playerid, pname, sizeof(pname));
                    GetPlayerName(pId, jname, sizeof(jname));
                    SetPlayerInterior(pId, 3);
                    new rand = random(sizeof(JailCellSpawns));
                    SetPlayerPos(pId, JailCellSpawns[rand][0], JailCellSpawns[rand][1], JailCellSpawns[rand][2]);
                    SetPlayerWantedLevel(pId, 0);
                    format(string1, sizeof(string1), "%s(%d) Has Been Jailed By Officer %s(%d) ", jname, pId, pname, playerid);
                    SendClientMessageToAll(0xFF0000AA, string1);
                    GameTextForPlayer(playerid, "~r~JAILED ", 3000, 3);

                    return 1;
                }
            }
            else SendClientMessage(playerid,COLOR_RED,"You are not authorized for use this command!");
    {
                return 0;
            }
Reply
#4

pawn Код:
new time=wantedlevel*60;
or something of the sort.

Basically their wanted level is timed by 60, - which can then become the amount of seconds they serve. For example, - for having one star they will serve 60 seconds. Then store the amount of time in a variable somewhere and do something like this to check if they're time has passed,
(Run the timer somewhere, or use something such as y_timers). Make sure it repeats if they're in jail.

PlayerTimer[playerid] = SetTimerEx("Update", 1000, true, "i", playerid);

public Update(playerid)
{
JailTime[playerid] = JailTime[playerid]-1;
if(JailTime[playerid]==0)
{
KillTimer(PlayerTimer[playerid]);
PlayerTimer[playerid] = 0;
// release them
}
}[/pawn]

This method is unsufficent and I'd recommend using Unix Timestamps, how-ever this should help you.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)