[AJUDA]
#1

Olб pessoal, boa tarde a todos, vi na wiki sa-mp(https://sampwiki.blast.hk/wiki/Tutorial_of_strtok) um tutorial de strtok, e entendi como fazer, sу que eu peguei o codigo que eles usaram pra ensinar, coloquei no meu GM, e deram alguns erros meio estranhos, porque eu fiz tudo que a wiki mandou...

pawn Код:
C:\Documents and Settings\XP\Desktop\Nova pasta\gamemodes\GoldFish.pwn(92) : error 017: undefined symbol "strtok"
C:\Documents and Settings\XP\Desktop\Nova pasta\gamemodes\GoldFish.pwn(92) : error 033: array must be indexed (variable "cmd")
C:\Documents and Settings\XP\Desktop\Nova pasta\gamemodes\GoldFish.pwn(93) : error 035: argument type mismatch (argument 2)
C:\Documents and Settings\XP\Desktop\Nova pasta\gamemodes\GoldFish.pwn(93) : error 035: argument type mismatch (argument 2)
C:\Documents and Settings\XP\Desktop\Nova pasta\gamemodes\GoldFish.pwn(97) : error 017: undefined symbol "strtok"
C:\Documents and Settings\XP\Desktop\Nova pasta\gamemodes\GoldFish.pwn(97) : error 033: array must be indexed (variable "tmp")
C:\Documents and Settings\XP\Desktop\Nova pasta\gamemodes\GoldFish.pwn(100) : error 035: argument type mismatch (argument 2)
C:\Documents and Settings\XP\Desktop\Nova pasta\gamemodes\GoldFish.pwn(100) : error 035: argument type mismatch (argument 2)
C:\Documents and Settings\XP\Desktop\Nova pasta\gamemodes\GoldFish.pwn(91) : warning 203: symbol is never used: "idx"
C:\Documents and Settings\XP\Desktop\Nova pasta\gamemodes\GoldFish.pwn(91 -- 109) : warning 209: function "OnPlayerCommandText" should return a value
C:\Documents and Settings\XP\Desktop\Nova pasta\gamemodes\GoldFish.pwn(91 -- 110) : error 010: invalid function or declaration
C:\Documents and Settings\XP\Desktop\Nova pasta\gamemodes\GoldFish.pwn(91 -- 110) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


10 Errors.
pawn Код:
89public OnPlayerCommandText(playerid, cmdtext[])
90{
91    new tmp[128], string[128], cmd[128], idx, giveplayerid, sendername, giveplayer;
92    cmd = strtok(cmdtext, idx);
93    GetPlayerName(playerid, sendername, sizeof(sendername));
95    if(strcmp(cmd, "/akill", true) == 0)
96    {
97        if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0x919191FF, "You must be admin to admin-kill someone.");
98        tmp = strtok(cmdtext, idx);
98        if(!strlen(tmp)) return SendClientMessage(playerid, 0x919191FF, "Usage: \"/akill [ID]\"");
99        giveplayerid = strval(tmp);
100        GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
101        if(!IsPlayerConnected(giveplayerid))SendClientMessage(playerid, 0x919191FF, "Player not found.");
102        SetPlayerHealth(giveplayerid, 0);
103        format(string, sizeof(string), "Admin %s[%i] killed you!", sendername, playerid);
104        SendClientMessage(giveplayerid, 0xE21D2CFF, string);
105        format(string, sizeof(string), "Killed %s[%i]!", giveplayer, giveplayerid);
106        SendClientMessage(playerid, 0xE21D2CFF, string);
107        return 1;
108   }
109}
110 return 0;
111}
Esses sao os erros, e as respectivas linhas, queria que alguem me ajudasse por favor, eu entendi o motivo dos erros, so nao sei como corrigi-los ):
Conforme forem surgindo duvidas vou editando aqui obg pela atenзao


@DUVIDA 2

Alguem sabe o id Do caixa bancario?
Reply
#2

Olha ai cara fiz com base nesse seu cуdigo ._.

