[HELP] Ranks connected to cars?
#1

Hello Again...
I've seen on RPG server, if you are a Cadet, and tries to get into a Cop Car, you gets kicked from the car, and a message pops up and says, you are not in blah blah rank...

How can I do that
Reply
#2

Quote:
Originally Posted by ByFukara
use onplayerentervehicle
I've never done this before, can you like, describe how and what I should put in there

Btw, I'm using ranks like this:

Код:
if(PlayerInfo[playerid][pRank] >= 1)
If it gets easiter for you to explain
Reply
#3

use dini
Reply
#4

Quote:
Originally Posted by ByFukara
use dini
Still no Succes...
Reply
#5

It's Very simple. Try this:

pawn Код:
public OnPlayerStateChange(playerid,newstate,oldstate)
{
    new carid;
    carid = GetVehicleModel(GetPlayerVehicleID(playerid));
    if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    {
        if(IsCopCar(carid) && PlayerInfo[playerid][pRank] >= 1) // If Player Enters any Cop Car and is Ranked 1 or less
        {
            SendClientMessage(playerid, 0xFF0000AA, "You cannot use this Vehicle, You need to be above Level 1 - Ejected");
            RemovePlayerFromVehicle(playerid);
        }
    }
    return 1;
}
You'll need to also add Andre's IsCopCar function as well:

pawn Код:
stock IsCopCar(carid)
{
  new Operative[] = { 523, 427, 490, 528, 596, 597, 598, 599 };
  for(new i = 0; i < sizeof(Operative); i++)
  {
    if(GetVehicleModel(carid) == Operative[i]) return 1;
  }
  return 0;
}
Untested.

EDIT: It will stop anyone who enters a cop car and is ranked 1 or less to be ejected. This is not what you want looking at ur original post. I used the variable you gave only for the player ranks. If you want just add/ change the rank to check if the player's not a cop.
Reply
#6

Quote:
Originally Posted by [B2K
Hustler ]
It's Very simple. Try this:

pawn Код:
public OnPlayerStateChange(playerid,newstate,oldstate)
{
    new carid;
    carid = GetVehicleModel(GetPlayerVehicleID(playerid));
    if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    {
        if(IsCopCar(carid) && PlayerInfo[playerid][pRank] >= 1) // If Player Enters any Cop Car and is Ranked 1 or less
        {
            SendClientMessage(playerid, 0xFF0000AA, "You cannot use this Vehicle, You need to be above Level 1 - Ejected");
            RemovePlayerFromVehicle(playerid);
        }
    }
    return 1;
}
You'll need to also add Andre's IsCopCar function as well:

pawn Код:
stock IsCopCar(carid)
{
  new Operative[] = { 523, 427, 490, 528, 596, 597, 598, 599 };
  for(new i = 0; i < sizeof(Operative); i++)
  {
    if(GetVehicleModel(carid) == Operative[i]) return 1;
  }
  return 0;
}
Untested.

EDIT: It will stop anyone who enters a cop car and is ranked 1 or less to be ejected. This is not what you want looking at ur original post. I used the variable you gave only for the player ranks. If you want just add/ change the rank to check if the player's not a cop.
I get no errors, but it have no effect, Cadets can still drive the PD cars...
Reply
#7

That's why i said that what i gave just checks the player's rank because that's all you gave. What variable do u use to identify whether the player is a 'cadet'? Or Even better, if you don't wany any NON-COP players to enter cop cars give the variable that identifies whether the player's a cop.
Reply
#8

Quote:
Originally Posted by [B2K
Hustler ]
That's why i said that what i gave just checks the player's rank because that's all you gave. What variable do u use to identify whether the player is a 'cadet'? Or Even better, if you don't wany any NON-COP players to enter cop cars give the variable that identifies whether the player's a cop.
I have maked a Rank system, only for cops, I mean, that's the only rank system I got on my script, for the cops, so, if non-cops or cadets, got rank 0, they cant use any cop cmd, they just gets that message, blah blah rank.
I want it like this on the cop cars and they will just get kicked out from the car...
Reply
#9

well as far as i can see it should kick you out of a cop vehicle if you have a rank of 1 or less. Either you are testing it out whilst you have a 2+ rank and/or you didn't enter a cop car, or cadets acutually have 2+ ranks, or maybe i've overlooked something - someone else may see a problem.

EDIT: I think the code might have been wrong, as it gets the player's vehicle model before the player enters the vehicle. Try this:
pawn Код:
public OnPlayerStateChange(playerid,newstate,oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    {
        new carid;
        carid = GetVehicleModel(GetPlayerVehicleID(playerid));
        if(IsCopCar(carid) && PlayerInfo[playerid][pRank] >= 1) // If Player Enters any Cop Car and is Ranked 1 or less
        {
            SendClientMessage(playerid, 0xFF0000AA, "You cannot use this Vehicle, You need to be above Level 1 - Ejected");
            RemovePlayerFromVehicle(playerid);
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)