RemovePlayerFromVehicle Doesn't Work ?
#1

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
Reply
#2

Probably you doing something wrong.. What about showing us some code ?
Reply
#3

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.
Reply
#4

change playerid to i
Reply
#5

Quote:
Originally Posted by xPawn
Посмотреть сообщение
change playerid to i
Doesn't Work
Reply
#6

Under what callback are you using it? If it's custom, when and how is it called?
Reply
#7

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;
}
Reply
#8

Quote:
Originally Posted by xPawn
Посмотреть сообщение
change playerid to i
You don't even know what you are saying..

Does the text appear?
Reply
#9

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
Reply
#10

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
Reply
#11

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].
Reply
#12

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
Reply
#13

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!
Reply
#14

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.
Reply
#15

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.
Reply
#16

OnPlayerKeyStateChange?
Reply
#17

Quote:
Originally Posted by BMUK
Посмотреть сообщение
OnPlayerKeyStateChange?
Lol.. he confused.. better use my code xD
Reply
#18

Well, Thank you guys, Its Working!
Reply
#19

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.
Reply
#20

I writing this post, because I want that my questions in the previous post would be answered.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)