Only i can drive a car - 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: Only i can drive a car (
/showthread.php?tid=431763)
Only i can drive a car -
smiljun123 - 19.04.2013
Hello i need help or tutorial, I just wanna make that I can only drive car and nobody else!
I want some cars front of my haouse if somebody else sit in the car, then kust eject him from car

TnX sry for my english
Re: Only i can drive a car -
zDivine - 19.04.2013
Top of script:
Under OnGameModeInit() or OnFilterScriptInit():
pawn Код:
myCar = CreateVehicle(Parameters here);
Under OnPlayerEnterVehicle() or OnPlayerStateChange()
OnPlayerEnterVehicle()
pawn Код:
if(strcmp(sendername, "YOUR_NAME_HERE", false) == 0) // Replace your in game name with "YOUR_NAME_HERE".
{
if(!ispassenger && vehicleid == myCar)
{
new Float: x, Float: y, Float: z;
GetPlayerPos(playerid, x, y, z); // I grab his position and set it to what it was because...
SetPlayerPos(playerid, x, y, z); // RemovePlayerFromVehicle() doesn't function properly in this.
SendClientMessage(playerid, -1, "This car is off limits.");
}
}
OnPlayerStateChange()
pawn Код:
if(oldstate == PLAYER_STATE_ONFOOD && newstate == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(vehicleid == myCar)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, -1, "This car is off limits.");
}
}