SA-MP Forums Archive
OnPlayerEnter SPECIFIC/UNIQUE Vehicle - 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: OnPlayerEnter SPECIFIC/UNIQUE Vehicle (/showthread.php?tid=655593)



OnPlayerEnter SPECIFIC/UNIQUE Vehicle - Adamoneoone - 25.06.2018

Hey guys, as the titles says, I'm trying to make a system that will allow the player to do certain things (like starting a job or something else) but ONLY when he enters a specific vehicle on the map. For instance, if three bikes (like three NRG-500s) are spawned next to eachother, only the middle one will start a delivery job.
Thanks for your help!


Re: OnPlayerEnter SPECIFIC/UNIQUE Vehicle - 0xDC143CAA - 25.06.2018

You could perhaps try using "GetPlayerDistanceFromPoint(playerid, Float:X, Float:Y, Float:Z)" and if he is within distance from the point and in the vehicle model you want then the job starts.


Re: OnPlayerEnter SPECIFIC/UNIQUE Vehicle - Adamoneoone - 25.06.2018

I would like to make it possible that the player can start the job anywhere he wants, as long as he is in the vehicle. A more appropriate example would be a Cheetah in which you can start the police job.


Re: OnPlayerEnter SPECIFIC/UNIQUE Vehicle - CodeStyle175 - 25.06.2018

PHP код:
new arrMissionVeh[3];
#define gVeh GetPlayerVehicleID

public OnGameModeInit(){
    
arrMissionVeh[0]=CreateVehicle(5220.00.00.0,0.0, -1, -160);
    
arrMissionVeh[1]=CreateVehicle(5220.00.00.0,0.0, -1, -160);
    
arrMissionVeh[2]=CreateVehicle(5220.00.00.0,0.0, -1, -160);
    return 
1;
}

public 
OnPlayerStateChange(playeridnewstateoldstate){
    new 
vid=gVeh(playerid);
    if(    
oldstate==PLAYER_STATE_ONFOOT && 
        
newstate==PLAYER_STATE_DRIVER &&
        
vid==arrMissionVeh[1]){
        
//your mission code here
    
}
    return 
1;




Re: OnPlayerEnter SPECIFIC/UNIQUE Vehicle - Verc - 25.06.2018

PHP код:
#define gVeh GetPlayerVehicleID 
No,there's no point you redefine a function,****** has said it to you,why are you doing it again? This can cause a lot of confusion if you reopen your script in the future and etc.


Re: OnPlayerEnter SPECIFIC/UNIQUE Vehicle - Sew_Sumi - 25.06.2018

Quote:
Originally Posted by Verc
Посмотреть сообщение
No,there's no point you redefine a function,****** has said it to you,why are you doing it again? This can cause a lot of confusion if you reopen your script in the future and etc.
More that when people paste up his code as a fix, then ask "What's gVeh" and someone keeps throwing the stupid define about...

Pretty sure this all originated from whoever thought it was a good idea to abbreviate SendClientMessage to SCM... Stupidest shit ever, and only encourages laziness.

And even with that confusing if statement.... Jesus. Terribly inconsiderate of those who are just learning to script.


Re: OnPlayerEnter SPECIFIC/UNIQUE Vehicle - CodeStyle175 - 25.06.2018

Verc and Sew_Sumi is alex cole your father ors?
when defines are available why not use them?
its doesn't make your code slower in any way
and you don't need to be so nerdy programmers who really doesn't know how to code


Re: OnPlayerEnter SPECIFIC/UNIQUE Vehicle - Sew_Sumi - 25.06.2018

Because defines do nothing...

And by throwing this practice up, even when you've been advised that it's not necessary, you're simply spreading bad coding practice...

Quote:

and you don't need to be so nerdy programmers who really doesn't know how to code

And this just shows how bad you are at even explaining or debating anything... Seriously, you've been told why this isn't a good idea, and I even showed it...

After all, the amount of threads where people throw up code to people that has the SCM example in it, yet they don't include the SCM define, should show why this isn't a good idea to keep spreading this laziness...


It's LAZY... Like, jesus, most IDEs have autocompletion, so why go the extra step throwing in the define, when you could autocomplete, or even, 'shock horror' use a text replacement option in the IDE itself.


Again, it's bad, it's lazy, and it shows that you don't listen.


Re: OnPlayerEnter SPECIFIC/UNIQUE Vehicle - Adamoneoone - 25.06.2018

Alright thanks for your help all!
Basically I have to do this?

PHP код:
new arrMissionVeh[3];
public 
OnGameModeInit(){
    
arrMissionVeh[0]=CreateVehicle(5220.00.00.0,0.0, -1, -160);
    
arrMissionVeh[1]=CreateVehicle(5220.00.00.0,0.0, -1, -160);
    
arrMissionVeh[2]=CreateVehicle(5220.00.00.0,0.0, -1, -160);
    return 
1;
}
public 
OnPlayerStateChange(playeridnewstateoldstate){
    if(    
oldstate==PLAYER_STATE_ONFOOT && 
        
newstate==PLAYER_STATE_DRIVER &&
        
GetPlayerVehicleID==arrMissionVeh[1]){
        
//your mission code here
    
}
    return 
1;




Re: OnPlayerEnter SPECIFIC/UNIQUE Vehicle - JasonRiggs - 25.06.2018

Alright, let me sort this out for you..

First, You need to set a specific ID for the car, just like what a person gave you before, like..

PHP код:
arrMissionVeh[0]=CreateVehicle(5220.00.00.0,0.0, -1, -160); 
And then check if the player's vehicle is the same as this..

PHP код:
cmd:startjob(playeridparams[])
{
     new 
vehicle GetPlayerVehicleID(playerid);
     if(
vehicle != arrMissionVeh[0] && vehicle != arrMissionVeh[1] && vehicle != arrMissionVeh[3]) return SendClientMessage(playeridCOLOR_RED"You are not in job's vehicle!");
     
//Add your job code here..