How to show this for the driver and the passenger ?
#1

Well ,I've been trying to Make a code for OnPlayerEnterVehicle for the taxi drivers which shows the Passenger's name when he enters the taxi. Well ,this is the code which I made
pawn Код:
if(IsAnTaxi(vehicleid) || IsAnBus(vehicleid))
    {
        foreach(Player, i)
        {
            if(ispassenger)
            {
                new string[28];
                format(string, sizeof(string), "Passenger %s Entered the taxi with fare %d", GetPlayerNameEx(playerid), TransportValue[playeird]);
                ProxDetector(2.0, playerid, string, COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
                return 1;
            }
        }
}
It does send the message to the driver and the passenger...But it even sends it to nearby players though.
Can someone help me with it ?
Reply
#2

This code will work more precisely .As per my information.
pawn Код:
IsAnTaxi(vehicleid) || IsAnBus(vehicleid))
    {
        foreach(Player, i)
        {
            if(ispassenger)
            {
                new string[77]; //I changed to 77 slots.
                format(string, sizeof(string), "Passenger %s Entered the taxi with fare %d", GetPlayerNameEx(playerid), TransportValue[playeird]);
                ProxDetector(2.0, playerid, string, COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
                //I just removed the return 1; over here.
            }
        }
}
Reply
#3

Well...It's working thanks but it sends the message twice Like:
Код:
Passenger %s Entered the taxi with fare %d
Passenger %s Entered the taxi with fare %d
Reply
#4

Firstly, get vehicle id: then:
pawn Код:
foreach(new i : Player) {
if(GetPlayerVehicleID(i) == vehicle) {
new string[77]; //I changed to 77 slots.
                format(string, sizeof(string), "Passenger %s Entered the taxi with fare %d", GetPlayerNameEx(playerid), TransportValue[playeird]);
               SendClientMessage(playerid,COLOR_YELLOW,string);
}
}
Reply
#5

I wonder if it works, but try this:

PHP код:
IsAnTaxi(vehicleid) || IsAnBus(vehicleid))
{
    if(
ispassenger)
    {
        foreach(
Playeri)
        {
            new 
string[77]; 
            
format(stringsizeof(string), "Passenger %s Entered the taxi with fare %d"GetPlayerNameEx(playerid), TransportValue[playeird]);
            
ProxDetector(2.0playeridstringCOLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
        }
    }

Reply
#6

Quote:
Originally Posted by [WSF]ThA_Devil
Посмотреть сообщение
Firstly, get vehicle id: then:
pawn Код:
foreach(new i : Player) {
if(GetPlayerVehicleID(i) == vehicle) {
new string[77]; //I changed to 77 slots.
                format(string, sizeof(string), "Passenger %s Entered the taxi with fare %d", GetPlayerNameEx(playerid), TransportValue[playeird]);
               SendClientMessage(playerid,COLOR_YELLOW,string);
}
}
Well..It works thanks man..
But is there any way to let it show as soon as the passenger steps into the taxi (Not when he press "G") and shows it for the driver only ?
Reply
#7

  • Don't ever make use of the 'ProxDetector' in your script. It's outdated and not well written.
  • Don't use an extra function to save a player's name (GetPlayerNameEx()). Save the player's name in a variable once he connects and use this variable all the time instead.
Reply
#8

https://sampwiki.blast.hk/wiki/OnPlayerStateChange

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate & PLAYER_STATE_PASSENGER)
    {
        new vid = GetPlayerVehicleID(playerid);
        if(IsAnTaxi(vid) || IsAnBus(vid))
        {
            foreach(new i : Player)
            {
                if(i == playerid) continue;
                if(!IsPlayerInVehicle(i, vid)) continue;
                if(GetPlayerVehicleSeat(i)) continue;
                new string[80];
                format(string, sizeof(string), "Passenger %s Entered the taxi with a fare of %d", GetPlayerNameEx(playerid), TransportValue[i]);
                SendClientMessage(i, -1, string);
                format(string, sizeof(string), "You have entered a taxi with a fare of $%d", TransportValue[i]);
                SendClientMessage(playerid, -1, string);
                break;
            }
        }
    }
    return 1;
}
Reply
#9

Quote:
Originally Posted by Threshold
Посмотреть сообщение
https://sampwiki.blast.hk/wiki/OnPlayerStateChange

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate & PLAYER_STATE_PASSENGER)
    {
        new vid = GetPlayerVehicleID(playerid);
        if(IsAnTaxi(vid) || IsAnBus(vid))
        {
            foreach(new i : Player)
            {
                if(i == playerid) continue;
                if(!IsPlayerInVehicle(i, vid)) continue;
                if(GetPlayerVehicleSeat(i)) continue;
                new string[80];
                format(string, sizeof(string), "Passenger %s Entered the taxi with a fare of %d", GetPlayerNameEx(playerid), TransportValue[i]);
                SendClientMessage(i, -1, string);
                format(string, sizeof(string), "You have entered a taxi with a fare of $%d", TransportValue[i]);
                SendClientMessage(playerid, -1, string);
                break;
            }
        }
    }
    return 1;
}
Pawno Crashed -_-
Reply
#10

Mine didn't. So the fault is in your script, not mine.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)