strcmp issue
#1

So I am making a /set command for my server, but I get an error on line 898

pawn Код:
if(strcmp(cmd, "/set", true) == 0)
    {
        new string[128];
        if(sscanf(params, "udz", id, Option, Value))
        {
            if(PlayerInfo[playerid][pAdmin] >= 3)
            {
                SendClientMessage(playerid, -1, "SYNTAX: /set [Playerid] [Option] [Value]");
                SendClientMessage(playerid, -1, "OPTIONS: Army, Origin, Interior, Skin, ArmyRank, Money, Age");
                SendClientMessage(playerid, -1, "OPTIONS: Armor, Cirtual WorldPlayinghours, Score, Experience");
            }
        }
        else
        {
            if(PlayerInfo[playerid][pAdmin] >=3)
            {
                if(strcmp(Option, "army", true) == 0) //this is Line 898
                {
                    format(string, sizeof(string), "You have set %s's Army to %d.", GetName(id), Value);
                    SendClientMessage(playerid, -1, string);
                    SavePlayerDat(id);
                    PlayerInfo[id][pArmy] = Value;
                    PlayerInfo[id][pArmyRank] = 1;
                }
            }
        }
    }
Any help would be appreciated and I will +Rep.
Reply
#2

Try

pawn Код:
if ( strcmp( Option, "army", false ) )
and see if that works.
Reply
#3

pawn Код:
C:\Documents and Settings\nmader\Desktop\Folders\COVRP\gamemodes\COVRP.pwn(898) : error 035: argument type mismatch (argument 1)
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
Reply
#4

Instead if using strcmp you could use:-

pawn Код:
If(Option == army)
{
          //your code
}
Reply
#5

Quote:
Originally Posted by FalconX
Посмотреть сообщение
Instead if using strcmp you could use:-

pawn Код:
If(Option == army)
{
          //your code
}
No. You cannot compare strings that way.

May I ask what the actual error is? (Assuming the one you posted above in another post isn't an attempt at rectifying the issue).
Reply
#6

I'm an idiot.

Option isn't defined, new Option [ 128 ]; (or whatever)

and on your sscanf line, you're using Option as an integer.

Tell me, how is 'army' an integer?
Reply
#7

It's totally wrong. At the moment I am too tired to explain it all, just try this:
pawn Код:
if(strcmp(cmd, "/set", true) == 0)
{
    new string[128], opt[20];
    if(PlayerInfo[playerid][pAdmin >= 3)
    {
        if(sscanf(params, "us[20]i", id, opt, Value))
        {
            if(strlen(opt) == 0)
            {
                        SendClientMessage(playerid, -1, "SYNTAX: /set [Playerid] [Option] [Value]");
                        SendClientMessage(playerid, -1, "OPTIONS: Army, Origin, Interior, Skin, ArmyRank, Money, Age");
                        SendClientMessage(playerid, -1, "OPTIONS: Armor, Cirtual WorldPlayinghours, Score, Experience");
            }
            else
            if(strcmp(opt, "army", true) == 0)
            {
                            format(string, sizeof(string), "You have set %s's Army to %d.", GetName(id), Value);
                            SendClientMessage(playerid, -1, string);
                            SavePlayerDat(id);
                            PlayerInfo[id][pArmy] = Value;
                            PlayerInfo[id][pArmyRank] = 1;
            }
        }
    }
    return 1;
}
Edit: Just tell me if it works. I didn't do this properly, but if it works, I'll change it.
Reply
#8

Quote:
Originally Posted by funky1234
Посмотреть сообщение
No. You cannot compare strings that way.

May I ask what the actual error is? (Assuming the one you posted above in another post isn't an attempt at rectifying the issue).
Oh ok Ty for correcting me.

-FalconX
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)