SA-MP Forums Archive
Check is it passsanger - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Check is it passsanger (/showthread.php?tid=552595)



Check is it passsanger - cyberlord - 25.12.2014

hello why this code doesnt work (its for npc trains i need to make them payable) :
Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(IsPlayerInVehicle(playerid, LSTrain1NPCVehicle || SFTrain2NPCVehicle || LVTrain3NPCVehicle) && ispassenger)
	{
	 
        GivePlayerMoney(playerid, -10);
        GameTextForPlayer(playerid,"~G~Uz bilieta sumokejot 10 Euru",3000,3);
	}
    
    
	return 1;
}



Re: Check is it passsanger - M4D - 25.12.2014

use OnPlayerState change because this callback call when someone attempt to enter a vehicle. You have to check that a player has entered vehicle or no !
I edited your code but its better to use it onplayerstatechange
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(vehicleid == LSTrain1NPCVehicle || vehicleid == SFTrain2NPCVehicle || vehicleid == LVTrain3NPCVehicle) && ispassenger)
    {
     
        GivePlayerMoney(playerid, -10);
        GameTextForPlayer(playerid,"~G~Uz bilieta sumokejot 10 Euru",3000,3);
    }
   
   
    return 1;
}
By using this callback if someone attempt to enter a vehicle but he cancel entering , server will gives him -10$


Re: Check is it passsanger - cyberlord - 25.12.2014

checking player state is like this PLAYER_STATE_PASSENGER ?


AW: Check is it passsanger - Flori - 25.12.2014

Quote:
Originally Posted by cyberlord
Посмотреть сообщение
hello why this code doesnt work (its for npc trains i need to make them payable) :
Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(IsPlayerInVehicle(playerid, LSTrain1NPCVehicle || SFTrain2NPCVehicle || LVTrain3NPCVehicle) && ispassenger)
	{
	 
        GivePlayerMoney(playerid, -10);
        GameTextForPlayer(playerid,"~G~Uz bilieta sumokejot 10 Euru",3000,3);
	}
    
    
	return 1;
}
Instead of checking if the player is in one of those vehicles you may can compare the vehicleid like: if(vehicleid == LSTrain1NPCVehicle /*plus the passenger like*/ && ispassenger ==0); if he enters that vehicle and as a passenger.

Edit: LOL, i was to slow, i mean same like M4D

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

Well, read through it to understand it completly.


Re: Check is it passsanger - M4D - 25.12.2014

Yes, if old state of playerid wasn't passenger and his new state is passenger , so player entered a vehicle as passenger
After this , get player vehicle id and check if vehicle id was one of that 3 bot vehicles, give him -10$ and etc