Help with restricted Class
#1

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)
Reply
#2

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

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

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

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?
Reply
#6

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.
Reply
#7

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

Check my edit please.
Reply
#9

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;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)