Protecting Vehicles Based On Skins
#1

I'm trying to protect some military vehicles so that only people with skin 286 and 287 may use them. They're assorted vehicles with id's 49 through 69. I can't seem to find a way to protect each of the vehicles. Thanks for any help.
Reply
#2

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        new playersVehicle = GetPlayerVehicleID(playerid), playersSkin = GetPlayerSkin(playerid);
        if(48 < playersVehicle < 70 && playersSkin != 286 && playersSkin != 287)
        {
            RemovePlayerFromVehicle(playerid);
            return SendClientMessage(playerid, -1, "You are not part of the military.");
        }
    }

    return 1;
}
Reply
#3

It has no effect, yet no errors. Is there something I'm doing wrong here? I used your condition. And for the record, I already tried it without my removeswitch variable.

Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{

	new playersVehicle = GetPlayerVehicleID(playerid), playersSkin = GetPlayerSkin(playerid);
	if(48 < playersVehicle < 70 && playersSkin != 286 && playersSkin != 287)
	{
	    removeswitch[playerid] = 1;
	    SendClientMessage(playerid,COLOR_RED,"LEAVE THIS VEHICLE ALONE!");
	}
	return 1;
}
Reply
#4

Quote:
Originally Posted by SuperViper
Посмотреть сообщение
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        new playersVehicle = GetPlayerVehicleID(playerid), playersSkin = GetPlayerSkin(playerid);
        if(48 < playersVehicle < 70 && playersSkin != 286 && playersSkin != 287)
        {
            RemovePlayerFromVehicle(playerid);
            return SendClientMessage(playerid, -1, "You are not part of the military.");
        }
    }

    return 1;
}
His show you to use " public OnPlayerStateChange " not "OnPlayerEnterVehicle"
If you whana use OnPlayerEnterVehicle you must set timer of 3000 milliseconds from point player start
entering car pass 3sek till he is in car.
Reply
#5

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    new playersVehicle = GetPlayerVehicleID(playerid), playersSkin = GetPlayerSkin(playerid);
    if(48 < playersVehicle < 70 && (playersSkin != 286 || playersSkin != 287))
    {
        SendClientMessage(playerid,COLOR_RED,"LEAVE THIS VEHICLE ALONE!");
        RemovePlayerFromVehicle(playerid);
    }
    return 1;
}
edit: opps, forgot something.. try it now
Reply
#6

Quote:
Originally Posted by Dennis_Smith
Посмотреть сообщение
It has no effect, yet no errors. Is there something I'm doing wrong here? I used your condition. And for the record, I already tried it without my removeswitch variable.

Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{

	new playersVehicle = GetPlayerVehicleID(playerid), playersSkin = GetPlayerSkin(playerid);
	if(48 < playersVehicle < 70 && playersSkin != 286 && playersSkin != 287)
	{
	    removeswitch[playerid] = 1;
	    SendClientMessage(playerid,COLOR_RED,"LEAVE THIS VEHICLE ALONE!");
	}
	return 1;
}
If you're gonna use it in OnPlayerEnterVehicle, replace playersVehicle with vehicleid.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)