SA-MP Forums Archive
Command working but showing all messages - 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: Command working but showing all messages (/showthread.php?tid=326215)



Command working but showing all messages - NewerthRoleplay - 16.03.2012

Hi i have a command which can be used in multiple places, when i use the command in one of these places it runs all 3 of the SendClientMessage function. Anyway cutting to the chase, here is the command (ZCMD).

pawn Код:
CMD:acceptjob(playerid, params[])
{
 if(IsPlayerInRangeOfPoint(playerid, 10,-1547.7715,123.7701,3.5547))
    {
        if(pJob[playerid] == 0)
        {
        pJob[playerid] = TRUCKER;
        SendClientMessage(playerid, COLOR_WHITE, ".:: You have now joined the job, Trucker ::.");
        SendClientMessage(playerid, COLOR_WHITE, ".:: To start work grab a truck and use /startjob ::.");
        }
        if(pJob[playerid] > 0)
        {
            SendClientMessage(playerid, COLOR_WHITE, ".:: You must quit your current job using /quitjob ::.");
        }
    }
 if(IsPlayerInRangeOfPoint(playerid, 10,1760.1884,-1895.4938,13.5612))
    {
        if(pJob[playerid] == 0)
        {
        pJob[playerid] = TAXI;
        SendClientMessage(playerid, COLOR_WHITE, ".:: You have now joined the job, Taxi Drive ::.");
        SendClientMessage(playerid, COLOR_WHITE, ".:: To start work grab a taxi and use /startjob ::.");
        }
        if(pJob[playerid] > 0)
        {
            SendClientMessage(playerid, COLOR_WHITE, ".:: You must quit your current job using /quitjob ::.");
        }
    }
 if(IsPlayerInRangeOfPoint(playerid, 10,-2033.3699,133.1192,28.8359))
    {
        if(pJob[playerid] == 0)
        {
        pJob[playerid] = MECHANIC;
        SendClientMessage(playerid, COLOR_WHITE, ".:: You have now joined the job, Mechanic ::.");
        SendClientMessage(playerid, COLOR_WHITE, ".:: To start work grab a tow truck and use /startjob ::.");
        }
        if(pJob[playerid] > 0)
        {
            SendClientMessage(playerid, COLOR_WHITE, ".:: You must quit your current job using /quitjob ::.");
        }
    }
 if(IsPlayerInRangeOfPoint(playerid, 10,-1721.8835,1356.2217,7.1805))
    {
        if(pJob[playerid] ==0)
        {
        pJob[playerid] = PIZZA;
        SendClientMessage(playerid, COLOR_WHITE, ".:: You have now joined the job, Pizza ::.");
        SendClientMessage(playerid, COLOR_WHITE, ".:: To start work grab a faggio and use /startjob ::.");
        }
       
        if(pJob[playerid] > 0)
        {
            SendClientMessage(playerid, COLOR_WHITE, ".:: You must quit your current job using /quitjob ::.");
        }
    }



 else SendClientMessage(playerid, COLOR_WHITE, ".:: You must be near a job area to start one! :..");
 return 1;
}



Re: Command working but showing all messages - ReneG - 16.03.2012

You must return a value after each message is sent to tell the command to stop processing. Or else the command won't stop until it has gone through all the if statements. Just return 1; after each cluster of SendClientMessage "functions" as you call it.


Re: Command working but showing all messages - NewerthRoleplay - 16.03.2012

Quote:
Originally Posted by VincentDunn
Посмотреть сообщение
You must return a value after each message is sent to tell the command to stop processing. Or else the command won't stop until it has gone through all the if statements. Just return 1; after each cluster of SendClientMessage "functions" as you call it.
Thanks...pretty sure it is a function go look at the wiki, in fact ill bring it to you: This function can be used to send a message to a certain player with any chosen color.

Anyway thanks


Re: Command working but showing all messages - ReneG - 16.03.2012

Quote:
Originally Posted by NewerthRoleplay
Посмотреть сообщение
Thanks...pretty sure it is a function go look at the wiki, in fact ill bring it to you: This function can be used to send a message to a certain player with any chosen color.

Anyway thanks
Yes, SendClientMessage is a native function, I thought you were using the word function to describe each group of messages. Just return 1; after each if statement and tell me how it pans out for you. Hope I could be of help.


Re: Command working but showing all messages - NewerthRoleplay - 16.03.2012

Quote:
Originally Posted by VincentDunn
Посмотреть сообщение
Yes, SendClientMessage is a native function, I thought you were using the word function to describe each group of messages. Just return 1; after each if statement and tell me how it pans out for you. Hope I could be of help.
Haha no i ment it as a native function, thanks alot mate it helped one more step forward in my RP script .... about 100 more steps to go xD