Params won't show up!
#1

'Sup y'all?

I just made fast a "setvip"-command, and then, I tested it! Unfortunately, when I just write "/setvip [ID]" or only "/setvip", it doesn't show the usage! There's written, that I've set my VIP-level to 0, even though it should show the usage:

PHP код:
COMMAND:setvip(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] >= 5)
    {
            new 
Target;
            new 
Level;
            if(!
sscanf(params"ui"TargetLevel)) SendClientMessage(playerid,COLOR_RED,"USAGE: /setvip <playerid> <level>");
            {
                
//if(Target == playerid) return SendClientMessage(playerid, COLOR_RED, "SERVER: Cant perform this command on yourself!" );
                
if(Level 3) return SendClientMessage(playeridCOLOR_RED"SERVER: Maximum level is 3!");
                if(
Target == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_RED,"ERROR: Wrong player ID");
                if(
PlayerInfo[Target][pAdmin] > PlayerInfo[playerid][pAdmin]) return SendClientMessage(playerid,COLOR_RED,"ERROR: You cant perform this on Admins that are equal or higher than your level!");
                
PlayerInfo[Target][VIPlevel] = Level;
                new 
tname[MAX_PLAYER_NAME];
                
GetPlayerName(Target,tname,sizeof(tname));
                new 
pname[MAX_PLAYER_NAME];
                
GetPlayerName(playerid,pname,sizeof(pname));
                new 
MyString[128];
                new 
TargetString[128];
                
format(MyStringsizeof(MyString), "You have set %s VIP Level to %i!"tnameLevel);
                
format(TargetStringsizeof(TargetString), "You are now VIP Level %i, thanks to %s!"Levelpname);
                
SendClientMessage(TargetCOLOR_REDTargetString);
                
SendClientMessage(playerid,COLOR_GREEN,MyString);
                
PlayerPlaySound(Target,1057,0.0,0.0,0.0);
            }
            
    }
    else 
SendClientMessage(playeridCOLOR_RED"ERROR: You have to be an Admin level 4 or higher to perform this command!");
    return 
1;

Reply
#2

simple mistake:
pawn Код:
if(!sscanf
should be
pawn Код:
if(sscanf
Reply
#3

Thanks! Well, now it shows the usage, but still a problem: When I just type "/setvip" or "/setvip [ID]" it should return the usage either! But, it shows it and sets my level to 0!
Reply
#4

oh, i didnt see the missing return - anyways, here is how i would have scripted it:
pawn Код:
COMMAND:setvip(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 5)
    {
        new Target;
        new Level;
        if(!sscanf(params, "ui", Target, Level))
        {
            //if(Target == playerid) return SendClientMessage(playerid, COLOR_RED, "SERVER: Cant perform this command on yourself!" );
            if(Level > 3) return SendClientMessage(playerid, COLOR_RED, "SERVER: Maximum level is 3!");
            if(Target == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_RED,"ERROR: Wrong player ID");
            if(PlayerInfo[Target][pAdmin] > PlayerInfo[playerid][pAdmin]) return SendClientMessage(playerid,COLOR_RED,"ERROR: You cant perform this on Admins that are equal or higher than your level!");
            PlayerInfo[Target][VIPlevel] = Level;
            new tname[MAX_PLAYER_NAME];
            GetPlayerName(Target,tname,sizeof(tname));
            new pname[MAX_PLAYER_NAME];
            GetPlayerName(playerid,pname,sizeof(pname));
            new MyString[128];
            new TargetString[128];
            format(MyString, sizeof(MyString), "You have set %s VIP Level to %i!", tname, Level);
            format(TargetString, sizeof(TargetString), "You are now VIP Level %i, thanks to %s!", Level, pname);
            SendClientMessage(Target, COLOR_RED, TargetString);
            SendClientMessage(playerid,COLOR_GREEN,MyString);
            PlayerPlaySound(Target,1057,0.0,0.0,0.0);
        }
        else
        {
            SendClientMessage(playerid,COLOR_RED,"USAGE: /setvip <playerid> <level>");
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "ERROR: You have to be an Admin level 4 or higher to perform this command!");
    }
    return 1;
}
Reply
#5

Try this, untested:

pawn Код:
COMMAND:setvip(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 4)
    return SendClientMessage(playerid, COLOR_RED, "ERROR: You have to be an Admin level 4 or higher to perform this command!");

    new Target, Level;
    if(sscanf(params, "ui", Target, Level))
    return SendClientMessage(playerid,COLOR_RED,"USAGE: /setvip <playerid> <level>");

    //if(Target == playerid) return SendClientMessage(playerid, COLOR_RED, "SERVER: Cant perform this command on yourself!" );
    if(Level > 3) return SendClientMessage(playerid, COLOR_RED, "SERVER: Maximum level is 3!");
    if(Target == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_RED,"ERROR: Wrong player ID");
   
    if(PlayerInfo[Target][pAdmin] > PlayerInfo[playerid][pAdmin])
    return SendClientMessage(playerid,COLOR_RED,"ERROR: You cant perform this on Admins that are equal or higher than your level!");

    PlayerInfo[Target][VIPlevel] = Level;
   
    new pname[MAX_PLAYER_NAME], string[128];
   
    GetPlayerName(Target,pname,sizeof(pname));
    format(string, sizeof(string), "You have set %s VIP Level to %i!", pname, Level);
    SendClientMessage(playerid, COLOR_GREEN, string);
   
    GetPlayerName(playerid,pname,sizeof(pname));
    format(string, sizeof(string), "You are now VIP Level %i, thanks to %s!", Level, pname);
    SendClientMessage(Target, COLOR_RED, string);
   
    PlayerPlaySound(Target,1057,0.0,0.0,0.0);
   
    return 1;
}
Reply
#6

