Lock a car and Lock Skin for specific player
#1

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?
Reply
#2

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.
Reply
#3

RemovePlayerFromVehicle wont work in OnPlayerEnterVehicle

Just use OnPlayerStateChange and the state PLAYER_STATE_DRIVER
Reply
#4

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

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

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

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

So can someone teach me how to do this
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)