SA-MP Forums Archive
їerror de 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: Español/Spanish (https://sampforum.blast.hk/forumdisplay.php?fid=29)
+---- Thread: їerror de comando? (/showthread.php?tid=372239)



їerror de comando? - Glimma - 25.08.2012

їPor quй al usar el comando /tpc me aparece "Introduciste un comando inexistente, escribe /ayuda"?

pawn Код:
if (strcmp(cmdtext, "/tpc", true)==0)
{
new Float:x, Float:y, Float:z;
new tmp[128];
tmp = strtok(cmdtext, idx);
if (!strlen(tmp) || !strlen(tmp)) return SendClientMessage(playerid, 0xFF0000AA, "Usa: /tpc <X> <Y> <Z>");
else
{
SetPlayerPos(playerid, x, y, z);
SendClientMessage(playerid, 0xFF0000AA, "Teletransportado.");
}
return 1;
}



Respuesta: їerror de comando? - Fluid016 - 25.08.2012

Ese comando esta dentro o fuera del gm?
Cuando Usas El Comando Te Funciona y Te Retorna Que No Existe?
O Directamente Te Retorna Que No Existe Y No Funciona?


Respuesta: їerror de comando? - OTACON - 25.08.2012

pawn Код:
#include <a_samp>
#include <gl_common>

public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[128], idx;
    cmd = strtok(cmdtext, idx);
    if(strcmp(cmd, "/tpc", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            new tmp1[128],tmp2[128],tmp3[128];
            tmp1 = strtok(cmdtext, idx);
            tmp2 = strtok(cmdtext, idx);
            tmp3 = strtok(cmdtext, idx);
            if(!strlen(tmp1) && !strlen(tmp2) && !strlen(tmp3)) return SendClientMessage(playerid, -1, "Usa: /tpc <X> <Y> <Z>");

            SetPlayerPos(playerid, strval(tmp1), strval(tmp2), strval(tmp3));
            SendClientMessage(playerid, -1, "Teletransportado.");
        }
        return 1;
    }
    return 0;
}



Re: їerror de comando? - Glimma - 25.08.2012

їPor quй retorna a 0? No sй, pero lo puse debajo de /slap, y el copilador me tira error, por un super error supongo, asн lo coloquй:

pawn Код:
if(strcmp(cmd, "/slap", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(JugadorInfo[playerid][jAdmin] >=1)
            {
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp))
                {
                    SendClientMessage(playerid, GRIS, "Uso: /slap [ID/Nombre]");
                    return 1;
                }
                new playa;
                new Float:shealth;
                new Float:slx, Float:sly, Float:slz;
                playa = ReturnUser(tmp);
                if(IsPlayerConnected(playa))
                {
                    if(playa != INVALID_PLAYER_ID)
                    {
                        GetPlayerName(playa, giveplayer, sizeof(giveplayer));
                        GetPlayerName(playerid, sendername, sizeof(sendername));
                        GetPlayerHealth(playa, shealth);
                        JugadorInfo[playerid][jVida] = shealth-5;
                        SetPlayerHealth(playa, shealth-5);
                        GetPlayerPos(playa, slx, sly, slz);
                        SetPlayerPos(playa, slx, sly, slz+5);
                        PlayerPlaySound(playa, 1130, slx, sly, slz+5);
                        printf("Administraciуn: %s golpeу a %s",sendername,  giveplayer);
                        format(string, sizeof(string), "Administraciуn: %s fue golpeado por %s",giveplayer ,sendername);
                        ABroadCast(ROJO,string,1);
                    }
                }
            }
            else
            {
                SendClientMessage(playerid, ROJO_OSCURO, " No puedes usar este comando!");
                return 1;
            }
        }
        return 1;
    }

    if(strcmp(cmd, "/tpc", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            new tmp1[128],tmp2[128],tmp3[128];
            tmp1 = strtok(cmdtext, idx);
            tmp2 = strtok(cmdtext, idx);
            tmp3 = strtok(cmdtext, idx);
            if(!strlen(tmp1) && !strlen(tmp2) && !strlen(tmp3)) return SendClientMessage(playerid, -1, "Usa: /tpc <X> <Y> <Z>");

            SetPlayerPos(playerid, strval(tmp1), strval(tmp2), strval(tmp3));
            SendClientMessage(playerid, -1, "Teletransportado.");
        }
        return 1;
    }
    return 0;
}



