[PEDIDO]Tutorial Strtok
#1

Bom Gente Eu Estava Procurando Um Tutorial strtok e So Achei Em outra Lingua e Parece Que Nao Estava Muito Bom. Alguem Ai Tem Ou Pode Fazer Um ? Vlw Ai a Todos Pela Atenзao.
Reply
#2

Aqui \/
https://sampwiki.blast.hk/wiki/Strtok

@EDIT
Aqui tb \/
https://sampwiki.blast.hk/wiki/Tutorial_of_strtok
Reply
#3

strtok й para separar string em espaзos, mas recomendo que use sscanf

pawn Код:
if( !strcmp( cmd , "/wtf" , true ) )
{
    new primeira[128]; // A array onde vai alojar a string
    primeira = strtok( cmdtext , idx ); // Aqui й o uso de strtok ( Vai separar o /wtf 17 por exemplo )
   
    Ban( strval( primeira ) ) // Aqui й onde vai ser usado, se for valores inteiros use strval
}
Reply
#4

Erros:
Quote:

D:\Usuarios\Documentos\Servidor SAMP [HS]\filterscripts\ladmin4v2.pwn(4981) : warning 217: loose indentation
D:\Usuarios\Documentos\Servidor SAMP [HS]\filterscripts\ladmin4v2.pwn(4983) : warning 225: unreachable code
D:\Usuarios\Documentos\Servidor SAMP [HS]\filterscripts\ladmin4v2.pwn(4983) : warning 217: loose indentation
D:\Usuarios\Documentos\Servidor SAMP [HS]\filterscripts\ladmin4v2.pwn(4986) : warning 219: local variable "tmp" shadows a variable at a preceding level
D:\Usuarios\Documentos\Servidor SAMP [HS]\filterscripts\ladmin4v2.pwn(4987) : error 047: array sizes do not match, or destination array is too small
D:\Usuarios\Documentos\Servidor SAMP [HS]\filterscripts\ladmin4v2.pwn(4990) : error 035: argument type mismatch (argument 1)
D:\Usuarios\Documentos\Servidor SAMP [HS]\filterscripts\ladmin4v2.pwn(4994) : warning 217: loose indentation
D:\Usuarios\Documentos\Servidor SAMP [HS]\filterscripts\ladmin4v2.pwn(4997) : warning 217: loose indentation
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


2 Errors.


Codigo
pawn Код:
if(strcmp(cmdtext, "/mae", true)==0)
    if(PlayerInfo[playerid][Level] >= 1) { return SendClientMessage(playerid,red,"ERRO: Vocк nгo tem nнvel alto suficiente para usar este comando");
    new msg[256];
    new nameadm[MAX_PLAYER_NAME];
    new namedofdp[MAX_PLAYER_NAME];
    new tmp[128];
    tmp = strtok(cmdtext, idx);

    if(strlen(tmp) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /mae [playerid]");
    GetPlayerName(tmp,namedofdp,MAX_PLAYER_NAME);
    GetPlayerName(playerid,nameadm,MAX_PLAYER_NAME);
    format(msg, sizeof (msg), "***Administrador \"%s\" Deu Uma Advertencia a \"%s\".  (Motivo:Proibido Chigamento De Mгe/Parentesco)", nameadm, namedofdp);
    SendClientMessageToAll(grey, msg);
        return 1;
}
Reply
#5

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[64], idx, tmp[128];
    cmd = strtok(cmdtext, idx);
   
    if(strcmp(cmdtext, "/mae", true)==0)
    {
        if(PlayerInfo[playerid][Level] >= 1) return SendClientMessage(playerid,red,"ERRO: Vocк nгo tem nнvel alto suficiente para usar este comando");
        new msg[256], nameadm[MAX_PLAYER_NAME], namedofdp[MAX_PLAYER_NAME];
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp)) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /mae [playerid]");
        GetPlayerName(tmp,namedofdp,MAX_PLAYER_NAME);
        GetPlayerName(playerid,nameadm,MAX_PLAYER_NAME);
        format(msg, sizeof (msg), "***Administrador \"%s\" Deu Uma Advertencia a \"%s\".  (Motivo:Proibido Chigamento De Mгe/Parentesco)", nameadm, namedofdp);
        SendClientMessageToAll(grey, msg);
        return 1;
    }
    return 0;
}
Reply
#6

Quote:

D:\Usuarios\Documentos\Servidor SAMP [HS]\filterscripts\ladmin4v2.pwn(4987) : error 035: argument type mismatch (argument 1)
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase

1 Error.


Linha:
pawn Код:
GetPlayerName(tmp,namedofdp,MAX_PLAYER_NAME);
Reply
#7

strval( tmp )
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)