SA-MP Forums Archive
[Ajuda] ajuda com sscanf/array - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda] ajuda com sscanf/array (/showthread.php?tid=653158)



ajuda com sscanf/array - cailir - 27.04.2018

Erro ao compilar:
PHP код:
C:\Users\***\DirigindoNoEstilo.pwn(614) : error 033: array must be indexed (variable "Strings")
C:\Users\***\DirigindoNoEstilo.pwn(623) : error 033: array must be indexed (variable "Strings")
C:\Users\***\DirigindoNoEstilo.pwn(632) : error 033: array must be indexed (variable "Strings") 
Codigo:
PHP код:
CMD:setplayer(playerid, params[])
{
    if (
PlayerInfo[playerid][pAdmin] > SubDonoAdminLevel)
    {
        new 
id, string[500], value, Strings[500], name[MAX_PLAYER_NAME];
        if (
sscanf(params, "rsi", id, Strings, value))
        {
            
SendClientMessage(playerid, -1, "Uso: /setplayer [id] [atributo] [valor]");
            
SendClientMessage(playerid, -1, "Atributos Validos: dinheiro - score - veiculo");
            return 
1;
        }
        if (
id == INVALID_PLAYER_ID)
            return 
SendClientMessage(playerid, -1, "{FF0000}[ERRO] {FFFFFF}Player invalido!");
        if (
Strings == "dinheiro")
        {
            
PlayerInfo[id][pDinheiro] = value;
            
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
            
format(string, sizeof(string), "O Admin %s setou %d em sua conta bancaria!", name, value);
            
SendClientMessage(id, -1, string);
            
GetPlayerName(id, name, MAX_PLAYER_NAME);
            
format(string, sizeof(string), "Voce setou %d na conta de %s!", value, name);
            
SendClientMessage(playerid, -1, string);
        } else if (
Strings == "score")
        {
            
SetPlayerScore(id, value);
            
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
            
format(string, sizeof(string), "O Admin %s setou voce nivel %d!", name, value);
            
SendClientMessage(id, -1, string);
            
GetPlayerName(id, name, MAX_PLAYER_NAME);
            
format(string, sizeof(string), "Voce setou %s no nivel %d!", name, value);
            
SendClientMessage(playerid, -1, string);
        } else if (
Strings == "veiculo")
        {
            
PlayerInfo[id][pVehicle] = value;
            
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
            
format(string, sizeof(string), "O Admin %s setou para voce o veiculo de ID %d!", name, value);
            
SendClientMessage(id, -1, string);
            
GetPlayerName(id, name, MAX_PLAYER_NAME);
            
format(string, sizeof(string), "Voce setou %d como veiculo de %s!", value, name);
            
SendClientMessage(playerid, -1, string);
        } else return 
SendClientMessage(playerid, -1, "Atributos Validos: dinheiro - score - veiculo");
        
    } else return 
SendClientMessage(playerid, -1, "{FF0000}[ERRO] {FFFFFF}Voce nao tem permissao para utilizar esse comando");
    return 
1;
} 



Re: ajuda com sscanf/array - 1sbedx - 27.04.2018

PHP код:
CMD:setplayer(playerid, params[])
{
    new 
id, set[16], value, string[128];
    if (
PlayerInfo[playerid][pAdmin] < SubDonoAdminLevel)
        return 
SendClientMessage(playerid, -1, "{FF0000}[ERRO] {FFFFFF}Voce nao tem permissao para utilizar esse comando");
    if (
sscanf(params, "us[16]i", id, set, value))
    {
        
SendClientMessage(playerid, -1, "Uso: /setplayer [id] [atributo] [valor]"); 
        
SendClientMessage(playerid, -1, "Atributos Validos: dinheiro - score - veiculo");
        return 
1;
    }
    if (
id == INVALID_PLAYER_ID) 
        return 
SendClientMessage(playerid, -1, "{FF0000}[ERRO] {FFFFFF}Player invalido!"); 
    if (!
strcmp(set, "dinheiro", true))
    {
        
PlayerInfo[id][pDinheiro] = value;
        
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
        
format(string, sizeof(string), "O Admin %s setou %d em sua conta bancaria!", name, value);
        
SendClientMessage(id, -1, string);
        
GetPlayerName(id, name, MAX_PLAYER_NAME);
        
format(string, sizeof(string), "Voce setou %d na conta de %s!", value, name);
        
SendClientMessage(playerid, -1, string);
    }
    else if (!
strcmp(set, "score", true))
    {
        
// ...
    
}
    return 
1;
} 



Re: ajuda com sscanf/array - Minerva - 27.04.2018

@Edit

Codigo jб postado ^^


Re: ajuda com sscanf/array - cailir - 27.04.2018

Quote:
Originally Posted by 1sbedx
Посмотреть сообщение
PHP код:
CMD:setplayer(playerid, params[])
{
    new 
id, set[16], value, string[128];
    if (
PlayerInfo[playerid][pAdmin] < SubDonoAdminLevel)
        return 
SendClientMessage(playerid, -1, "{FF0000}[ERRO] {FFFFFF}Voce nao tem permissao para utilizar esse comando");
    if (
sscanf(params, "us[16]i", id, set, value))
    {
        
SendClientMessage(playerid, -1, "Uso: /setplayer [id] [atributo] [valor]"); 
        
SendClientMessage(playerid, -1, "Atributos Validos: dinheiro - score - veiculo");
        return 
1;
    }
    if (
id == INVALID_PLAYER_ID) 
        return 
SendClientMessage(playerid, -1, "{FF0000}[ERRO] {FFFFFF}Player invalido!"); 
    if (!
strcmp(set, "dinheiro", true))
    {
        
PlayerInfo[id][pDinheiro] = value;
        
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
        
format(string, sizeof(string), "O Admin %s setou %d em sua conta bancaria!", name, value);
        
SendClientMessage(id, -1, string);
        
GetPlayerName(id, name, MAX_PLAYER_NAME);
        
format(string, sizeof(string), "Voce setou %d na conta de %s!", value, name);
        
SendClientMessage(playerid, -1, string);
    }
    else if (!
strcmp(set, "score", true))
    {
        
// ...
    
}
    return 
1;
} 
Obrigado, ajudou muito!!