Can You Improve This Code?
#1

I am Wanting To Know If Anyone Can Improve This Code or can tell me if its a good code.
(this does not include changing if(strcmp(cmdtext,"/vcmds",true) == 0))
Code:
pawn Код:
if(strcmp(cmdtext,"/vcmds",true) == 0)
    {
       if(IsPlayerVipType(playerid,1)) {
            SendClientMessage(playerid,red,"[_____________San Andreas MultiPlayGround VIP Player Commands_____________]");
            SendClientMessage(playerid,green,"Silver: /afk, /back, /f - Flips You Car");
            if(IsPlayerVipType(playerid,2)) {
                SendClientMessage(playerid,green,"Gold: /heal, /armor, /vr - Repairs Your Vehicle");
                if(IsPlayerVipType(playerid,3)) {
                    SendClientMessage(playerid,green,"Preimum: /vpgod,");
                }
            }
        }
        else SendClientMessage(playerid,red,"Only Vip's Can Use This Command");
        return 1;
    }
Reply
#2

That code is perfectly fine, and personally, can't see any way of improving it. (Besides using ZCMD, and calling the variable directly (assuming that's what IsPlayerVIPType does))

At the below reply, it is true you could use the switch statement. However, how much better it would be, with the limited amount of code, is very minimal.
Reply
#3

you just can do something like this

pawn Код:
YCMD:ahelp(playerid, params[], help)
{
    #pragma unused help
    #pragma unused params
    if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdmin] >= 1)
    {
        switch(PlayerInfo[playerid][pAdmin])
        {
            case 1: ShowPlayerDialog(playerid, 15, DIALOG_STYLE_MSGBOX, "Admin Komande!", "{00C0FF}/slap /kornjaca /explode /mute /unmute /freeze /unfreeze /crash /kick /ban /goto /gethere /setloc /gotoloc /gotojail /gotokomora /adminbaza /admino /sethp /o /a /getip /specon /specoff /vehid /remove /busi /disarm /onduty /offduty /put /eject", "Ok", "");
            case 2: ShowPlayerDialog(playerid, 16, DIALOG_STYLE_MSGBOX, "Admin Komande!", "{00C0FF}/slap /kornjaca /explode /mute /unmute /freeze /unfreeze /crash  /jail /unjail /kick /ban /goto /gethere /setloc /gotoloc /gotoammu /gotojail /gotokomora /adminbaza /admino /sethp /settime /givegun /weaponid /o /a /cc /cnn /uping /downing /godmodeon /godmodeoff /visible /getip /specon /specoff /vehid /remove /busi /disarm /onduty /offduty /put /eject", "Ok", "");
            case 3: ShowPlayerDialog(playerid, 17, DIALOG_STYLE_MSGBOX, "Admin Komande!", "{00C0FF}/slap /kornjaca /explode /mute /unmute /freeze /unfreeze /crash  /jail /unjail /kick /ban /goto /gethere /setloc /gotoloc /gotoammu /gotojail /gotokomora /adminbaza /admino /sethp /setscore /setkills /setdeaths /settime /givegun /weaponid /setmoney /o /a /cc /cnn /cnnn /uping /downing /godmodeon /godmodeoff /visible /getip /specon /specoff /vehid /remove /busi /disarm /onduty /offduty /put", "Ok", "");
        }
    }
    else SendClientMessage(playerid, COLOR_KRED, "Niste autorizirani za koriљtenje ove komande!");
    return 1;
}
Reply
#4

Quote:
Originally Posted by Grim_
Посмотреть сообщение
At the below reply, it is true you could use the switch statement. However, how much better it would be, with the limited amount of code, is very minimal.
i dont think there is a way to do dialogs without doing the case. or is there?
Reply
#5

Quote:
Originally Posted by mastalol
Посмотреть сообщение
i dont think there is a way to do dialogs without doing the case. or is there?
There is:
pawn Код:
if( IsPlayerVIPType( playerid, 1 ) ) ShowPlayerDialog( ... );
else if( IsPlayerVIPType( playerid, 2 ) ) ShowPlayerDialog( ... );
else if( IsPlayerVIPType( playerid, 3 ) ) ShowPlayerDialog( ... );
However if you're going to be doing it that way, then you should go ahead and use a switch statement.
Reply
#6

dude how u will detect which player is vip i want to know only that and always im asking about that how the pawn will detect which player will be vip ? and how i can make to detect some player to give rights ?
Reply
#7

Quote:
Originally Posted by Rafa
Посмотреть сообщение
dude how u will detect which player is vip i want to know only that and always im asking about that how the pawn will detect which player will be vip ? and how i can make to detect some player to give rights ?
I dont quite understand you but if you are asking how my vip system works....

I use LUXADMIN

and its as simple as 1,2,3 xD

if(IsPlayerVipType(playerid,TYPE))
Type 1 = Silver
Type 2 = Gold
Type 3 = Premium
Reply
#8

yeah but i need to know how u will detect the player who is vip and u give him this right to use... :/
Reply
#9

will IsPlayerVipType return true if you ask for level 1 and he is level 3?
If so then the only way I could improve it would be changing the "Flips You Car" to "Flips Your Car"
Reply
#10

Quote:
Originally Posted by Daren_Jacobson
Посмотреть сообщение
will IsPlayerVipType return true if you ask for level 1 and he is level 3?
If so then the only way I could improve it would be changing the "Flips You Car" to "Flips Your Car"
epic looked through it with a fine tooth comb XD

+ rep for finding typo
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)