Taxi script not working
#1

PHP код:
public OnPlayerClickMap(playeridFloat:fXFloat:fYFloat:fZ)
{
     for(new 
0MAX_PLAYERSi++)
    {
        if(
taxi[i]==&& GetPlayerState(playerid) == PLAYER_STATE_PASSENGER && != playerid)
        {
            
SetPlayerMapIcon(i0fXfYfZ00xFF0000FFMAPICON_GLOBAL);
               if(
IsPlayerInRangeOfPoint(i50fXfYfZ))
            {
                
RemovePlayerMapIcon(i0);
                
SendClientMessage(playerid, -1"you have arrived");
                
GameTextForPlayer(i"you have arrived"10000);
                 
TextDrawShowForPlayer(itextdraw_payout);
                 
TextDrawShowForPlayer(itextdraw_taxipayout);
                
GivePlayerMoney(i3000);
                
GivePlayerMoney(, -100);
            }
        }
    }
    return 
1;

PHP код:
CMD:taxi(playeridparams[])
{
    new 
vmodel GetVehicleModel(GetPlayerVehicleID(playerid));
    if(
vmodel != 420 && vmodel != 438) return SendClientMessage(playerid0xFF0000FF"You are not in a Taxi!");
    
GameTextForPlayer(playerid"TAXI"60004);
    
taxi[playerid] = 1;
    
PlayerTextDrawShow(playeridtextdraw_taxicustomer[playerid]);
    return 
1;

Whenever a player clicks the map, the taxi sees it on the map, however when he gets near, nothing happens :/
Any idea?
Reply
#2

Checking the range in OnPlayerClickMap is the problem. If taxi drivers are not in range of 50 meters at the time the player clicks on map, nothing will happen.

I believe the best way to achieve this is by using dynamic areas and not timers. Something like this:
- Player A clicks on map and alerts taxi drivers.
- Create a dynamic sphere at player's position with range of 50 and call Streamer_Update function for all the taxi drivers to update the areas for them.
- Now you have the areaid returned when creating the sphere and stored in variable. When taxi drivers enter the area, OnPlayerEnterDynamicArea will be called and you can execute your code there.
Reply
#3

I did this, could someone correct my code, it doesn't seem to work :/

PHP код:
public OnPlayerClickMap(playeridFloat:fXFloat:fYFloat:fZ)
{
     for(new 
0MAX_PLAYERSi++)
    {
        if(
taxi[i]==&& GetPlayerState(playerid) == PLAYER_STATE_PASSENGER && != playerid)
        {
            
SetPlayerMapIcon(i0fXfYfZ00xFF0000FFMAPICON_GLOBAL);
            
taxiarea CreateDynamicSphere(fXfYfZ1000i);
            
Streamer_Update(i);
        }
    }
    return 
1;
}
public 
OnPlayerEnterDynamicArea(playeridareaid)
{
    for(new 
0MAX_PLAYERSi++)
    {
        if(
areaid == taxiarea && taxi[playerid]==&& GetPlayerState(i) == PLAYER_STATE_PASSENGER)
        {
            
RemovePlayerMapIcon(playerid0);
            
SendClientMessage(i, -1"you have arrived");
            
GameTextForPlayer(playerid"you have arrived"10000);
            
TextDrawShowForPlayer(playeridtextdraw_payout);
            
TextDrawShowForPlayer(playeridtextdraw_taxipayout);
            
GivePlayerMoney(playerid3000);
            
GivePlayerMoney(i, -100);
        }
    }
    return 
1;

//EDIT added Streamer_Update(i); nothing happened
Reply
#4

I guess you miss-assigned something in there, Explain to me exactly what you're doing so I can help you.
Reply
#5

Sorry, i missspelt something somewhere else in my script, now it's working, thanks a lot !!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)