how to make a kind of car admin only
#1

i want to make a car ( hustler with hydraulics and twist rims ) for admins only how to do make them admin only even if they tp to them they cant get in even with hacks and if they in it with hacks that they will be auto kicked? i searched but cant find it.
Reply
#2

1.) OnPlayerEnterVehicle
2.) GetPlayerVehicleModel
3.) if(model == ADMINCAR)
4.) RemovePlayerFromVehicle
Reply
#3

Quote:
Originally Posted by Mo3
1.) OnPlayerEnterVehicle
2.) GetPlayerVehicleModel
3.) if(model == ADMINCAR)
4.) RemovePlayerFromVehicle
ty, but i cant find the right code? and those lines are my cars:
Код:
	AddStaticVehicle(545,-2237.8757,-1712.4080,480.6812,188.3410,44,96); // admincar10
	AddStaticVehicle(545,-2237.0417,-1718.1138,480.6796,188.2534,44,96); // admincar12
	AddStaticVehicle(545,-2236.3730,-1723.5104,480.6723,187.3156,44,96); // admincar13
	AddStaticVehicle(545,-2235.7861,-1728.0155,480.6618,187.4335,44,96); // admincar14
	AddStaticVehicle(545,-2231.8418,-1738.1964,480.9620,218.0235,44,96); // admincar15
	AddStaticVehicle(545,-2235.1506,-1740.0599,480.6364,216.1143,44,96); // admincar16
	AddStaticVehicle(545,-2238.9924,-1746.1462,480.6679,212.2924,44,96); // admincar17
i dont have more static cars etc.
i got it under public OnFilterScriptInit()
But i dont know how to make them to admin onlycars so if an player can go in it they need to respawn, die or be kicked.
if they trie to get in with F or Enter that its locked or that they cant get in, can somebody help me? with a starting piece of the code? i want to do a part by myself
Reply
#4

Quote:
Originally Posted by Mo3
1.) OnPlayerEnterVehicle
2.) GetPlayerVehicleModel
3.) if(model == ADMINCAR)
4.) RemovePlayerFromVehicle
It won't work if you're going to use RemovePlayerFromVehicle function at OnPlayerEnterVehicle callback because OnPlayerEnterVehicle callback is called when player is trying to enter the vehicle, so you can't remove him if he isn't in.
I would suggest you to use OnPlayerStateChange callback in which you would check if the old state is on foot and if the new state is driver/passenger.
But you could also use SetPlayerPos function with OnPlayerEnterVehicle in which you would get the player's current position and set it to that position.
And GetPlayerVehicleModel doesn't exist, it's GetVehicleModel.
Reply
#5

Quote:
Originally Posted by Don Correlli
Quote:
Originally Posted by Mo3
1.) OnPlayerEnterVehicle
2.) GetPlayerVehicleModel
3.) if(model == ADMINCAR)
4.) RemovePlayerFromVehicle
It won't work if you're going to use RemovePlayerFromVehicle function at OnPlayerEnterVehicle callback because OnPlayerEnterVehicle callback is called when player is trying to enter the vehicle, so you can't remove him if he isn't in.
I would suggest you to use OnPlayerStateChange callback in which you would check if the old state is on foot and if the new state is driver/passenger.
But you could also use SetPlayerPos function with OnPlayerEnterVehicle in which you would get the player's current position and set it to that position.
And GetPlayerVehicleModel doesn't exist, it's GetVehicleModel.
could you make a part of the code so i got a begin otherwish i cant make a start...
Reply
#6

pawn Код:
new
    myVehicle;

public OnGameModeInit()
{
  myVehicle = CreateVehicle(...);
  return true;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
  if(oldstate == PLAYER_STATE_ONFOOT && (newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER))
  {
    new
        vehicleID;
    vehicleID = GetPlayerVehicleID(playerid);
    if(GetVehicleModel(vehicleID) == myVehicle) RemovePlayerFromVehicle(playerid);
  }
  return true;
}
This should do it.
Reply
#7

return true is that return 1 or 0? like return 1; or return 0;
Reply
#8

true stands for 1 and false stands for 0.
Reply
#9

Quote:
Originally Posted by Don Correlli
true stands for 1 and false stands for 0.
ty, and i get error:

Код:
maps/.../admin.pwn(42) : error 029: invalid expression, assumed zero
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase

1 Error.
edit 1;
nvm... found it

edit 2: i changed myVehicle = CreateVehicle(...); to myVehicle = CreateVehicle(545,-2237.8757,-1712.4080,480.6812,188.3410,44,96); // admincar10 and now i got the warning:
Код:
\admin.pwn(42) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Warning.
Reply
#10

pawn Код:
myVehicle = CreateVehicle(...);
This was just an example, put your own modelID, coordinations, ..

Edit: You forgot the respawn delay.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)