Error cmd /settasnumero
#1

I can not understand because she gives me these errors
Код HTML:
}    
CMD:settasnumero(playerid, params[])
{
    new ID;
    new numero[300];
    if(PlayerInfo[playerid][pAdmin] == 0) return SendClientMessage(playerid, COLOR_RED, "[SERVER]: Non sei uno Staffer");
    if((PlayerInfo[playerid][pAdmin] >= 1) && (PlayerInfo[playerid][pAdmin] <= 3)) return SendClientMessage(playerid, COLOR_RED, "[SERVER]: Non disponi di questo comando!");
    if(sscanf(params, "s[24]", ID, numero)) return SendClientMessage(playerid, COLOR_WHITE, "[USA]: /settasnumero <IDPlayer> <Numero>");
    if(PlayerInfo[playerid][pAdmin] >= 4)
    {
        new INI:File = INI_Open(UserPath(ID));
        new string[300];
        INI_WriteInt(File, "Numero", numero);
        PlayerInfo[ID][pNumero] = numero;
        INI_Close(File);

        format(string, sizeof(string), "[SERVER]: Ti и stato settato il numero: %i da %s", numero, GetName(playerid));
        SendClientMessage(ID, COLOR_RED, string);
        format(string, sizeof(string), "[SERVER]: Hai settato %s il numero: %i ", GetName(ID), numero);
        SendClientMessage(playerid, COLOR_RED, string);
    }    
    return 1;
Код HTML:
error 035: argument type mismatch (argument 3) =  INI_WriteInt(File, "Numero", numero);
error 006: must be assigned to an array = PlayerInfo[ID][pNumero] = numero;
Could you explain why it gives me this error?
Reply
#2

sscanf was completely incorrect.
Variable "numero" must be an integer and in sscanf you need to put the "u" for ID (playerid) and "i" for numero

This work:
pawn Код:
CMD:settasnumero(playerid, params[])
{
    new ID, numero;
    if(PlayerInfo[playerid][pAdmin] == 0) return SendClientMessage(playerid, COLOR_RED, "[SERVER]: Non sei uno Staffer");
    if((PlayerInfo[playerid][pAdmin] >= 1) && (PlayerInfo[playerid][pAdmin] <= 3)) return SendClientMessage(playerid, COLOR_RED, "[SERVER]: Non disponi di questo comando!");
    if(sscanf(params, "ui", ID, numero)) return SendClientMessage(playerid, COLOR_WHITE, "[USA]: /settasnumero <IDPlayer> <Numero>");
    if(PlayerInfo[playerid][pAdmin] >= 4)
    {
        new INI:File = INI_Open(UserPath(ID));
        new string[300];
        INI_WriteInt(File, "Numero", numero);
        PlayerInfo[ID][pNumero] = numero;
        INI_Close(File);

        format(string, sizeof(string), "[SERVER]: Ti и stato settato il numero: %i da %s", numero, GetName(playerid));
        SendClientMessage(ID, COLOR_RED, string);
        format(string, sizeof(string), "[SERVER]: Hai settato %s il numero: %i ", GetName(ID), numero);
        SendClientMessage(playerid, COLOR_RED, string);
    }
}
Reply
#3

Thanks +rep A question has a guide that explains in detail the functions of sscanf?
Reply
#4

https://sampforum.blast.hk/showthread.php?tid=570927
Reply
#5

Thanks +rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)