Would this command work?
#1

PHP код:
CMD:setVIP(playeridparams[])
{
    new 
victimname[MAX_PLAYER_NAME], vipname[MAX_PLAYER_NAME], viplvlid;
    if(
IsPlayerAdmin(playerid))
    {
        if (
sscanf(params"ui"idviplvl)) return SendClientMessage(playeridCOLOR_RED"USAGE: /setvip [id] [viplevel]");
        if (
id == INVALID_PLAYER_ID) return SendClientMessage(playeridCOLOR_RED"System: Invalid ID");
        if (
viplvl 10 || viplvl 0) return SendClientMessage(playeridCOLOR_RED,"System: Valid vip Levels: 1-3!");
        
PlayerInfo[id][pVipLevel] = viplvl;
        
GetPlayerName(idvictimnamesizeof(victimname));
        
GetPlayerName(playeridvipnamesizeof(vipname));
        new 
str[128];
        
format(str,128,"System: %s [ID %d] has set %s [ID %d] admin level to %i",vipnameplayeridvictimnameidviplvl);
        
SendClientMessage(playerid,COLOR_GREEN,str);
        return 
1;
    }
    else return 
SendClientMessage(playerid,COLOR_RED,"  You are not allowed to use this command!");

Will this work?
Reply
#2

Код:
 if (viplvl > 10 || viplvl < 0) return SendClientMessage(playerid, COLOR_RED,"System: Valid vip Levels: 1-3!");
It looks like you can set higher level than 3...

______

You can't try this command on themself?
Reply
#3

Don't use || when comparing between 2 values.

Use it like this:
pawn Код:
if (viplvl <= 3 && viplvl >= 0) //Correct.
//Less than or equal to 3 and bigger than or equal to 0.

 if (viplvl < 3 || viplvl > 0) //Wrong.
//It means less than 3 OR more than 0. So, if you enter 151515 it IS bigger than 3 and it will continue.
Reply
#4

pawn Код:
if (viplvl > 10 || viplvl < 0) return SendClientMessage(playerid, COLOR_RED,"System: Valid vip Levels: 1-3!");
Should be

pawn Код:
if (viplvl < 0 || viplvl > 3) return SendClientMessage(playerid, COLOR_RED,"System: Valid vip Levels: 0-3!");
I'm sure you'd want to set them to 0, if you wished to take the VIP away :P

Apart from that, taking a brief glance over it, I don't see why it won't. However it's a good idea to test it.
Reply
#5

I just took my SetAdmin code and converted it to VIP and i was in a rush so i forgot to change it from 10 to 3. Thanks guys
Reply
#6

You should test code yourself, instead of asking others if it will work.

But given the fact that you've created this thread - it's more appropriate to refrain from case sensivity with the definition of commands.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)