Casino robbery help
#1

I made a casino robbery, it consists of 3 checkpoints... 1 Entrance to caligulas, 1 exit out of caligulas, and 1 robbery checkpoint inside underground.

Here is my code:

pawn Код:
// top of script

new caligentercp; //this is the entrance cp
new caligrobcp; // this is the cp underground
new caligexitcp; //  this is the exit cp to back onto the strip
new CasRobberID; // this is the casino robber/player
new caligtimer; // this is the timer

// ongamemodeinit

caligtimer = SetTimer("CasRob",1000,1);

// onplayerenterdynamiccp

if(checkpointid == caligentercp)
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
            return 0;
        }
        SetPlayerInterior(playerid,1);
        SetPlayerVirtualWorld(playerid,1);
        SetPlayerPos(playerid,2234.0896,1706.2617,1009.9155,180.3854);
        SendClientMessage(playerid,COLOR_LIGHTBLUE,"Welcome To "#COL_ORANGE"Caligula's Palace & Casino! "#COL_LIGHTBLUE"Enter The "#COL_RED"Checkpoint "#COL_LIGHTBLUE"Underground To Start A Casino Rob.");
        SetPlayerFacingAngle(playerid,180);
        SetCameraBehindPlayer(playerid);
    }
    if(checkpointid == caligrobcp)
    {
        CasRobberID=playerid;
        CasRobberRecentMS=GetTickCount();
        SendClientMessage(playerid,COLOR_ORANGE,"You Can Rob Our Casino If You Like! Wait Here For 5 Seconds, Thats All We Ask!");
        GameTextForPlayer(playerid,"~y~stay in the checkpoint for ~n~~w~5 seconds",5000,3); // this shows when u walk into the rob checkpoint,
    }
    if(checkpointid == caligexitcp)
    {
        SetPlayerInterior(playerid,0);
        SetPlayerVirtualWorld(playerid,0);
        SendClientMessage(playerid,red,"You Have Exited Caligula's Palace. Thanks For Visiting!");
        SetPlayerPos(playerid,2190.3384,1677.3412,11.5830);
        SetPlayerFacingAngle(playerid,87.9511);
        SetCameraBehindPlayer(playerid);
    }
    return 1;
}

// my forwarded public timer for caligtimer

forward CasRob(playerid);
public CasRob(playerid)
{
    if(IsPlayerInDynamicCP(CasRobberID,caligrobcp))
    {
        if(GetTickCount()-CasRobberRecentMS>5000)
        {
            SendClientMessage(CasRobberID,COLOR_LIGHTBLUE,"Robbery Complete! Received $150,000 And 2+ Score!");
            GameTextForPlayer(CasRobberID,"~p~robbery completed! ~n~~w~recieved ~y~$150,000 ~w~& ~y~2+ Score",5000,3);
            GivePlayerMoney(CasRobberID,150000);
            SetPlayerScore(CasRobberID, GetPlayerScore(CasRobberID) + 2);
        }
    }
   
    if(!IsPlayerInDynamicCP(CasRobberID,caligrobcp))
    {
        SendClientMessage(CasRobberID,red,"Robbery Failed. You Didn't Stay In The Checkpoint Long Enough!");
        GameTextForPlayer(CasRobberID,"~r~casino robbery failed",5000,3);
   
    }
    return true;
}
Now, my problem is, that when I walk into the rob checkpoint and stand there, the "Robbery Complete! Received $150,000 And 2+ Score!" message keeps spamming every 1 second, same with when I walk out of the checkpoint, it will spam "Robbery Failed. You Didn't Stay In The Checkpoint Long Enough!" when I'm outside of the checkpoint, and it will go on forever, what have I done wrong and how do I fix it?
Reply
#2

You need create timer for player exapmple and when rober completed kill timer..

example:

pawn Код:
new RobOrder[MAX_PLAYERS];

// Enter Rob CP..
if(chekpointid == Rob)
{
    //You'r functions if can rob etc.
    //...
    RobOrder[playerid]=SetTimerEx("CashRob",1000,true,"i",playerid);
}

forward CashRob(playerid);
public CashRob(playerid)
{
    if(GetTickCount()-CasRobberRecentMS>5000)
    {
        SendClientMessage(CasRobberID,COLOR_LIGHTBLUE,"Robbery Complete! Received $150,000 And 2+ Score!");
        GameTextForPlayer(CasRobberID,"~p~robbery completed! ~n~~w~recieved ~y~$150,000 ~w~& ~y~2+ Score",5000,3);
        GivePlayerMoney(CasRobberID,150000);
        SetPlayerScore(CasRobberID, GetPlayerScore(CasRobberID) + 2);
        // Kill Timer When Mission Completed
        KillTimer(RobOrder[playerid]);
    }
    return true;
}
Reply
#3

Doesn't work.

Anyone else?
Reply


Forum Jump:


Users browsing this thread: