GetPlayerAdminRank
#10

Quote:
Originally Posted by Sjn
Посмотреть сообщение
It is because you are assigning admin rank 1 to the place where your variable returns 0 which should be player.

You need to do something like this instead.

PHP код:
stock GetPlayerAdminRank(playerid)
{
    new 
level[64];
    switch (
PlayerInfo[playerid][pAdministrator])
    {
        case 
0level "{FF0000}Player";
        case 
1level "{FF0000}Admin I{FFFFFF}";
        case 
2level "{FF0000}Admin II{FFFFFF}";
        case 
3level "{FF0000}Admin III{FFFFFF}";
        case 
4level "{FF0000}Direktor{FFFFFF}";
        case 
5level "{FF0000}Vlasnik{FFFFFF}";
    }
    return 
level;

Your variable starts counting from 0 so you have to assign something with like like null or whatever, i have set it Player cause players have no level.
Switch doesnt "count" them. Switch goes straight to assigned value.

PHP код:
MyFunction(playerid) {
    new 
switchid 2;
    switch(
switchid) {
        case 
0: print("Hi");
        case 
1: print("Hi"); 
        case 
2: print("Hi"); // jumps to case 2 straight away.
    
}
    return 
true;
}
MyFunction(playerid) {
    new 
switchid 2;
    if(
switchid == 0) return print("Hi"); //checks
    
else if(switchid == 1) return print("Hi"); //checks
    
else if(switchid == 2) return print("Hi"); //checks
    
return true;

If you want to check if they are not any of that.
PHP код:
MyFunction(playerid) {
    new 
switchid 2;
    switch(
switchid) {
        case 
1: print("Hi");
        case 
2: print("Hi"); // jumps to case 2 straight away.
        
default: print("Not 1 or 2"); //if it isnt 1-2
    
}
    return 
true;

Therefore imagine that 0 doesnt represent anything. You are correct in 1 way, he should have default value incase they are above 5 or bellow 1. But defining just case 0 would be plain dumb just because there is no usage at all for him.

PHP код:
stock GetPlayerAdminRank(playerid)
{
    new 
level[64];
    switch (
PlayerInfo[playerid][pAdministrator])
    {
        case 
1level "{FF0000}Admin I{FFFFFF}";
        case 
2level "{FF0000}Admin II{FFFFFF}";
        case 
3level "{FF0000}Admin III{FFFFFF}";
        case 
4level "{FF0000}Direktor{FFFFFF}";
        case 
5level "{FF0000}Vlasnik{FFFFFF}";
        default: 
level "Player";
    }
    return 
level;

Reply


Messages In This Thread
GetPlayerAdminRank - by NoDi522 - 13.12.2015, 16:57
Re: GetPlayerAdminRank - by ATGOggy - 13.12.2015, 17:04
Re: GetPlayerAdminRank - by TwinkiDaBoss - 13.12.2015, 17:13
Re: GetPlayerAdminRank - by NoDi522 - 13.12.2015, 17:20
Re: GetPlayerAdminRank - by NoDi522 - 13.12.2015, 17:24
Re: GetPlayerAdminRank - by TwinkiDaBoss - 13.12.2015, 17:27
Re: GetPlayerAdminRank - by NoDi522 - 13.12.2015, 17:35
Re: GetPlayerAdminRank - by TwinkiDaBoss - 13.12.2015, 17:41
Re: GetPlayerAdminRank - by Sjn - 13.12.2015, 17:42
Re: GetPlayerAdminRank - by TwinkiDaBoss - 13.12.2015, 17:47

Forum Jump:


Users browsing this thread: 1 Guest(s)