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(522, 0.0, 0.0, 0.0,0.0, -1, -1, 60);
arrMissionVeh[1]=CreateVehicle(522, 0.0, 0.0, 0.0,0.0, -1, -1, 60);
arrMissionVeh[2]=CreateVehicle(522, 0.0, 0.0, 0.0,0.0, -1, -1, 60);
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate){
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(522, 0.0, 0.0, 0.0,0.0, -1, -1, 60);
arrMissionVeh[1]=CreateVehicle(522, 0.0, 0.0, 0.0,0.0, -1, -1, 60);
arrMissionVeh[2]=CreateVehicle(522, 0.0, 0.0, 0.0,0.0, -1, -1, 60);
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate){
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(522, 0.0, 0.0, 0.0,0.0, -1, -1, 60);
And then check if the player's vehicle is the same as this..
PHP код:
cmd:startjob(playerid, params[])
{
new vehicle = GetPlayerVehicleID(playerid);
if(vehicle != arrMissionVeh[0] && vehicle != arrMissionVeh[1] && vehicle != arrMissionVeh[3]) return SendClientMessage(playerid, COLOR_RED, "You are not in job's vehicle!");
//Add your job code here..
}