What is the best way?
#7

Quote:
Originally Posted by MP2
Посмотреть сообщение
Why don't you explain to him why?


The first method is definately not the way to do things. In fact, you don't really need a variable at all, just do this if you only need it once:

pawn Код:
if(GetPlayerVehicleID(playerid) == Player[playerid][pCar]) SendClientMessage(playerid, "It's your vehicle");
@Vanchesta (OP): Please use [ pawn ] tags, not php.
No mate, I ain't gonna use it once, there will be multiple actions with it, that's why I added "codes to be used with vehicle" as a comment. Well, I noticed that if you use #define anywhere at script then it affects to whole code, so I decided to undefine it when the function ends. So what's better now?

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        #define vehicle GetPlayerVehicleID(playerid)
        if(vehicle == Player[playerid][pCar]) SendClientMessage(playerid, "It's your vehicle");
        // codes to be used with vehicle
        #undef vehicle
    }
    return 1;
}
or

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        new vehicle GetPlayerVehicleID(playerid)
        if(vehicle == Player[playerid][pCar]) SendClientMessage(playerid, "It's your vehicle");
        // codes to be used with vehicle
    }
    return 1;
}
P.S: Sorry if you don't understand me, I'm not best in speaking english at all.
Reply


Messages In This Thread
What is the best way? - by Vanchesta - 22.03.2014, 08:21
Re: What is the best way? - by Hanuman - 22.03.2014, 08:32
Re: What is the best way? - by MP2 - 23.03.2014, 06:33
Re: What is the best way? - by Lloyde - 23.03.2014, 06:41
Re: What is the best way? - by MP2 - 23.03.2014, 06:56
Re: What is the best way? - by Hanuman - 23.03.2014, 07:14
Re: What is the best way? - by Vanchesta - 23.03.2014, 09:13
Re: What is the best way? - by Hanuman - 23.03.2014, 09:29
Re: What is the best way? - by Vanchesta - 23.03.2014, 18:36
Re: What is the best way? - by Konstantinos - 23.03.2014, 18:42

Forum Jump:


Users browsing this thread: 2 Guest(s)