Jail Timer [Help]
#1

Hey there,

Basically I am looking for a bit of help with a timer.

When somebody with a wanted star walks into my checkpoint it sends them to a cell.

I only want them to be in that cell for 60 seconds and then it releases them and sends them to a different position.

I'll show you what I have so far, and if anybody can complete it that'll be awesome.

Код:
public OnPlayerEnterCheckpoint(playerid)
{
    if(GetPlayerWantedLevel(playerid) >= 1)
    {
        SetTimer("prisoncell", 10000, true);
        SetPlayerWantedLevel(playerid, 0);
        SetPlayerInterior(playerid, 6);
        SetPlayerPos(playerid,263.9106,77.6354,1001.0391);
    }
So how will I make that timer end, and then when it does end change there position ?

cheers team.
Reply
#2

Ok, firstly - SetTimer is not meant for each player - SetTimerEx is.

Add this at the top of your script: new PrisonT[MAX_PLAYERS];

Update OnPlayerEnterCheckPoint(playerid) to this:

pawn Код:
public OnPlayerEnterCheckpoint(playerid)
{
    if(GetPlayerWantedLevel(playerid) >= 1)
    {
        PrisonT[playerid] = SetTimerEx("prisoncell", 10000, false,"i",playerid);
        SetPlayerWantedLevel(playerid, 0);
        SetPlayerInterior(playerid, 6);
        SetPlayerPos(playerid,263.9106,77.6354,1001.0391);
    }
}
Then you should create another function:

pawn Код:
forward prisoncell(playerid); // if you didnt already

public prisoncell(playerid)
{
    SetPlayerInterior(playerid,0);
    SetPlayerPos(playerid,Float:x,Float:y,Float:z); // update to the location
    KillTimer(PrisonT[playerid]);
    return 1;
}
Update Float,Float:y,Float:z to the position you want them to be placed at.

You left the timer as true, making it constantly put that player in the cell.
Reply
#3

Quote:
Originally Posted by LukeTheMajor
Посмотреть сообщение
Hey there,

Basically I am looking for a bit of help with a timer.

When somebody with a wanted star walks into my checkpoint it sends them to a cell.

I only want them to be in that cell for 60 seconds and then it releases them and sends them to a different position.

I'll show you what I have so far, and if anybody can complete it that'll be awesome.

Код:
public OnPlayerEnterCheckpoint(playerid)
{
    if(GetPlayerWantedLevel(playerid) >= 1)
    {
        SetTimer("prisoncell", 10000, true);
        SetPlayerWantedLevel(playerid, 0);
        SetPlayerInterior(playerid, 6);
        SetPlayerPos(playerid,263.9106,77.6354,1001.0391);
    }
So how will I make that timer end, and then when it does end change there position ?

cheers team.
Код:
public OnPlayerEnterCheckpoint(playerid)
{
    if(GetPlayerWantedLevel(playerid) >= 1)
    {
        SetTimerEx("prisoncell", 60000, false,"i",playerid);//we need SetTimerEx
        SetPlayerWantedLevel(playerid, 0);
        SetPlayerInterior(playerid, 6);
        SetPlayerPos(playerid,263.9106,77.6354,1001.0391);
    }
Here timer is now of 60 sec which do not repeat itself.

pawn Код:
forward prisoncell(playerid);
public prisoncell(playerid)
{
    //SetPlayerPos and all that stuff.
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)