SA-MP Forums Archive
Lock a car and Lock Skin for specific player - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Lock a car and Lock Skin for specific player (/showthread.php?tid=275762)



Lock a car and Lock Skin for specific player - Rabbayazza - 11.08.2011

Okay, say theres a player named "Robert" and we want to make a car that only "Robert" can drive, all others get a message saying this is roberts car, or a skin that only Robert can use, with others dying if they try to spawn as it. How do I do this?


Re: Lock a car and Lock Skin for specific player - Scenario - 11.08.2011

Go read the forum rules. Bumping your thread within 24 hours from the last post can result in an infraction!

You need to create a variable which saves the vehicle ID that only "Robert" can drive. You can use this callback to run a check to see if the vehicle ID matches the one which is restricted to "Robert." If it is, check the player's name and see if it matches "Robert's." If it does, then return 1 and leave it alone; otherwise you can send them a message and kick them from the vehicle using this function.


AW: Lock a car and Lock Skin for specific player - Nero_3D - 11.08.2011

RemovePlayerFromVehicle wont work in OnPlayerEnterVehicle

Just use OnPlayerStateChange and the state PLAYER_STATE_DRIVER


Re: Lock a car and Lock Skin for specific player - Rabbayazza - 11.08.2011

... I don't understand what any of you just said.. I can't script anything myself.. help.


Re: AW: Lock a car and Lock Skin for specific player - SchurmanCQC - 11.08.2011

Quote:
Originally Posted by Nero_3D
View Post
RemovePlayerFromVehicle wont work in OnPlayerEnterVehicle

Just use OnPlayerStateChange and the state PLAYER_STATE_DRIVER
+rep, I was going to reply with this same message until I saw you posted it.


Re: Lock a car and Lock Skin for specific player - Rabbayazza - 11.08.2011

Someone teach me how to do this or give me a tutorial link.. I don't know how to do all these functions.


Re: AW: Lock a car and Lock Skin for specific player - Scenario - 11.08.2011

Quote:
Originally Posted by Nero_3D
View Post
RemovePlayerFromVehicle wont work in OnPlayerEnterVehicle

Just use OnPlayerStateChange and the state PLAYER_STATE_DRIVER
Oh yeah... I forgot. Sorry about that!

EDIT: This code should work for you. There is a new variable at the top, learn where it goes.

pawn Code:
new iRVehicle; // This needs to be the vehicle ID of "Robert's" vehicle.

public OnPlayerStateChange(playerid,newstate,oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        if(GetPlayerVehicleID(playerid) == iRVehicle))
        {
            new szName[MAX_PLAYER_NAME];
            GetPlayerName(playerid, szName, sizeof(szName));
            if(!strcmp(szName, "Robert", false)) return 1;
            else RemovePlayerFromVehicle(playerid, GetPlayerVehicleID(playerid)), SendClientMessage(playerid, 0xFFFFFFFF, "GET THE FUCK OUT!!! THIS VEHICLE BELONGS TO ROBERT!!!");
        }
    }
    return 1;
}



Re: Lock a car and Lock Skin for specific player - Rabbayazza - 11.08.2011

So can someone teach me how to do this