Still doesn't work, still gives the message that I set my level to 0, even though I only type "/setvip"...

pawn Код:
COMMAND:setvip(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 5)
    {

            new Target;
            new Level;
            if(sscanf(params, "ui", Target, Level))
            {
                //if(Target == playerid) return SendClientMessage(playerid, COLOR_RED, "SERVER: Cant perform this command on yourself!" );
                if(Level > 3) return SendClientMessage(playerid, COLOR_RED, "SERVER: Maximum level is 3!");
                if(Target == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_RED,"ERROR: Wrong player ID");
                if(PlayerInfo[Target][pAdmin] > PlayerInfo[playerid][pAdmin]) return SendClientMessage(playerid,COLOR_RED,"ERROR: You cant perform this on Admins that are equal or higher than your level!");
                PlayerInfo[Target][VIPlevel] = Level;
                new tname[MAX_PLAYER_NAME];
                GetPlayerName(Target,tname,sizeof(tname));
                new pname[MAX_PLAYER_NAME];
                GetPlayerName(playerid,pname,sizeof(pname));
                new MyString[128];
                new TargetString[128];
                format(MyString, sizeof(MyString), "You have set %s VIP Level to %i!", tname, Level);
                format(TargetString, sizeof(TargetString), "You are now VIP Level %i, thanks to %s!", Level, pname);
                SendClientMessage(Target, COLOR_RED, TargetString);
                SendClientMessage(playerid,COLOR_GREEN,MyString);
                PlayerPlaySound(Target,1057,0.0,0.0,0.0);
            }
            else
            {
                SendClientMessage(playerid,COLOR_RED,"USAGE: /setvip <playerid> <level>");
            }
           
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "ERROR: You have to be an Admin level 4 or higher to perform this command!");
    }
    return 1;
}
EDIT: Tryin' this from iPLEOMAX! I'mma post later what happened!
EDIT2: Yep, thanks iPLEOMAX, all fixed, you betcha!^_^
Reply
#7

1st way:
pawn Код:
if( !sscanf( params, "ui", Target, Level ) )
{
     // Code
     return 1;
}
else return SendClientMessage( playerid, COLOR_RED, "USAGE: /setvip <playerid> <level>" );
2nd way:
pawn Код:
if( sscanf( params, "ui", Target, Level ) ) return SendClientMessage( playerid, COLOR_RED, "USAGE: /setvip <playerid> <level>" );
// Code
return 1;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)