Player does not get kicked out of a vehicle -
69 - 02.11.2012
PHP код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
new model = GetVehicleModel(vehicleid);
if(model == 541)
{
if (GetPlayerSkin(playerid) != 0 ) return SendClientMessage(playerid, -1, "You may not drive this vehicle!")|| RemovePlayerFromVehicle(playerid);
}
return 1;
}
If a player does not have skin 0, he shouldn't be able to enter vehicle ID 541. But when that happens, he gets the "you may not drive this vehicle" but he does not get kicked as the text shows at the instant the player presses F.
How to make this work?
Re : Player does not get kicked out of a vehicle -
69 - 02.11.2012
Solved, got it to work with OnPlayerStateChange. Please lock this.
Re: Player does not get kicked out of a vehicle -
[KHK]Khalid - 02.11.2012
This is not how the operator || is used (To know how,
click me). You should of used "," instead of it if you wanna save lines, like this:
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
new model = GetVehicleModel(vehicleid);
if(model == 541)
{
if (GetPlayerSkin(playerid) != 0 ) return SendClientMessage(playerid, -1, "You may not drive this vehicle!"), RemovePlayerFromVehicle(playerid);
}
return 1;
}
But, this still won't work because you're using RemovePlayerFromVehicle under OnPlayerEnterVehicle which is called before a player enters a vehicle (Actually as soon as they press RETURN), so RemovePlayerFromVehicle won't have effects as the player hasn't entered the vehicle yet. If I were you, I'd do it this way:
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
new model = GetVehicleModel(vehicleid);
if(model == 541)
{
if (GetPlayerSkin(playerid) != 0 )
{
SendClientMessage(playerid, -1, "You may not drive this vehicle!");
TogglePlayerControllable(playerid, false); // freezes the player
TogglePlayerControllable(playerid, true); // then unfreezes him, which will cause him to stop the entering animation (and won't enter the vehicle)
return 1;
}
}
return 1;
}
Re : Player does not get kicked out of a vehicle -
69 - 02.11.2012
Yeah, I noticed that and I fixed it, already got it to work before, thanks for the help though, greatly appreciated!
Re : Player does not get kicked out of a vehicle -
69 - 03.11.2012
Right, I need more help.
I want to make a vehicle accessible to two skins, but when I have this for example:
PHP код:
if(GetPlayerSkin(playerid) != 0 || 1)
it doesn't let neither of the skins enter the vehicle. It just kicks both.
Help please.
EDIT: Testing with &&, standby.
EDIT: && doesn't work.
Re: Player does not get kicked out of a vehicle -
Emre__ - 03.11.2012
Use that one below:
http://pastebin.com/8cysfrLg
Re : Re: Player does not get kicked out of a vehicle -
69 - 03.11.2012
Quote:
Originally Posted by Emre__
|
Would be awesome if you tried not to take profit from these forums, and it would be even more awesome if you read the full topic before posting. I have -another- querie and the querie on the main post was solved.
Re: Player does not get kicked out of a vehicle -
iggy1 - 03.11.2012
The OR operator does not work like that, both expressions require an operand.
pawn Код:
new skinid = GetPlayerSkin(playerid);
if( skin != 0 || skin != 1 )
{
//if the players skinid is NOT 0 or 1 this will be executed
}
else
{
//if the players skinid IS 0 or 1 this will be executed
}