warning 202: number of arguments does not match definition
#1

Hi guys. I have a common problem that i can't solve, and get 17 warnings. I will post whole CMD and comment the line so you guys can check the problem.

Код:
CMD:setstat(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 4)
    {

        new string[128], giveplayerid, statcode, amount;
        if(sscanf(params, "udd", giveplayerid, statcode, amount))
        {
            SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setstat [playerid] [statcode] [amount]");
            SendClientMessage(playerid, COLOR_WHITE, "|1 Level |2 Driving License |3 UpgradePoints |4 Cash |5 VIP |6 Model");
            SendClientMessage(playerid, COLOR_WHITE, "|7 Experience Points |8 Age |9 Sex");
            return 1;
        }
        if(IsPlayerConnected(giveplayerid))
        {
            switch (statcode)
            {
            case 1:
                {
                    PlayerInfo[giveplayerid][pLevel] = amount;
                    format(string, sizeof(string), "%s's Level has been set to %d.", GetPlayerName(giveplayerid), amount); // First error here = 2725
                    SetPlayerScore(giveplayerid, PlayerInfo[giveplayerid][pLevel]);
                }
            case 2:
                {
                    PlayerInfo[giveplayerid][pDriveLic] = amount;
                    format(string, sizeof(string), "%s's Driver license has been set to %d.", GetPlayerName(giveplayerid), amount); // Second error here = 2731
                }
            case 3:
                {
                    PlayerInfo[giveplayerid][pExp] = amount;
                    format(string, sizeof(string), "%s's Respect Points have been set to %d.", GetPlayerName(giveplayerid), amount); // Third line error = 2736
                }
            case 4:
                {
                    PlayerInfo[giveplayerid][pCash] = amount;
                    format(string, sizeof(string), "%s's Cash has been set %d.", GetPlayerName(giveplayerid), amount); // So it goes on...
                }
            case 5:
                {
                    PlayerInfo[giveplayerid][pVip] = amount;
                    format(string, sizeof(string), "%s's Account VIP has been set to $%d.", GetPlayerName(giveplayerid), amount);
                }
            case 6:
                {
                    PlayerInfo[giveplayerid][pModel] = amount;
                    format(string, sizeof(string), "%s's Model has been set to %d.", GetPlayerName(giveplayerid), amount);
                }
            case 7:
                {
                    PlayerInfo[giveplayerid][pExp] = amount;
                    format(string, sizeof(string), "%s's Respect Points have been set to %d.", GetPlayerName(giveplayerid), amount);
                }
            case 8:
                {
                    PlayerInfo[giveplayerid][pLevel] = 5;
                    PlayerInfo[giveplayerid][pCash] = 50000;
                    PlayerInfo[giveplayerid][pVip] = 3;
                    format(string, sizeof(string), "You got Refunded.", GetPlayerName(giveplayerid), amount);
                }
                      default:
                {
                    format(string, sizeof(string), "   Invalid stat code.", amount);
                    return 1;
				}
			}
		}
	}
	return 1;
}
Код:
C:\Users\DennisAlexander\Desktop\Deluxe-Roleplay UNIQUE Script\samp03e_svr_win32\gamemodes\SF-RP.pwn(2725) : warning 202: number of arguments does not match definition
C:\Users\DennisAlexander\Desktop\Deluxe-Roleplay UNIQUE Script\samp03e_svr_win32\gamemodes\SF-RP.pwn(2725) : warning 202: number of arguments does not match definition
C:\Users\DennisAlexander\Desktop\Deluxe-Roleplay UNIQUE Script\samp03e_svr_win32\gamemodes\SF-RP.pwn(2731) : warning 202: number of arguments does not match definition
C:\Users\DennisAlexander\Desktop\Deluxe-Roleplay UNIQUE Script\samp03e_svr_win32\gamemodes\SF-RP.pwn(2731) : warning 202: number of arguments does not match definition
C:\Users\DennisAlexander\Desktop\Deluxe-Roleplay UNIQUE Script\samp03e_svr_win32\gamemodes\SF-RP.pwn(2736) : warning 202: number of arguments does not match definition
C:\Users\DennisAlexander\Desktop\Deluxe-Roleplay UNIQUE Script\samp03e_svr_win32\gamemodes\SF-RP.pwn(2736) : warning 202: number of arguments does not match definition
C:\Users\DennisAlexander\Desktop\Deluxe-Roleplay UNIQUE Script\samp03e_svr_win32\gamemodes\SF-RP.pwn(2741) : warning 202: number of arguments does not match definition
C:\Users\DennisAlexander\Desktop\Deluxe-Roleplay UNIQUE Script\samp03e_svr_win32\gamemodes\SF-RP.pwn(2741) : warning 202: number of arguments does not match definition
C:\Users\DennisAlexander\Desktop\Deluxe-Roleplay UNIQUE Script\samp03e_svr_win32\gamemodes\SF-RP.pwn(2746) : warning 202: number of arguments does not match definition
C:\Users\DennisAlexander\Desktop\Deluxe-Roleplay UNIQUE Script\samp03e_svr_win32\gamemodes\SF-RP.pwn(2746) : warning 202: number of arguments does not match definition
C:\Users\DennisAlexander\Desktop\Deluxe-Roleplay UNIQUE Script\samp03e_svr_win32\gamemodes\SF-RP.pwn(2751) : warning 202: number of arguments does not match definition
C:\Users\DennisAlexander\Desktop\Deluxe-Roleplay UNIQUE Script\samp03e_svr_win32\gamemodes\SF-RP.pwn(2751) : warning 202: number of arguments does not match definition
C:\Users\DennisAlexander\Desktop\Deluxe-Roleplay UNIQUE Script\samp03e_svr_win32\gamemodes\SF-RP.pwn(2756) : warning 202: number of arguments does not match definition
C:\Users\DennisAlexander\Desktop\Deluxe-Roleplay UNIQUE Script\samp03e_svr_win32\gamemodes\SF-RP.pwn(2756) : warning 202: number of arguments does not match definition
C:\Users\DennisAlexander\Desktop\Deluxe-Roleplay UNIQUE Script\samp03e_svr_win32\gamemodes\SF-RP.pwn(2763) : warning 202: number of arguments does not match definition
C:\Users\DennisAlexander\Desktop\Deluxe-Roleplay UNIQUE Script\samp03e_svr_win32\gamemodes\SF-RP.pwn(2763) : warning 202: number of arguments does not match definition
Reply
#2

