Making it soo theese cars can only be drove by TEAM_COP
#1

Hello. i have

Код:
new CopCar[18];
and then

Код:
CopCar[0] = AddStaticVehicle(
CopCar[1] = AddStaticVehicle(
CopCar[2] = AddStaticVehicle(
CopCar[3] = AddStaticVehicle(
...
all up to [17]
But then i need something on,
Код:
OnPlayerStateChange
or something i think


But i dont know
i need to make it so
only
Код:
TEAM_COP
can drive the cars :S
Reply
#2

Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
  if(GetVehicleModel(vehicleid) == 520) // replace 520 with the id of the car you want only police to drive
  {
	if(gTeam[playerid] == TEAM_COP) {
    SendClientMessage(playerid, red, "You are police, You needed to be police to drive this car");
  }
		else {
		new Float:px, Float:py, Float:pz;
		SendClientMessage(playerid, red, "You need to be a cop to drive a cop car!.");
	    GetPlayerPos(playerid, px, py, pz);
        SetPlayerPos(playerid, px, py, pz+3);
		}
		}
}
Reply
#3

mm this is now how i need it,

I need it soo
if your not TEAM_COP then it RemovePlayerFromVehicle
and then sends them a message saying, "You need to be a Cop to drive this"
Reply
#4

Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
  if(GetVehicleModel(vehicleid) == 520) // replace 520 with the id of the car you want only police to drive
  {
	if(gTeam[playerid] == TEAM_COP) {
    SendClientMessage(playerid, red, "You are police, You can drive the car!");
  }
		else {
        RemovePlayerFromVehicle(playerid);
        PlayerPlaySound(playerid, 1147, 0.0, 0.0, 0.0);
        SendClientMessage(playerid, COLOR_RED, "You need to be a Cop to drive this!");
		}
		}
}
Reply
#5

This won't work if you're going to use "RemovePlayerFromVehicle" function because OnPlayerEnterVehicle is called every time if player is near the vehicle AND if he presses the enter key, which means he can cancel the entry but callback will get called anyway.

Use this:
pawn Код:
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
SetPlayerPos(playerid, x, y, z);
Reply
#6

Quote:
Originally Posted by Don Correlli
This won't work if you're going to use "RemovePlayerFromVehicle" function because OnPlayerEnterVehicle is called every time if player is near the vehicle AND if he presses the enter key, which means he can cancel the entry but callback will get called anyway.

Use this:
pawn Код:
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
SetPlayerPos(playerid, x, y, z);
i got it at a other place, cause i use it different then him, and i am not that good scripter
but it tryed to help him a little bit
Reply
#7

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new
        vm = GetVehicleModel(vehicleid),
        Float:playerX, Float:playerY, Float:playerZ;
       
    if(vm == 597 || vm == 598 || vm == 599 || vm == 601) // etc ..
    {
        if(gTeam[playerid] != TEAM_COP)
        {
            GetPlayerPos(playerid, playerX, playerY, playerZ);
            SetPlayerPos(playerid, playerX, playerY, playerZ);
            SendClientMessage(playerid, COLOR_RED, " You don't have the keys for this vehicle.");
        }
        else return SendClientMessage(playerid, COLOR_RED, " Welcome back on patrol, officer.");
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)