Taxi Fare
#1

So when someone gets into taxi and taxi driver types /taxi start fare is going really fast, like in few seconds it's thousand

Code
PHP код:
stock ChargePerson(playerid)
{
    new 
string[128];
    if(
GetPlayerMoney(playerid) < TaxiMoney[playerid])
    {
    
format(string,sizeof(string),"%s doesn't have enough money to pay for the TAXI.",GetPlayerNameEx(playerid));
    
SendClientMessage(GetVehicleDriver(OldVehicle[playerid]), COLOR_WHITEstring);
        
TaxiMade[GetVehicleDriver(OldVehicle[playerid])] -= TaxiMoney[playerid];
        
TaxiMoney[playerid] = 0;
    }
    else
    {
        
format(stringsizeof(string), "[TAXI]: The final taxi fare has got to, $%d."TaxiMoney[playerid]);
        
SendClientMessage(playeridCOLOR_YELLOWstring);
        
GivePlayerCash(playerid, -TaxiMoney[playerid]);
        
GivePlayerCash(GetVehicleDriver(OldVehicle[playerid]), TaxiMoney[playerid]);
        
TaxiMade[GetVehicleDriver(OldVehicle[playerid])] -= TaxiMoney[playerid];
        
TaxiMoney[playerid] = 0;
    }

PHP код:
    for(new 0MAX_VEHICLESi++)
    {
        if(
IsATaxi(i))
        {
            new 
driver GetVehicleDriver(i);
            if(
driver != INVALID_PLAYER_ID)
            {
                if(
TaxiDuty{driver} && TaxiStart{driver} && CountVehiclePlayers(i) > 0)
                {
                    new 
string[128];
                    
format(stringsizeof(string), "~y~TAXI FARE: $%d"TaxiMade[driver]);
                    
GameTextForPlayer(driverstring16);
                    for(new 
0MAX_PLAYERSp++)
                    {
                        if(
IsPlayerConnected(p) && PlayerInCar(p) && GetPlayerState(p) != PLAYER_STATE_DRIVER && GetPlayerVehicleID(p) == GetPlayerVehicleID(driver))
                        {
                            
format(stringsizeof(string), "~y~TAXI FARE: $%d"TaxiMoney[p]);
                            
GameTextForPlayer(pstring16);
                            
TaxiMoney[p] += TaxiFare{driver};
                            
TaxiMade[driver] += TaxiFare{driver};
                        }
                    }
                }
            }
        }
    } 
Reply
#2

UP UP UP
Reply
#3

Where's your for cycle located? In a callback or a timer?
Reply
#4

I have this

PHP код:
//Taxi variables
#define TAXI 17
new bool:TaxiDuty[MAX_PLAYERS char],
    
TaxiFare[MAX_PLAYERS char],
    
bool:TaxiStart[MAX_PLAYERS char],
    
TaxiMoney[MAX_PLAYERS],
    
OldVehicle[MAX_PLAYERS],
    
TaxiMade[MAX_PLAYERS];
//Taxi variables 
This under OnPlayerConnect
PHP код:
    TaxiDuty[playerid] = falseTaxiFare[playerid] = 0TaxiStart[playerid] = falseTaxiMoney[playerid] = 0TaxiMade[playerid] = 0
This under OnPlayerStateChange
PHP код:
        if(TaxiMoney[playerid] > && IsATaxi(oldvehicle))
        {
            
ChargePerson(playerid);
        } 
Reply
#5

UP UP UP
Reply
#6

So no one can help me with this?
Reply
#7

Where is this located?
for(new i = 0; i < MAX_VEHICLES; i++)
{
if(IsATaxi(i))
{
new driver = GetVehicleDriver(i);
if(driver != INVALID_PLAYER_ID)
{
if(TaxiDuty{driver} && TaxiStart{driver} && CountVehiclePlayers(i) > 0)
{
new string[128];
format(string, sizeof(string), "~y~TAXI FARE: $%d", TaxiMade[driver]);
GameTextForPlayer(driver, string, 1, 6);
for(new p = 0; p < MAX_PLAYERS; p++)
{
if(IsPlayerConnected(p) && PlayerInCar(p) && GetPlayerState(p) != PLAYER_STATE_DRIVER && GetPlayerVehicleID(p) == GetPlayerVehicleID(driver))
{
format(string, sizeof(string), "~y~TAXI FARE: $%d", TaxiMoney[p]);
GameTextForPlayer(p, string, 1, 6);
TaxiMoney[p] += TaxiFare{driver};
TaxiMade[driver] += TaxiFare{driver};
}
}
}
}
}
}

If this is located on OnPlayerUpdate then it will go super-fast..

If I've helped you with something please feel free to REP me, or at-least say "Thanks!"
- Abagail
Reply
#8

Yeah it is located there

Can i make it in some different way?

EDIT: Maybe i found out, will check.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)