Looks like you don't know how to use GetPlayerName. Read the documentation for this and you'll see that you have to store it an array (string) first and that's what the function does.

pawn Код:
new PlayerName[24];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
Also keep in mind never to use those stupid wrapper functions which do the above and then return the PlayerName. This is a serious waste of computing!

Also, another thing I should mention is that the u specifier in sscanf stores INVALID_PLAYER_ID in the variable if the player is not found, so your IsPlayerConnected check is unnecessary, as it will come down to: IsPlayerConnected(INVALID_PLAYER_ID)... and how can an invalid ID be connected?
pawn Код:
if(sscanf(params, "udd", giveplayerid, statcode, amount))
{
    // ...
}
if(giveplayerid != INVALID_PLAYER_ID)
{
    // ...
}
Reply
#3

Quote:
Originally Posted by AndreT
Посмотреть сообщение
Looks like you don't know how to use GetPlayerName. Read the documentation for this and you'll see that you have to store it an array (string) first and that's what the function does.

pawn Код:
new PlayerName[24];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
Also keep in mind never to use those stupid wrapper functions which do the above and then return the PlayerName. This is a serious waste of computing!

Also, another thing I should mention is that the u specifier in sscanf stores INVALID_PLAYER_ID in the variable if the player is not found, so your IsPlayerConnected check is unnecessary, as it will come down to: IsPlayerConnected(INVALID_PLAYER_ID)... and how can an invalid ID be connected?
pawn Код:
if(sscanf(params, "udd", giveplayerid, statcode, amount))
{
    // ...
}
if(giveplayerid != INVALID_PLAYER_ID)
{
    // ...
}
Alright i see what you are pointing at! but since i'm new at pawno, though i can script some things. I would be very appreciate if you fixed the whole CMD for me
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)