Player does not get kicked out of a vehicle
#1

PHP код:
public OnPlayerEnterVehicle(playeridvehicleidispassenger)
{
    new 
model GetVehicleModel(vehicleid);
    if(
model == 541)
    {
    if (
GetPlayerSkin(playerid) != ) 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?
Reply
#2

Solved, got it to work with OnPlayerStateChange. Please lock this.
Reply
#3

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

Yeah, I noticed that and I fixed it, already got it to work before, thanks for the help though, greatly appreciated!
Reply
#5

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) != || 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.
Reply
#6

Use that one below:

http://pastebin.com/8cysfrLg
Reply
#7

Quote:
Originally Posted by Emre__
Посмотреть сообщение
Use that one below:

http://pastebin.com/8cysfrLg
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.
Reply
#8

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
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)