SA-MP Forums Archive
IsPlayerNearAnyRobberyArea - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: IsPlayerNearAnyRobberyArea (/showthread.php?tid=510586)



IsPlayerNearAnyRobberyArea - vassilis - 01.05.2014

custom function i made
pawn Код:
IsPlayerNearAnyRobberyArea(playerid)
{
        if( IsPlayerInRangeOfPoint( playerid, 3.0, 381.647399, -56.551239, 1001.515136) || IsPlayerInRangeOfPoint( playerid, 3.0, 810.491821, -1616.179199, 13.546875) || IsPlayerInRangeOfPoint( playerid, 3.0, 1070.025268, 249.608657, 536.092712) )
        {
            return true; //if player is near we will return true;
        }
         return false;
}
CMD:robstore(playerid,params[])
{
    if(gteam[playerid] != TEAM_CIV) return SendClientMessage(playerid,COLOR_RED,"(Error): You must be civilian to use this command!");
    if(!IsPlayerNearAnyRobberyArea(playerid)) return ErrorMessages(playerid,5);
    if(GetPlayerWantedLevel(playerid) >= 3) return ErrorMessages(playerid,7);
    if(alreadyrobbed[playerid] && gettime() < alreadyrobbed[playerid])return SendClientMessage(playerid,COLOR_RED,"(Error): You have already robbed a shop!Try Later!");
    if(Player_CountDown[playerid] != -1) return SendClientMessage(playerid, COLOR_RED, "(Error): Please wait until the robbery you've started gets finished.");
    Player_CountDown[playerid] = 30;
    PlayerTimer_CountDown[playerid] = SetTimerEx("countdown", 1000, true, "i", playerid);
    SetPlayerProgressBarValue(playerid,bar[playerid],0);
    ShowPlayerProgressBar(playerid,bar[playerid]);
    IncreasePlayerWantedLevel(playerid,4);
    alreadyrobbed[playerid] = gettime() + 120;
    SendClientMessage(playerid,-1," ("COL_GREEN"WAIT"COL_WHITE"): Please stay at the point for 30 seconds if you want the robbery to be completed!");
    GameTextForPlayer(playerid,"~r~Starting Robbery!",1000,6);
    return 1;
}
Eventhough it compiles it says i am not near the robbery point... which i actually am..


Re: IsPlayerNearAnyRobberyArea - Teemo - 01.05.2014

pawn Код:
IsPlayerNearAnyRobberyArea(playerid)
{
        if( IsPlayerInRangeOfPoint( playerid, 3.0, 381.647399, -56.551239, 1001.515136) || IsPlayerInRangeOfPoint( playerid, 3.0, 810.491821, -1616.179199, 13.546875) || IsPlayerInRangeOfPoint( playerid, 3.0, 1070.025268, 249.608657, 536.092712) )
        {
            return true; //if player is near we will return true;
        }
         return false;
}
In these lines, Why are you using return true/false? Just make it normal, return 1;

That was my suggestion, I am not sure.



Re: IsPlayerNearAnyRobberyArea - vassilis - 01.05.2014

Quote:
Originally Posted by Teemo
Посмотреть сообщение
pawn Код:
IsPlayerNearAnyRobberyArea(playerid)
{
        if( IsPlayerInRangeOfPoint( playerid, 3.0, 381.647399, -56.551239, 1001.515136) || IsPlayerInRangeOfPoint( playerid, 3.0, 810.491821, -1616.179199, 13.546875) || IsPlayerInRangeOfPoint( playerid, 3.0, 1070.025268, 249.608657, 536.092712) )
        {
            return true; //if player is near we will return true;
        }
         return false;
}
In these lines, Why are you using return true/false? Just make it normal, return 1;

That was my suggestion, I am not sure.
I don't really think thats the problem.. lol


Re: IsPlayerNearAnyRobberyArea - Teemo - 01.05.2014

Well, That's was my suggestion, Because I had a same code like that (IsPlayerAt24/7), But i don't remember


Re: IsPlayerNearAnyRobberyArea - Konstantinos - 01.05.2014

It will only check for these 3 points and not any other (in your previous thread, you looped through the RobberyPoints array).

I'd suggest you to use dynamic checkpoints for the robbery points so you'll know for sure that you are in a point and if the player exits before 30 seconds pass, cancel the robbery.