SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 20/06/2014, 01:20 PM   #1
Drago987
Huge Clucker
 
Drago987's Avatar
 
Join Date: Sep 2013
Location: No where
Posts: 233
Reputation: 3
Default How to show this for the driver and the passenger ?

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 Code:
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 ?
Drago987 is offline   Reply With Quote
Old 20/06/2014, 01:27 PM   #2
Rittik
Huge Clucker
 
Rittik's Avatar
 
Join Date: May 2014
Location: github.com/RittikVerma
Posts: 452
Reputation: 33
Default Re: How to show this for the driver and the passenger ?

This code will work more precisely .As per my information.
pawn Code:
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.
            }
        }
}
Rittik is offline   Reply With Quote
Old 21/06/2014, 03:15 PM   #3
Drago987
Huge Clucker
 
Drago987's Avatar
 
Join Date: Sep 2013
Location: No where
Posts: 233
Reputation: 3
Default Re: How to show this for the driver and the passenger ?

Well...It's working thanks but it sends the message twice Like:
Code:
Passenger %s Entered the taxi with fare %d
Passenger %s Entered the taxi with fare %d
Drago987 is offline   Reply With Quote
Old 21/06/2014, 03:21 PM   #4
[WSF]ThA_Devil
Gangsta
 
[WSF]ThA_Devil's Avatar
 
Join Date: Sep 2010
Location: United Kingdom
Posts: 724
Reputation: 55
Default Re: How to show this for the driver and the passenger ?

Firstly, get vehicle id: then:
pawn Code:
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);
}
}
__________________
Quote:
Originally Posted by Shinobu View Post
Somebody save me, I am not a server.
[WSF]ThA_Devil is online now   Reply With Quote
Old 21/06/2014, 03:23 PM   #5
Yera96
Little Clucker
 
Join Date: Mar 2013
Posts: 48
Reputation: 0
Default Re: How to show this for the driver and the passenger ?

I wonder if it works, but try this:

PHP Code:
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);
        }
    }

Yera96 is offline   Reply With Quote
Old 21/06/2014, 08:55 PM   #6
Drago987
Huge Clucker
 
Drago987's Avatar
 
Join Date: Sep 2013
Location: No where
Posts: 233
Reputation: 3
Default Re: How to show this for the driver and the passenger ?

Quote:
Originally Posted by [WSF]ThA_Devil View Post
Firstly, get vehicle id: then:
pawn Code:
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 ?
Drago987 is offline   Reply With Quote
Old 21/06/2014, 09:04 PM   #7
Campbell-
Big Clucker
 
Join Date: Jan 2012
Location: Germany
Posts: 140
Reputation: 12
Default Re: How to show this for the driver and the passenger ?

  • 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.
Campbell- is offline   Reply With Quote
Old 21/06/2014, 10:59 PM   #8
Threshold
High-roller
 
Threshold's Avatar
 
Join Date: Nov 2012
Location: Australia
Posts: 3,033
Reputation: 519
Default Re: How to show this for the driver and the passenger ?

http://wiki.sa-mp.com/wiki/OnPlayerStateChange

pawn Code:
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;
}
__________________

SERVER.LVCNR.NET:7777
Threshold is offline   Reply With Quote
Old 22/06/2014, 02:11 AM   #9
Drago987
Huge Clucker
 
Drago987's Avatar
 
Join Date: Sep 2013
Location: No where
Posts: 233
Reputation: 3
Default Re: How to show this for the driver and the passenger ?

Quote:
Originally Posted by Threshold View Post
http://wiki.sa-mp.com/wiki/OnPlayerStateChange

pawn Code:
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 -_-
Drago987 is offline   Reply With Quote
Old 22/06/2014, 02:44 AM   #10
Threshold
High-roller
 
Threshold's Avatar
 
Join Date: Nov 2012
Location: Australia
Posts: 3,033
Reputation: 519
Default Re: How to show this for the driver and the passenger ?

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

SERVER.LVCNR.NET:7777
Threshold is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Text dont show when passenger Don_Cage Scripting Help 5 30/01/2014 01:04 PM
Car take damage without a passenger/driver. Unri Scripting Help 4 26/09/2013 10:39 PM
Kicking out driver/passenger(s) before vehicle despawns Dairyll Scripting Help 0 19/01/2013 01:31 AM
[Include] Driveby - Detect when a PASSENGER is drivebying! (Driver support coming soon) Hiddos Includes 2 31/07/2011 07:24 PM
Badger's Anti-Drive by: Passenger/Driver/Both Badger(new) Filterscripts 13 10/08/2010 03:03 PM


All times are GMT. The time now is 05:15 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.