Hunter only for specific class
#1

Hey guys,


I made a class system with 6 classes.

I want that the "Pilot" class only can drive the Hunter.

Please help me
Reply
#2

What do you mean by "class"? A certain skin? A certain team? A certain group of players?
You can use the callback OnPlayerEnterVehicle which is called as soon as the player starts to get into the animation of entering a vehicle, so when pressing F/Enter. Just ask for which vehicle is being entered by whom and close the vehicle using SetVehicleParamsForPlayer.
Reply
#3

I mean I have 6 classes.

Like Pilot, Engineer etc.

I want that only Pilots can fly hunters!
Reply
#4

pawn Код:
new PlayerClass[MAX_PLAYERS] = CLASS_NONE;
public OnPlayerRequestClass(playerid,classid)
{
    if(classid == CLASS_HUNTER)
    {
    PlayerClass[playerid] = CLASS_HUNTER;
    }

    return 1;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(vehicleid == 426 && PlayerClass[playerid] != CLASS_HUNTER)
        return ClearAnimations(playerid);

    return true;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER && GetVehicleModel(GetPlayerVehicleID(playerid)) == 426 && PlayerClass[playerid] != CLASS_HUNTER)
    {
        RemovePlayerFromVehicle(playerid);
    }

        return true;
}
Adjust this to your script, this is just an example.
Reply
#5

Quote:
Originally Posted by Fantje
Посмотреть сообщение
I mean I have 6 classes.

Like Pilot, Engineer etc.

I want that only Pilots can fly hunters!
Tell me your pilot variable please, and give me the coordinates of the hunters spawning.
Reply
#6

Quote:
Originally Posted by Abagail
Посмотреть сообщение
pawn Код:
new PlayerClass[MAX_PLAYERS] = CLASS_NONE;
public OnPlayerRequestClass(playerid,classid)
{
    if(classid == CLASS_HUNTER)
    {
    PlayerClass[playerid] = CLASS_HUNTER;
    }

    return 1;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(vehicleid == 426 && PlayerClass[playerid] != CLASS_HUNTER)
        return ClearAnimations(playerid);

    return true;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER && GetVehicleModel(GetPlayerVehicleID(playerid)) == 426 && PlayerClass[playerid] != CLASS_HUNTER)
    {
        RemovePlayerFromVehicle(playerid);
    }

        return true;
}
Adjust this to your script, this is just an example.

Thank you but this is not working. I got this error:

PHP код:
array index out of bounds (variable "gPlayerClass"
My line:

PHP код:
if(vehicleid == 426 && gPlayerClass[MAX_PLAYERS] != PILOT
What can i do to fix this?
Reply
#7

gPlayerClass[MAX_PLAYERS]

to

gPlayerClass[playerid]
Reply
#8

Then the code doesn't work.
Reply
#9

Nevermind, the vehicle id was not right
Reply
#10

Quote:
Originally Posted by KevinExec
Посмотреть сообщение
Tell me your pilot variable please, and give me the coordinates of the hunters spawning.
Why'd you even want the coordinates?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)