RemovePlayerFromVehicle Doesn't Work ? -
Gforcez - 26.10.2010
Hello, When i use RemovePlayerFromVehicle, And test it ingame, It Don't works.
Is this a SA:MP bug, or is it me that doing something wrong?
Please tell me.
Greetings
Gforcez
Re: RemovePlayerFromVehicle Doesn't Work ? -
Cameltoe - 26.10.2010
Probably you doing something wrong.. What about showing us some code ?
Re: RemovePlayerFromVehicle Doesn't Work ? -
Gforcez - 26.10.2010
Quote:
Originally Posted by Cameltoe
Probably you doing something wrong.. What about showing us some code ?
|
Sure here it is:
Код:
for(new i = 0; i <MAX_PIZZABIKES; i++)
{
if(PlayerInfo[playerid][pJob] != 1 && vehicleid == PizzaJobVehicles[i])
{
SendClientMessage(playerid, COLOR_RED, "You don't have the keys of this Vehicle");
SendClientMessage(playerid, COLOR_RED, "So you decide to step off the Pizzaboy");
RemovePlayerFromVehicle(playerid);
}
}
The Message is coming, But it doesn't remove a player from the Vehicle.
Re: RemovePlayerFromVehicle Doesn't Work ? -
xPawn - 26.10.2010
change playerid to i
Re: RemovePlayerFromVehicle Doesn't Work ? -
Gforcez - 26.10.2010
Quote:
Originally Posted by xPawn
change playerid to i
|
Doesn't Work
Re: RemovePlayerFromVehicle Doesn't Work ? -
Hiddos - 26.10.2010
Under what callback are you using it? If it's custom, when and how is it called?
Re: RemovePlayerFromVehicle Doesn't Work ? -
Gforcez - 26.10.2010
Quote:
Originally Posted by Hiddos
Under what callback are you using it? If it's custom, when and how is it called?
|
Код:
IsPlayerPizzaDeliverer(playerid, vehicleid) // This goes into: OnPlayerEnterVehicle
{
for(new i = 0; i <MAX_PIZZABIKES; i++)
{
if(PlayerInfo[playerid][pJob] != 1 && vehicleid == PizzaJobVehicles[i])
{
SendClientMessage(playerid, COLOR_RED, "You don't have the keys of this Vehicle");
SendClientMessage(playerid, COLOR_RED, "So you decide to step off the Pizzaboy");
RemovePlayerFromVehicle(playerid);
}
}
return 1;
}
Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
IsPlayerPizzaDeliverer(playerid, vehicleid);
return 1;
}
Re: RemovePlayerFromVehicle Doesn't Work ? -
The_Moddler - 26.10.2010
Quote:
Originally Posted by xPawn
change playerid to i
|
You don't even know what you are saying..
Does the text appear?
Re: RemovePlayerFromVehicle Doesn't Work ? -
Hiddos - 26.10.2010
Do you get the messages ("You don't have the keys", etc)? Where did you define the PizzaJobVehicles (The code where you care the vehicles)?
Moddler pwnt me
Re: RemovePlayerFromVehicle Doesn't Work ? -
Gforcez - 26.10.2010
Quote:
Originally Posted by The_Moddler
You don't even know what you are saying..
Does the text appear?
|
Quote:
Originally Posted by Hiddos
Do you get the messages ("You don't have the keys", etc)? Where did you define the PizzaJobVehicles (The code where you care the vehicles)?
Moddler pwnt me 
|
Yes, The Messages just appear.. Thats the Weirdest :S
Re: RemovePlayerFromVehicle Doesn't Work ? -
BMUK - 26.10.2010
Quote: "This goes into: OnPlayerEnterVehicle".
It doesnt work cos your not actually in the vehicle when the function is called.
OnPlayerEnterVehicle is called when you press the button [to enter the vehicle].
Re: RemovePlayerFromVehicle Doesn't Work ? -
The_Moddler - 26.10.2010
Ahaha, I know why, OnPlayerEnterVehicle is called BEFORE the player enters the car, so you should use this:
pawn Код:
public OnPlayerStateChange(playerid,newstate,oldstate)
{
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
{
IsPlayerPizzaDeliverer(playerid, GetPlayerVehicleID(playerid));
}
return 1;
}
BMUK won me grrr
Re: RemovePlayerFromVehicle Doesn't Work ? -
Hiddos - 26.10.2010
Okay, did some quick testing on my homehost and it turns out that OnPlayerEnterVehicle is called when the player presses the button to enter a vehicle (By default The 'F' key, the 'Enter' button), not when he actually has entered the vehicle. Hence why this occurs
Now this should work, remove the "IsPlayerPizzaDeliver" line in OnPlayerEnterVehicle, and use this one under OnPlayerKeyStateChange:
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER) IsPlayerPizzaDeliverer(playerid, GetPlayerVehicleID(playerid));
return 1;
}
Should work.
Moddler beat me again

