SA-MP Forums Archive
Help with restricted 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: Help with restricted Class (/showthread.php?tid=286776)



Help with restricted Class - Azzeto - 30.09.2011

I want to make one class on my gangwar TDM to be for admins only I have the class set up and everything as class ID 4. Now I looked at the wiki for OnPlayerRequestSpawn so I could figure out how to not let them spawn if they werent admin,
pawn Code:
public OnPlayerRequestSpawn(playerid)
{
    if(!IsPlayerAdmin(playerid))
    {
        SendClientMessage(playerid,COLOR_GREEN,"You may not spawn.");
        return 0;
    }
    return 1;
}
is the code from the wiki, Where the "if(!IsPlayerAdmin(playerid)) how would I put it to check if they were on class id 4? And if they were admin? please help ASAP

pawn Code:
if(classid == 4) && if(PlayerInfo[playerid][pAdmin] > 1)



Re: Help with restricted Class - Jafet_Macario - 30.09.2011

pawn Code:
if(classid == 4 && IsPlayerAdmin(playerid))
{
    // Do your code
}



Re: Help with restricted Class - Azzeto - 30.09.2011

will the IsPlayerAdmin(playerid)) doesnt that check if their RCON admin? I need it to read from there player file.


Re: Help with restricted Class - Jafet_Macario - 30.09.2011

Well if you have the thing you posted above: PlayerInfo[playerid][pAdmin]
pawn Code:
if(classid == 4 && PlayerInfo[playerid][pAdmin] > 1)
{
    // Do your code
}



Re: Help with restricted Class - Azzeto - 30.09.2011

pawn Code:
Return 0; would stop them from spawning right? thats what the wiki said, so I put my code as
new classid;
if(classid == 4 && PlayerInfo[playerid][pAdmin] > 1)
{
    return 0;
}
and I set my admin level to 0 and now I can still spawn with that class?


Re: Help with restricted Class - Jafet_Macario - 30.09.2011

pawn Code:
if(classid == 4 && PlayerInfo[playerid][pAdmin] < 1)
{
    return 0;
}
If classid is 4, and the player admin level is 0, he can't spawn with that.


Re: Help with restricted Class - Azzeto - 30.09.2011

Thanks for the help, repped, Ill just put it so it'll kick them if they're not admin.


Re: Help with restricted Class - Jafet_Macario - 30.09.2011

Check my edit please.


Re: Help with restricted Class - DRIFT_HUNTER - 30.09.2011

pawn Code:
new AllowedToSpawn[MAX_PLAYERS];

public OnPlayerRequestClass(playerid, classid)
{
    AllowedToSpawn[playerid] = 0;
    if(classid == 4 && PlayerInfo[playerid][pAdmin] < 1)
    {
        AllowedToSpawn[playerid] = 0;
        return 0;
    }
    return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    if(AllowedToSpawn[playerid] == 0)
    {
        SendClientMessage(playerid,COLOR_GREEN,"You may not spawn.");
        return 0;
    }
    return 1;
}
OnPlayerConnect and disconnect add AllowedToSpawn[playerid] = 1;