09.01.2013, 11:18
Hello, I was wondering if anyone could show me & explain a simple code for Restricted vehicle to name?
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
new Pname[24];
GetPlayerName(playerid, Pname, 24);
if(vehicleid == /*The certain vehicle ID you want to restrict*/ && strcmp(Pname, /*Name you want to restrict the car to*/, true) && ispassenger == 0)
{
new Float:Pos[3];
GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
SetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
}
return 1;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
new Pname[24];
GetPlayerName(playerid, Pname, 24);
if(vehicleid == /*The certain vehicle ID you want to restrict*/ && strcmp(Pname, "Oggy_Wilson", true) && ispassenger == 0)
{
new Float:Pos[3];
GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
SetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
}
else
{
SendClientMessage(playerid, COLOR_RED, "You are not allowed to access this vehicle."):
}
return 1;
}
pawn Код:
|
I meant like that vehicle only, not all vehicle's those are spawn'd with same ID should be restricted.. |
new Abracafuckingdabra; // this will be id of your vehicle
// on game mode
Abracafuckingdabra = createvehicle(.....);
// later on you can use it
if(vehicleid == Abracafuckingdabra, true) && ispassenger == 0)
{
// code
goto this tutorial, it will help you make it a private vehicle.
http://www.youtube.com/watch?v=WBhxR...-lq2-hq-vhq-hd |
new myvehicle; //this is the car you want to restrict
public OnGameModeInit() //this is where you create the goddamn vehicle
{
myvehicle = CreateVehicle(... //This is where you create your vehicle at your coordinates
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER) //They entered a car as a driver
{
if(GetPlayerVehicleID(playerid) == myvehicle) //If the car they entered is the car you created
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME); //Get their name
if(strcmp(name, "Oggy_Winston", false) != 0) //If their name isn't Oggy Winston
{
SendClientMessage(playerid, 0xFF0000FF, "This car is restricted to 'Oggy_Winston' and you cannot use it.");
RemovePlayerFromVehicle(playerid);
}
}
}
return 1;
}