Re: їerror de comando? - Daniel-92 - 25.08.2012

pawn Код:
if(strcmp(cmd, "/tpc", true) == 0)
{
    if(IsPlayerConnected(playerid))
    {
        new tmp1[128],tmp2[128],tmp3[128];
        tmp1 = strtok(cmdtext, idx);
        tmp2 = strtok(cmdtext, idx);
        tmp3 = strtok(cmdtext, idx);
        if(!strlen(tmp1) || !strlen(tmp2) || !strlen(tmp3)) return SendClientMessage(playerid, -1, "Usa: /tpc <X> <Y> <Z>");

        SetPlayerPos(playerid, floatstr(tmp1), floatstr(tmp2), floatstr(tmp3));
        SendClientMessage(playerid, -1, "Teletransportado.");
    }
    return 1;
}



Re: їerror de comando? - Glimma - 26.08.2012

Quote:
Originally Posted by Daniel-92
Посмотреть сообщение
pawn Код:
if(strcmp(cmd, "/tpc", true) == 0)
{
    if(IsPlayerConnected(playerid))
    {
        new tmp1[128],tmp2[128],tmp3[128];
        tmp1 = strtok(cmdtext, idx);
        tmp2 = strtok(cmdtext, idx);
        tmp3 = strtok(cmdtext, idx);
        if(!strlen(tmp1) || !strlen(tmp2) || !strlen(tmp3)) return SendClientMessage(playerid, -1, "Usa: /tpc <X> <Y> <Z>");

        SetPlayerPos(playerid, floatstr(tmp1), floatstr(tmp2), floatstr(tmp3));
        SendClientMessage(playerid, -1, "Teletransportado.");
    }
    return 1;
}
Funcionу correctamente, muchas gracias a todos los que me ayudaron.

Les darй +rep a todos, porque lo que importa es tener las ganas de ayudar, y poner empeсo y esfuerzo.

El de Otacon seguro que sirve, pero algo habrй hecho mal yo, que sуlo me funcionу el de Daniel, en fin, Otacon sabe mucho de script, va en un buen camino.


Respuesta: їerror de comando? - Jose_grana - 26.08.2012

Tu fallo estaba en

pawn Код:
if (!strlen(tmp) || !strlen(tmp)) return SendClientMessage(playerid, 0xFF0000AA, "Usa: /tpc <X> <Y> <Z>");
else//aquн



Respuesta: Re: їerror de comando? - Daniel-92 - 26.08.2012

Quote:
Originally Posted by DeadSkyTkb
Посмотреть сообщение
Funcionу correctamente, muchas gracias a todos los que me ayudaron.

Les darй +rep a todos, porque lo que importa es tener las ganas de ayudar, y poner empeсo y esfuerzo.

El de Otacon seguro que sirve, pero algo habrй hecho mal yo, que sуlo me funcionу el de Daniel, en fin, Otacon sabe mucho de script, va en un buen camino.
El que puse yo es el mismo de otacon corregido, solo cambiй las "&&" por "||" y los "strval" por "floatstr"


Respuesta: Re: їerror de comando? - OTACON - 26.08.2012

Quote:
Originally Posted by Daniel-92
Посмотреть сообщение
El que puse yo es el mismo de otacon corregido, solo cambiй las "&&" por "||" y los "strval" por "floatstr"
lo de floatstr esta bien pero lo de los && no por ke si colocas || si colocan una sola cordenada pasara a la funcion de SetPlayerPos y no teletransportada nada ya ke debes colocar las tres cordenadas para el SetPlayerPos ¬¬ :P.