How to show this for the driver and the passenger ? -
Drago987 - 20.06.2014
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 ?
Re: How to show this for the driver and the passenger ? -
Rittik - 20.06.2014
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.
}
}
}
Re: How to show this for the driver and the passenger ? -
Drago987 - 21.06.2014
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
Re: How to show this for the driver and the passenger ? -
[WSF]ThA_Devil - 21.06.2014
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);
}
}
Re: How to show this for the driver and the passenger ? -
Yera96 - 21.06.2014
I wonder if it works, but try this:
PHP код:
IsAnTaxi(vehicleid) || IsAnBus(vehicleid))
{
if(ispassenger)
{
foreach(Player, i)
{
new string[77];
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);
}
}
}
Re: How to show this for the driver and the passenger ? -
Drago987 - 21.06.2014
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 ?
Re: How to show this for the driver and the passenger ? -
Campbell- - 21.06.2014
- 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.
Re: How to show this for the driver and the passenger ? -
Threshold - 21.06.2014
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;
}
Re: How to show this for the driver and the passenger ? -
Drago987 - 22.06.2014
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 -_-
Re: How to show this for the driver and the passenger ? -
Threshold - 22.06.2014
Mine didn't. So the fault is in your script, not mine.