12.04.2009, 22:37
If I do this specific loop:
My IsATaxi function:
Will this give every driver that is currently in a taxi $20 or just the one the passenger enters.
Whole section of desired code:
and so on..
pawn Code:
for(new i; i<MAX_PLAYERS; i++)
{
if(IsPlayerInVehicle(i, IsATaxi(GetPlayerVehicleID(i))) && newstate == PLAYER_STATE_DRIVER)
{
return GivePlayerCash(i, 20);
}
}
pawn Code:
public IsATaxi(vehicleid)
{
new model = GetVehicleModel(vehicleid);
if(model == 420)
{
return 1;
}
return 0;
}
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);
}
}