Locking classes to faction
#1

Hi Guys,

I am creating my own Cops n Robbers Gamemode from scratch and I have some pretty complex, advanced stuff in here but apparently the simple stuff caught me off guard and I've tried 100 different things but nothing seems to work.

So I have a variable which defines which faction a player belongs to...
pawn Код:
//faction defines
#define FAC_CIV 0
#define FAC_POLICE 1
#define FAC_MAFIA 2
#define FAC_RUS_MAFIA 3
#define FAC_AZTEKAS 4
#define FAC_VAGOS 5
#define FAC_BALLAS 6
pawn Код:
PlayerInfo[playerid][pFac] == FAC_POLICE;
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
    //this will set the players faction ID - whether it be 0 for CIV or 1 for Police
    switch(classid)
    {
        case 0..20:
        {
            PlayerInfo[playerid][pFac] = 0;
            GameTextForPlayer(playerid, "~y~CIV", 5000, 5);
            SetPlayerPos(playerid,1697.1034,1402.3219,11.3416);
            SetPlayerFacingAngle(playerid,304.0754);
            SetPlayerCameraPos(playerid,1699.0399,1403.9608,11.4432);
            SetPlayerCameraLookAt(playerid,1697.1034,1402.3219,11.3416);
        }
        case 22..26:
        {
            GameTextForPlayer(playerid, "~b~CIV", 5000, 5);
        }
pawn Код:
public OnPlayerRequestSpawn(playerid)
{
    //used to deny certain spawns depending on points
    switch(GetPlayerSkin(playerid))
    {
        case 0..21:
        {
            SpawnPlayer(playerid);
        }
        case 22..26:
        {
            if(PlayerInfo[playerid][pFac] == FAC_POLICE)
            {
                SpawnPlayer(playerid);
            }
            else
            {
                SendClientMessage(playerid, COLOR_RED, "You're not a police officer!");
                return 0;
            }
        }
        case 27..30:
        {
            if(GetPlayerScore(playerid) > 0)
            {
                SpawnPlayer(playerid);
            }
            else
            {
                SendClientMessage(playerid, COLOR_RED, "You aren't high enough level to join that!");
                return 0;
            }
        }
I have checked the users ini file which saves the variables fine every time ... and the PlayerInfo[playerid][pFac] variable is 0 (meaning civ, and shouldn't be able to spawn as police)

Ignore the mess or missing entries etc with nothing in the cases, I am just testing it out at the moment. Then i will complete.

Please could someone just help me out here. I know this is simple, and I've done it before about 4 years ago when i used to script pawn.

Thanks in advance
Reply
#2

Good
Reply
#3

Quote:
Originally Posted by Wary
Посмотреть сообщение
Good
Not quite sure I understand
Reply
#4

I guess here is the problem

PlayerInfo[playerid][pFac] == FAC_POLICE;

should be

PlayerInfo[playerid][pFac] = FAC_POLICE;

2 equal ( == ) used in If statements.
1 equal used to set a var. equal to a value



Pss Rep if this helped you
Reply
#5

Quote:
Originally Posted by mongi
Посмотреть сообщение
I guess here is the problem

PlayerInfo[playerid][pFac] == FAC_POLICE;

should be

PlayerInfo[playerid][pFac] = FAC_POLICE;

2 equal ( == ) used in If statements.
1 equal used to set a var. equal to a value



Pss Rep if this was helped you
Yeah I already know that. The 2 equals actually got copied off an if statement in the code i've got... and 2 == signs in a variable will throw an error. I got no error, so that's definitely not it.

Thank you for your input though, really appreciated

+rep for trying
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)