SA-MP Forums Archive
[Ajuda] comando. - 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] comando. (/showthread.php?tid=450571)



comando. - Cromado - 13.07.2013

Desculpe por esse post eu tinha dado uma olhada de como por motivo etc...

dai eu fiz assim
pawn Код:
if(strcmp(cmd, "/prendert", true) ==0) {
    new aname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, aname, MAX_PLAYER_NAME);
    format(file, sizeof(file), P_CONTAS, aname);
    new tmp[256];
    new plid;
    new tempo;
    new msg1[256];
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp)){
        SendClientMessage(playerid, Vermelho, "| ERRO | Digite : /Prendert [id] [tempo] [motivo]");
        return 1;
    }
    plid = strval(tmp);
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp)){
        SendClientMessage(playerid, Vermelho,"| ERRO | Digite : /Prendert [id] [tempo] [motivo]");
        return 1;
    }
    tempo = strval(tmp);
    msg1 = strtok(cmdtext, idx);
    if(!strlen(msg1)){
        SendClientMessage(playerid, Vermelho,"| ERRO | Digite : /Prendert [id] [tempo] [motivo]");
        return 1;
    }
    if(tempo > 1000000 || tempo < 1){
        SendClientMessage(playerid, Vermelho,"| ERRO | Tempo de 1 hб 1000000!");
        return 1;
    }
    if(!IsPlayerConnected(plid)){
        SendClientMessage(playerid, Vermelho, "| ERRO | O jogador nгo estб conectado");
        return 1;
    }
   
          new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' ')) {
                idx++;
            }
    new offset = idx;
    new result[64];
    while ((idx < length) && ((idx - offset) < (sizeof(result) - 1))) {
    result[idx - offset] = cmdtext[idx];
    idx++;
    }
    result[idx - offset] = EOS;
    if(!strlen(result)) {
    SendClientMessage(playerid, Vermelho,"| ERRO | Digite : /Prendert [id] [tempo] [motivo]");
    return 1;
    }
    else {
    new pname[MAX_PLAYER_NAME];
    GetPlayerName(plid, pname, MAX_PLAYER_NAME);
    format(file2, sizeof(file2), P_CONTAS, pname);
    format(string, sizeof(string), "| INFO | O administrador(a) %s prendeu o jogador %s Por %d minutos ( MOTIVO: %s ) ", aname ,pname ,tempo ,result);
    SendClientMessageToAll(Vermelho,string);
    GameTextForPlayer(plid, "~w~ Preso", 5000, 6);
    SetPlayerPos(plid, 263.8820,77.4002,1001.0391);
    SetPlayerInterior(plid, 6);
    SetPlayerHealth(plid, 99999);
    ResetPlayerWeapons(plid);
    Cadeia[plid] = 1;
    TempoCadeia[plid] = tempo*60;
    }
    return 1;
}
mais o comando fica assim /prender id tempo motivo motivo 2 motivo sendo que so sai um motivo me ajuda a transformar o comando pra assim

/prendert id tempo motivo ?


Re: comando. - dieegov - 13.07.2013

Quote:
Originally Posted by Cromado
Посмотреть сообщение
Desculpe por esse post eu tinha dado uma olhada de como por motivo etc...

dai eu fiz assim
pawn Код:
if(strcmp(cmd, "/prendert", true) ==0) {
    new aname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, aname, MAX_PLAYER_NAME);
    format(file, sizeof(file), P_CONTAS, aname);
    new tmp[256];
    new plid;
    new tempo;
    new msg1[256];
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp)){
        SendClientMessage(playerid, Vermelho, "| ERRO | Digite : /Prendert [id] [tempo] [motivo]");
        return 1;
    }
    plid = strval(tmp);
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp)){
        SendClientMessage(playerid, Vermelho,"| ERRO | Digite : /Prendert [id] [tempo] [motivo]");
        return 1;
    }
    tempo = strval(tmp);
    msg1 = strtok(cmdtext, idx);
    if(!strlen(msg1)){
        SendClientMessage(playerid, Vermelho,"| ERRO | Digite : /Prendert [id] [tempo] [motivo]");
        return 1;
    }
    if(tempo > 1000000 || tempo < 1){
        SendClientMessage(playerid, Vermelho,"| ERRO | Tempo de 1 hб 1000000!");
        return 1;
    }
    if(!IsPlayerConnected(plid)){
        SendClientMessage(playerid, Vermelho, "| ERRO | O jogador nгo estб conectado");
        return 1;
    }
   
          new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' ')) {
                idx++;
            }
    new offset = idx;
    new result[64];
    while ((idx < length) && ((idx - offset) < (sizeof(result) - 1))) {
    result[idx - offset] = cmdtext[idx];
    idx++;
    }
    result[idx - offset] = EOS;
    if(!strlen(result)) {
    SendClientMessage(playerid, Vermelho,"| ERRO | Digite : /Prendert [id] [tempo] [motivo]");
    return 1;
    }
    else {
    new pname[MAX_PLAYER_NAME];
    GetPlayerName(plid, pname, MAX_PLAYER_NAME);
    format(file2, sizeof(file2), P_CONTAS, pname);
    format(string, sizeof(string), "| INFO | O administrador(a) %s prendeu o jogador %s Por %d minutos ( MOTIVO: %s ) ", aname ,pname ,tempo ,result);
    SendClientMessageToAll(Vermelho,string);
    GameTextForPlayer(plid, "~w~ Preso", 5000, 6);
    SetPlayerPos(plid, 263.8820,77.4002,1001.0391);
    SetPlayerInterior(plid, 6);
    SetPlayerHealth(plid, 99999);
    ResetPlayerWeapons(plid);
    Cadeia[plid] = 1;
    TempoCadeia[plid] = tempo*60;
    }
    return 1;
}
mais o comando fica assim /prender id tempo motivo motivo 2 motivo sendo que so sai um motivo me ajuda a transformar o comando pra assim

/prendert id tempo motivo ?
Resolvido, bastava colocar return 1; nas funзхes de Spawn.


Re: comando. - Cromado - 13.07.2013

isso nгo tem nada a ver , ou eu fiz errado


Re: comando. - [THs]ShadoW - 13.07.2013

Posso dar uma sugestгo ? Use SSCANF...


Re: comando. - Cromado - 13.07.2013

como eu mudo lб pra scanff?