Protecting Vehicles Based On Skins - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Protecting Vehicles Based On Skins (
/showthread.php?tid=393354)
Protecting Vehicles Based On Skins -
Dennis_Smith - 18.11.2012
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.
Re: Protecting Vehicles Based On Skins -
SuperViper - 18.11.2012
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;
}
Re: Protecting Vehicles Based On Skins -
Dennis_Smith - 18.11.2012
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;
}
Re: Protecting Vehicles Based On Skins -
Azazelo - 18.11.2012
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.
Re: Protecting Vehicles Based On Skins -
mastermax7777 - 18.11.2012
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
Re: Protecting Vehicles Based On Skins -
SuperViper - 18.11.2012
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.