. THIS MEANS WAR!
Re: RemovePlayerFromVehicle Doesn't Work ? -
Finn - 26.10.2010
Are you sure this part is right:
pawn Код:
PlayerInfo[playerid][pJob] != 1
Also, I'd suggest first checking player's job, then launching the loop if the job is correct (not like you're doing - checking the job every loop tick). Plus breaking the loop when found the correct vehicle id wouldn't hurt.
pawn Код:
if(PlayerInfo[playerid][pJob] != 1)
{
for(new i = 0; i <MAX_PIZZABIKES; i++)
{
if(vehicleid == PizzaJobVehicles[i])
{
SendClientMessage(playerid, COLOR_RED, "You don't have the keys of this Vehicle");
SendClientMessage(playerid, COLOR_RED, "So you decide to step off the Pizzaboy");
RemovePlayerFromVehicle(playerid);
break; // Kill the loop.
}
}
}
Edit: Maybe I should learn to write faster.
Re: RemovePlayerFromVehicle Doesn't Work ? -
The_Moddler - 26.10.2010
Quote:
Originally Posted by Hiddos
Okay, did some quick testing on my homehost and it turns out that OnPlayerEnterVehicle is called when the player presses the button to enter a vehicle (By default The 'F' key, the 'Enter' button), not when he actually has entered the vehicle. Hence why this occurs
Now this should work, remove the "IsPlayerPizzaDeliver" line in OnPlayerEnterVehicle, and use this one under OnPlayerKeyStateChange:
pawn Код:
public OnPlayerKeyStateChange(playerid, newstate, oldstate) { if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER) IsPlayerPizzaDeliverer(playerid, GetPlayerVehicleID(playerid)); return 1; }
Should work.
Moddler beat me again  . THIS MEANS WAR!
|
Lol xD
Yea, your code it's better actually, and I forgot
return 1;
Peace.
Re: RemovePlayerFromVehicle Doesn't Work ? -
BMUK - 26.10.2010
OnPlayer
KeyStateChange?
Re: RemovePlayerFromVehicle Doesn't Work ? -
The_Moddler - 26.10.2010
Quote:
Originally Posted by BMUK
OnPlayerKeyStateChange?
|
Lol.. he confused.. better use my code xD
Re: RemovePlayerFromVehicle Doesn't Work ? -
Gforcez - 26.10.2010
Well, Thank you guys, Its Working!
Re: RemovePlayerFromVehicle Doesn't Work ? -
karakana7 - 26.10.2010
Quote:
Originally Posted by Finn
Are you sure this part is right:
pawn Код:
PlayerInfo[playerid][pJob] != 1
Also, I'd suggest first checking player's job, then launching the loop if the job is correct (not like you're doing - checking the job every loop tick). Plus breaking the loop when found the correct vehicle id wouldn't hurt.
pawn Код:
if(PlayerInfo[playerid][pJob] != 1) { for(new i = 0; i <MAX_PIZZABIKES; i++) { if(vehicleid == PizzaJobVehicles[i]) { SendClientMessage(playerid, COLOR_RED, "You don't have the keys of this Vehicle"); SendClientMessage(playerid, COLOR_RED, "So you decide to step off the Pizzaboy"); RemovePlayerFromVehicle(playerid); break; // Kill the loop. } } }
Edit: Maybe I should learn to write faster.
|
Guys, can you explain, because i want to know, what actually means from this line:if(PlayerInfo[playerid][pJob] != 1):
[pJob] and !=1?I only saw =1 per my scripting time...And i don't understand the whole line:
for(new i = 0; i <MAX_PIZZABIKES; i++) :can someone say what it is used for?I understand that
new i is variable and now it has integer
0 inside itself, but what it gives i don't know.Is this code
i<MAX_PIZZABIKES only checks if all pizza boy bikes number is lower than variable
i?So why it need than?And for me it's unclear how bikes number can be lower than variable
i if variable is only
0, so there's no bikes?

And the last thing about that is code
i++ what actually it does?!Big thanks for the help and don't say anything like go and learn yourself boy.Write what you know about what i asking.
Re: RemovePlayerFromVehicle Doesn't Work ? -
karakana7 - 26.10.2010
I writing this post, because I want that my questions in the previous post would be answered.