Can't removeplayerfromvehicle if not owner
#1

Hey guys, I've been editing the newest release of Cops and Robbers for my server, and I can't get this thing to work, I've learnt a lot about pawno, but I just can't get this to work, could use some help..

Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    GetPlayerLastVehicleID[playerid] = vehicleid;
	new string[150];
	if(!ispassenger)
	{
	    if(IsShopVehicle[vehicleid] != -1)
		{
			if(strcmp(GetName(playerid), VehicleInfo[IsShopVehicle[vehicleid]][vOwner], false))
		    {
		        format(string, sizeof(string), "This vehicle is owned by %s.", VehicleInfo[IsShopVehicle[vehicleid]][vOwner]);
		        SendClientMessage(playerid, RED, string);
		        RemovePlayerFromVehicle(playerid);
		    }
		}
	}
	return 1;
}
It appears to be ok for me, but when someone else enters someone's vehicle, he doesn't get ejected, so he can drive it as if it was his.
What can I do? Is there something wrong?

And the strangest part is that it displays the string ("This vehicle is owned by %s."), it just doesn't eject playerid from the said vehicle..
Reply
#2

I'll give rep if I get helped
Reply
#3

looks wrong
pawn Код:
if(!ispassenger)
need to looks like

pawn Код:
if(!ispassenger(handler))
pawn Код:
if(!ispassenger[handler])
Reply
#4

Quote:
Originally Posted by Ryz
Посмотреть сообщение
looks wrong
pawn Код:
if(!ispassenger)
need to looks like

pawn Код:
if(!ispassenger(handler))
pawn Код:
if(!ispassenger[handler])
ispassenger 0 when player entering vehicle as driver and 1 if player entering vehicle as passenger and dosn't have handler ! Handler is player id… ispassenger() is wrong

Your code is right but you didn't pay attention to one note !
This callback call when player STARTS to enter a vehicle !
You remove player from vehicle when he isn't in vehicle ! Just attempt to enter vehicle !
Please move your code into OnPlayerStateChange and check if new state is driver, then check vehicle owner and if player wasn't owner, remove him from vehicle
Or with OnPlayerEnterVehicle callback you can SetPlayerPos to his position to cancel entering vehicle and NOT Remove him from vehicle
Reply
#5

Thank you very much.
Reply
#6

Quote:
Originally Posted by M4D
Посмотреть сообщение
ispassenger 0 when player entering vehicle as driver and 1 if player entering vehicle as passenger and dosn't have handler ! Handler is player id… ispassenger() is wrong

Your code is right but you didn't pay attention to one note !
This callback call when player STARTS to enter a vehicle !
You remove player from vehicle when he isn't in vehicle ! Just attempt to enter vehicle !
Please move your code into OnPlayerStateChange and check if new state is driver, then check vehicle owner and if player wasn't owner, remove him from vehicle
Or with OnPlayerEnterVehicle callback you can SetPlayerPos to his position to cancel entering vehicle and NOT Remove him from vehicle
aww fu*k i just forgeted that
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)