What will be the outcome?
#1

If I do this specific loop:
pawn Code:
for(new i; i<MAX_PLAYERS; i++)
{
   if(IsPlayerInVehicle(i, IsATaxi(GetPlayerVehicleID(i))) && newstate == PLAYER_STATE_DRIVER)
   {
     return GivePlayerCash(i, 20);
   }
}
My IsATaxi function:
pawn Code:
public IsATaxi(vehicleid)
{  
   new model = GetVehicleModel(vehicleid);
   if(model == 420)
   {
     return 1;
   }
   return 0;
}
Will this give every driver that is currently in a taxi $20 or just the one the passenger enters.

Whole section of desired code:
pawn Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
   if(newstate == PLAYER_STATE_PASSENGER)
   {
     if(PlayerInfo[playerid][pCalledTaxi] == 1 && IsATaxi(GetPlayerVehicleID(playerid)))
     {
        GivePlayerCash(playerid, -20);
        PlayerInfo[playerid][pCalledTaxi] = 0;
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "* You entered the taxi which you called for, this ride has cost you $20.");
        for(new i; i<MAX_PLAYERS; i++)
        {
          if(IsPlayerInVehicle(i, IsATaxi(GetPlayerVehicleID(i))) && newstate == PLAYER_STATE_DRIVER)
          {
             return GivePlayerCash(i, 20);
          }
        }
and so on..
Reply
#2

Go test it.
Reply
#3

Yes, i don't understand why you would ask us, when you could simply test it yourself.
Reply
#4

use 127.0.0.1:7777 to test it, thats the usefulness of it
Reply
#5

I asked for a reason. I have nobody to test with and it's a closed beta.
Reply
#6

Just the driver
Reply
#7

why u use : for(new i; i<MAX_PLAYERS; i++) and you don't use for(new i = 0 ; i<MAX_PLAYERS; i++)
Reply
#8

Quote:
Originally Posted by FUNExtreme
Just the driver
That's all I needed..
Thank you.
Reply
#9

Quote:
Originally Posted by MoroJr™
why u use : for(new i; i<MAX_PLAYERS; i++) and you don't use for(new i = 0 ; i<MAX_PLAYERS; i++)
Because you don't need it. New variables are automatically assigned 0.
Reply
#10

i didn't knew this thx
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)