I need some help with Restricted Vehicle to a Name. -
Desi_Dude - 09.01.2013
Hello, I was wondering if anyone could show me & explain a simple code for
Restricted vehicle to name?
Re: I need some help with Restricted Vehicle to a Name. -
denNorske - 09.01.2013
Do you mean, a vehicle which is not available for a given name on the server ?
Re: I need some help with Restricted Vehicle to a Name. -
azzerking - 09.01.2013
pawn Код:
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;
}
that should work
Re: I need some help with Restricted Vehicle to a Name. -
Desi_Dude - 09.01.2013
I mean like , suppose there is a player named
Oggy_Winston only he can drive that vehicle which is marked as restricted , others would recieve a error saying that | This vehicle is restricted to
Oggy_Winston and they would be removed from the vehicle.
Re: I need some help with Restricted Vehicle to a Name. -
azzerking - 09.01.2013
pawn Код:
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;
}
That will fix it, just replace the values with the right ones.
Re: I need some help with Restricted Vehicle to a Name. -
Desi_Dude - 09.01.2013
Quote:
Originally Posted by azzerking
pawn Код:
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; }
|
Sorry for double post , but mate that isn't what i had in mind xD
I meant like that vehicle only, not all vehicle's those are spawn'd with same ID should be restricted..
Thanks for the reply tho .
Re: I need some help with Restricted Vehicle to a Name. -
gDarius - 09.01.2013
Quote:
I meant like that vehicle only, not all vehicle's those are spawn'd with same ID should be restricted..
|
Hi,
assigning vehicles to variables will easy it up for you to use them later on.
Example:
pawn Код:
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
Re: I need some help with Restricted Vehicle to a Name. -
azzerking - 09.01.2013
goto this tutorial, it will help you make it a private vehicle.
http://www.youtube.com/watch?v=WBhxR...-lq2-hq-vhq-hd
Re: I need some help with Restricted Vehicle to a Name. -
Desi_Dude - 11.01.2013
Quote:
Originally Posted by azzerking
|
Well,I'm not asking for a private vehicle system, Just asking for restricted vehicle system in which , Only that specific person can sit in.if that car is created at that co-ordinates.
I need someone to explain and show me a example ..
Re: I need some help with Restricted Vehicle to a Name. -
Threshold - 11.01.2013
Oh for christ sakes... let's all repeat ourselves twelve times then...
pawn Код:
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;
}
See these functions:
https://sampwiki.blast.hk/wiki/RemovePlayerFromVehicle
https://sampwiki.blast.hk/wiki/GetPlayerName
https://sampwiki.blast.hk/wiki/CreateVehicle