SA-MP Forums Archive
Hunter only for specific class - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Hunter only for specific class (/showthread.php?tid=606254)



Hunter only for specific class - Fantje - 01.05.2016

Hey guys,


I made a class system with 6 classes.

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

Please help me


Re: Hunter only for specific class - Manyula - 01.05.2016

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.


Re: Hunter only for specific class - Fantje - 01.05.2016

I mean I have 6 classes.

Like Pilot, Engineer etc.

I want that only Pilots can fly hunters!


Re: Hunter only for specific class - Abagail - 01.05.2016

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.


Re: Hunter only for specific class - iKevin - 01.05.2016

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.


Re: Hunter only for specific class - Fantje - 02.05.2016

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?


Re: Hunter only for specific class - itsCody - 02.05.2016

gPlayerClass[MAX_PLAYERS]

to

gPlayerClass[playerid]


Re: Hunter only for specific class - Fantje - 02.05.2016

Then the code doesn't work.


Re: Hunter only for specific class - Fantje - 02.05.2016

Nevermind, the vehicle id was not right


Re: Hunter only for specific class - Ritzy2K - 02.05.2016

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?