SA-MP Forums Archive
[Ajuda] Warning no meu gamemode - 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] Warning no meu gamemode (/showthread.php?tid=386035)



Warning no meu gamemode - Vinicius_TroLL - 18.10.2012

Coloquei um sistema de Laser no meu gamemode, aquele de /laseron /laseroff /lasercor mais ai fico dando warnings...me ajudem a resolver ?
Код:
(14862) : warning 219: local variable "tmp" shadows a variable at a preceding level
(50793) : error 021: symbol already defined: "strtok"
Linhas
Код:
                new tmp[128];
{
Comandos com erro
Код:
        if (!strcmp("/lasercor", cmd, true)) {
                new tmp[128];
                tmp = strtok(cmdtext, idx);
                if (!strlen(tmp)) {
                        SendClientMessage(playerid, 0x00E800FF, "Usage: /lasercor [cor]");
                        return 1;
                }
                if (!strcmp(tmp, "vermelho", true)) SetPVarInt(playerid, "color", 18643);
                else if (!strcmp(tmp, "azul", true)) SetPVarInt(playerid, "color", 19080);
                else if (!strcmp(tmp, "rosa", true)) SetPVarInt(playerid, "color", 19081);
                else if (!strcmp(tmp, "laranja", true)) SetPVarInt(playerid, "color", 19082);
                else if (!strcmp(tmp, "verde", true)) SetPVarInt(playerid, "color", 19083);
                else if (!strcmp(tmp, "amarelo", true)) SetPVarInt(playerid, "color", 19084);
                else SendClientMessage(playerid, 0x00E800FF, "Cor nгo disponivel!");
                return 1;
        }
Код:
strtok(const string[], &index)
{
        new length = strlen(string);
        while ((index < length) && (string[index] <= ' '))
        {
                index++;
        }

        new offset = index;
        new result[20];
        while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
        {
                result[index - offset] = string[index];
                index++;
        }
        result[index - offset] = EOS;
        return result;
}



Re: Warning no meu gamemode - leandro123456 - 18.10.2012

deleta a strtok, seu gm jб tem ela. Deleta uma das duas que vocк tem.


Re: Warning no meu gamemode - Vinicius_TroLL - 18.10.2012

Ainda deu um erro esse
Код:
(14844) : warning 219: local variable "tmp" shadows a variable at a preceding level
Linha do erro
Код:
                new tmp[128];
comando do erro
Код:
        if (!strcmp("/lasercor", cmd, true)) {
                new tmp[128];
                tmp = strtok(cmdtext, idx);
                if (!strlen(tmp)) {
                        SendClientMessage(playerid, 0x00E800FF, "Usage: /lasercor [cor]");
                        return 1;
                }
                if (!strcmp(tmp, "vermelho", true)) SetPVarInt(playerid, "color", 18643);
                else if (!strcmp(tmp, "azul", true)) SetPVarInt(playerid, "color", 19080);
                else if (!strcmp(tmp, "rosa", true)) SetPVarInt(playerid, "color", 19081);
                else if (!strcmp(tmp, "laranja", true)) SetPVarInt(playerid, "color", 19082);
                else if (!strcmp(tmp, "verde", true)) SetPVarInt(playerid, "color", 19083);
                else if (!strcmp(tmp, "amarelo", true)) SetPVarInt(playerid, "color", 19084);
                else SendClientMessage(playerid, 0x00E800FF, "Cor nгo disponivel!");
                return 1;
        }



Re: Warning no meu gamemode - leandro123456 - 18.10.2012

pawn Код:
if (!strcmp("/lasercor", cmd, true)) {
                tmp = strtok(cmdtext, idx);
                if (!strlen(tmp)) {
                        SendClientMessage(playerid, 0x00E800FF, "Usage: /lasercor [cor]");
                        return 1;
                }
                if (!strcmp(tmp, "vermelho", true)) SetPVarInt(playerid, "color", 18643);
                else if (!strcmp(tmp, "azul", true)) SetPVarInt(playerid, "color", 19080);
                else if (!strcmp(tmp, "rosa", true)) SetPVarInt(playerid, "color", 19081);
                else if (!strcmp(tmp, "laranja", true)) SetPVarInt(playerid, "color", 19082);
                else if (!strcmp(tmp, "verde", true)) SetPVarInt(playerid, "color", 19083);
                else if (!strcmp(tmp, "amarelo", true)) SetPVarInt(playerid, "color", 19084);
                else SendClientMessage(playerid, 0x00E800FF, "Cor nгo disponivel!");
                return 1;
        }



Re: Warning no meu gamemode - Vinicius_TroLL - 18.10.2012

Obrigado, funcionou...+Rep pra vc...