Estuda ele e vocк consegue:

pawn Код:
#include <a_samp>

public OnPlayerCommandText(playerid, cmdtext[])
{
    new tmp[128], string[128], cmd[128], idx;
    cmd = strtok(cmdtext, idx);

    new pNome[24];//Pega o nome do Admin
    new iNome[24];//Pega o Nome do ID escolhido
    GetPlayerName(playerid, pNome, sizeof(pNome));

    if(strcmp(cmd, "/akill", true) == 0)
    {
        if(!IsPlayerAdmin(playerid))//Se vocк nгo for admin
        {
            SendClientMessage(playerid, 0x919191FF, "Vocк nгo й adminstrador!");
            return 1;
        }
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))// Se voce errar o comando
        {
            SendClientMessage(playerid, 0x919191FF, "Uso: akill [ID]");
        }
        new id = strval(tmp);
        if(!IsPlayerConnected(id))// Se o lek nгo estiver conectado
        {
            SendClientMessage(playerid, 0x919191FF, "Esse jogador nгo estб conectado!");
            return 1;
        }
        GetPlayerName(id, iNome, sizeof(iNome));//Format GetplayerName que pega o Nome do ID
        SetPlayerHealth(id, 0);//Seta a vida do ID para 0
       
        format(string, sizeof(string), "O Admin %s setou sua vida para 0.", pNome);
        SendClientMessage(id, 0xE21D2CFF, string);//Manda mensagem para o ID setado
       
        format(string, sizeof(string), "Vocк setou a vida de %s para 0.", iNome);
        SendClientMessage(playerid, 0xE21D2CFF, string);//Manda mensagem para o admin que usou o comando
        return 1;
    }
    return 0;
}

strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }
    new offset = index,result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}
Reply
#3

pawn Код:
C:\Documents and Settings\XP\Desktop\Nova pasta\gamemodes\GoldFish.pwn(119) : error 047: array sizes do not match, or destination array is too small
C:\Documents and Settings\XP\Desktop\Nova pasta\gamemodes\GoldFish.pwn(130) : error 047: array sizes do not match, or destination array is too small
C:\Documents and Settings\XP\Desktop\Nova pasta\gamemodes\GoldFish.pwn(309) : error 021: symbol already defined: "strtok"
C:\Documents and Settings\XP\Desktop\Nova pasta\gamemodes\GoldFish.pwn(322) : error 047: array sizes do not match, or destination array is too small
C:\Documents and Settings\XP\Desktop\Nova pasta\gamemodes\GoldFish.pwn(39) : warning 204: symbol is assigned a value that is never used: "caixadp"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.
Nгo pense que sou um vagaba que so copio as coisas,nem vou usar esse comando, so estou tentando aprender com ele, estou estudando e tentando entender, mas acho que ta faltando alguma coisa no meu GM pra dar certo... no comeзo do gm eu coloquei #include <string>, precisa?





------------------------------------------------EDIT--------------
Tirei o include la do comeзo, e os erros diminuiram, e ajeitei um outro que era erro meu na hora de colocar o cmd
pawn Код:
C:\Documents and Settings\XP\Desktop\Nova pasta\gamemodes\GoldFish.pwn(118) : error 047: array sizes do not match, or destination array is too small
C:\Documents and Settings\XP\Desktop\Nova pasta\gamemodes\GoldFish.pwn(129) : error 047: array sizes do not match, or destination array is too small
C:\Documents and Settings\XP\Desktop\Nova pasta\gamemodes\GoldFish.pwn(38) : warning 204: symbol is assigned a value that is never used: "caixadp"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


2 Errors.
O warning nao precisa corrigir, vou ajeitar depois.
Reply
#4

acho que nгo, eu faзo comandos strtok se essa include string
Reply
#5

Ok obg leandro, alguem saberia me dizer a id do caixa bancario, que vemos em alguns rpgs, ao lado da dp, ou da prefeitura? obg
Reply
#6

acho que ja vi ele no mta, procura no mta
Reply
#7

Alguma ajuda por favor?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)