[AJUDA] alterar comando
#1

Boas malta,eu tinha o comando /anuncio,que era quando o player entrasse numa business,ele usava /anuncio e fazia o seu anuncio,so que alterei,para nгo ser anuncio. Comando do Anuncio.
pawn Код:
if(strcmp(cmd, "/anuncio", true) == 0 || strcmp(cmd, "/an", true) == 0)
        {
            if(IsPlayerConnected(playerid))
            {
                if(gPlayerLogged[playerid] == 0)
                {
                    SendClientMessage(playerid, COLOR_DARKRED, "[ERRO:] Nгo estбs logado.");
                    return 1;
                }
                new length = strlen(cmdtext);
                while ((idx < length) && (cmdtext[idx] <= ' '))
                {
                    idx++;
                }
                new offset = idx;
                new result[128];
                while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
                {
                    result[idx - offset] = cmdtext[idx];
                    idx++;
                }
                result[idx - offset] = EOS;
                if(!strlen(result))
                {
                    SendClientMessage(playerid, COLOR_LIGHTORANGE, "[Comando:] (/an)uncio [texto]");
                    return 1;
                }
                {
                   if(GetPlayerVirtualWorld(playerid) == -1)
                         {
                                    if ((!adds) && (PlayerInfo[playerid][mstrvbcAdmin] < 1))
                                    {
                                        format(string, sizeof(string), "Aguarda %d segundos para fazeres outro anъncio.",  (addtimer/1000));
                                        SendClientMessage(playerid, COLOR_WHITE, string);
                                        return 1;

                                    }
                                    new payout = idx * 15;
                                    if(GetPlayerEuros(playerid) < payout)
                                    {
                                        SendClientMessage(playerid, COLOR_DARKRED, "[ERRO:]Nгo tens dinheiro suficiente para fazeres publicidade.");
                                        return 1;
                                    }
                                    GivePlayerEuros(playerid, - payout);
                                    format(string, sizeof(string), "___________________________[Publicidade]___________________________");
                                    SendClientMessageToAll(COLOR_LIGHTGREEN,string);
                                    format(string, sizeof(string), "[Anъncio:] %s",  result);
                                    SendClientMessageToAll(COLOR_WHITE,string);
                                    format(string, sizeof(string), "[Anъncio:] Publicidade por: %s - Nъmero De Telemуvel: %d.",  GetPlayerNameEx(playerid),PlayerInfo[playerid][msPhoneNumber]);
                                    SendClientMessageToAll(COLOR_WHITE,string);
                                    SendClientMessageToAll(COLOR_LIGHTGREEN,"________________________________________________________________________________________________________________________");
                                    if (PlayerInfo[playerid][mstrvbcAdmin] < 1){SetTimer("AddsOn", addtimer, 0);adds = 0;}
                                    format(string, sizeof(string), " Caracteres contidos: %d - Preзo: %dЂ - Obrigado pelo seu anъncio.");
                                    SendClientMessage(playerid,COLOR_WHITE,string);
                                    PlayerActionMessage(playerid,15.0,"Deu algum dinheiro ao jornalista e fez o seu anuncio");
                                    return 1;
                                }
                                else
                                {
                                 SendClientMessage(playerid, COLOR_WHITE, "Nгo te encontras no Negуcio.");
                        }
                    }
                }
                return 1;
            }
eu queria que,quando o player tivesse dentro de um interior numas certas coordenadas,podesse fazer o anuncio,se tivesse fora do interior nгo desse. Exemplo: Player ta na rua,usa /anuncio e apareзia,"Tens que estar no estabelecimento da news". Se o player tivesse dentro do interior numas coordenadas,ja podesse fazer o /anuncio. Ajudem-me malta :S
Reply
#2

Podes usar: IsPlayerInRangeOfPoint

pawn Код:
if(!strcmp("/meucomando",cmdtext))
{
    if(IsPlayerInRangeOfPoint(playerid,RAIO, CORDENADAX, CORDENADAY, CORDENADAZ))
    {
        SendClientMessage(playerid,COR,"[ERRO] Vai para o local correto para usares /meucomando");
    }
    return 1;
}
Se precisar de mais ajuda ou se der algum erro posta
Ajudei? +resp <----

@EDIT Faltou o raio
Reply
#3

Usa assim para verificar se estб em certo local:
pawn Код:
if(!IsPlayerInRangeOfPoint(playerid,raio, coordenadas do local)) return SendClientMessage(playerid,-1,"Vocк nгo estб no local.");
//resto do cmd
E para verificar se estб no interior que vocк quer usa assim:
pawn Код:
if(GetPlayerInterior(playerid) != interior q voce quer) return SendClientMessage(playerid,-1,"Vocк precisa tб no interior interiorid");
//resto do cmd
Se estiver errada desculpe-me, nгo estou muito bem hoje...
Reply
#4

Quote:
Originally Posted by Skun Fly
Посмотреть сообщение
Podes usar: IsPlayerInRangeOfPoint

pawn Код:
if(!strcmp("/meucomando",cmdtext))
{
    if(IsPlayerInRangeOfPoint(playerid, CORDENADAX, CORDENADAY, CORDENADAZ))
    {
        SendClientMessage(playerid,COR,"[ERRO] Vai para o local correto para usares /meucomando");
    }
    return 1;
}
Se precisar de mais ajuda ou se der algum erro posta
Ajudei? +resp <----
Errado.

pawn Код:
if(!strcmp("/meucomando",cmdtext))
{
    if(!IsPlayerInRangeOfPoint(playerid, RAIO, CORDENADAX, CORDENADAY, CORDENADAZ))
        return SendClientMessage(playerid,COR,"[ERRO] Vai para o local correto para usares /meucomando");
    return 1;
}
Reply
#5

Quote:
Originally Posted by Pedro_Miranda
Посмотреть сообщение
Errado.

pawn Код:
if(!strcmp("/meucomando",cmdtext))
{
    if(IsPlayerInRangeOfPoint(playerid, RAIO, CORDENADAX, CORDENADAY, CORDENADAZ))
    {
        SendClientMessage(playerid,COR,"[ERRO] Vai para o local correto para usares /meucomando");
    }
    return 1;
}
Й verdade, esqueci o raio '-' vlw
Vou jб editar
Reply
#6

Quote:
Originally Posted by Pedro_Miranda
Посмотреть сообщение
Errado.

pawn Код:
if(!strcmp("/meucomando",cmdtext))
{
    if(IsPlayerInRangeOfPoint(playerid, RAIO, CORDENADAX, CORDENADAY, CORDENADAZ))
    {
        SendClientMessage(playerid,COR,"[ERRO] Vai para o local correto para usares /meucomando");
    }
    return 1;
}
O certo nгo seria:
pawn Код:
if(!strcmp("/meucomando",cmdtext))
{
    if(IsPlayerInRangeOfPoint(playerid, RAIO, CORDENADAX, CORDENADAY, CORDENADAZ))
    {
        SendClientMessage(playerid,COR,"Vocк estб no local correto!");
    }
    return 1;
}
Ou entгo:
pawn Код:
if(!strcmp("/meucomando",cmdtext))
{
    if(!IsPlayerInRangeOfPoint(playerid, RAIO, CORDENADAX, CORDENADAY, CORDENADAZ))// !
    {
        SendClientMessage(playerid,COR,"[ERRO] Vai para o local correto para usares /meucomando");
    }
    return 1;
}
Ou de uma forma mais pequena
pawn Код:
if(!strcmp("/meucomando",cmdtext))
{
    if(!IsPlayerInRangeOfPoint(playerid, RAIO, CORDENADAX, CORDENADAY, CORDENADAZ)) return SendClientMessage(playerid,COR,"[ERRO] Vai para o local correto para usares /meucomando");
    //funзoes do comando, exemplo:
    SendClientMessage(playerid,-1,"Vocк digitou o comando no lugar certo e ganhou uma arminha :)");
    GivePlayerWeapon(playerid, 24,100);
    return 1;
}
Reply
#7

Verdade

Estб correto apenas na segunda forma, na primeira vai dizer que nгo estб no local mas as funзхes seguintes serгo executadas da mesma forma (caso hajam), deveria ter posto return 1; :P
Reply
#8

Ja,agora,aproveito este topic,eu orienteime por voces,fico grato. O comando "finalizado" por min:
pawn Код:
if(strcmp(cmd, "/anuncio", true) == 0 || strcmp(cmd, "/an", true) == 0)
        {
            if(IsPlayerConnected(playerid))
            {
                if(gPlayerLogged[playerid] == 0)
                {
                    SendClientMessage(playerid, COLOR_DARKRED, "[ERRO:] Nгo estбs logado.");
                    return 1;
                }
                new length = strlen(cmdtext);
                while ((idx < length) && (cmdtext[idx] <= ' '))
                {
                    idx++;
                }
                new offset = idx;
                new result[128];
                while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
                {
                    result[idx - offset] = cmdtext[idx];
                    idx++;
                }
                result[idx - offset] = EOS;
                if(!strlen(result))
                {
                    SendClientMessage(playerid, COLOR_LIGHTORANGE, "[Comando:] (/an)uncio [texto]");
                    return 1;
                }
                {
                if(!IsPlayerInRangeOfPoint(playerid, 20.0, 364.1921,168.3376,1019.9844))
                  (SetPlayerInterior(playerid, 3));
                   };
                   {
                    if(GetPlayerVirtualWorld(playerid) == 3)
                         {
                                    if ((!adds) && (PlayerInfo[playerid][mstrvbcAdmin] < 1))
                                    {
                                        format(string, sizeof(string), "Aguarda %d segundos para fazeres outro anъncio.",  (addtimer/1000));
                                        SendClientMessage(playerid, COLOR_WHITE, string);
                                        return 1;

                                    }
                                    new payout = idx * 15;
                                    if(GetPlayerEuros(playerid) < payout)
                                    {
                                        SendClientMessage(playerid, COLOR_DARKRED, "[ERRO:]Nгo tens dinheiro suficiente para fazeres publicidade.");
                                        return 1;
                                    }
                                    GivePlayerEuros(playerid, - payout);
                                    format(string, sizeof(string), "___________________________[Publicidade]___________________________");
                                    SendClientMessageToAll(COLOR_LIGHTGREEN,string);
                                    format(string, sizeof(string), "[Anъncio:] %s",  result);
                                    SendClientMessageToAll(COLOR_WHITE,string);
                                    format(string, sizeof(string), "[Anъncio:] Publicidade por: %s - Nъmero De Telemуvel: %d.",  GetPlayerNameEx(playerid),PlayerInfo[playerid][msPhoneNumber]);
                                    SendClientMessageToAll(COLOR_WHITE,string);
                                    SendClientMessageToAll(COLOR_LIGHTGREEN,"________________________________________________________________________________________________________________________");
                                    if (PlayerInfo[playerid][mstrvbcAdmin] < 1){SetTimer("AddsOn", addtimer, 0);adds = 0;}
                                    format(string, sizeof(string), " Caracteres contidos: %d - Preзo: %dЂ - Obrigado pelo seu anъncio.");
                                    SendClientMessage(playerid,COLOR_WHITE,string);
                                    PlayerActionMessage(playerid,15.0,"Deu algum dinheiro ao jornalista e fez o seu anuncio");
                                    return 1;
                                }
                                else
                                {
                                 SendClientMessage(playerid, COLOR_WHITE, "Nгo te encontras no Negуcio.");
                        }
                    }
                }
                return 1;
            }
ficou assim comando,mas dame somente 1 erro:
pawn Код:
C:\Users\Jesus\Desktop\Comunidade OG\OG\pawno\include\a_players.inc(125) : warning 201: redefinition of constant/macro (symbol "MAX_PLAYER_ATTACHED_OBJECTS")
C:\Users\Jesus\Desktop\Comunidade OG\OG\pawno\include\JunkBuster.inc(1084) : warning 209: function "F_SetPlayerPos" should return a value
C:\Users\Jesus\Desktop\Comunidade OG\OG\pawno\include\JunkBuster.inc(3126) : warning 201: redefinition of constant/macro (symbol "SetPlayerPos")
C:\Users\Jesus\Desktop\Comunidade OG\OG\gamemodes\OG-RP.pwn(5307) : warning 225: unreachable code
C:\Users\Jesus\Desktop\Comunidade OG\OG\gamemodes\OG-RP.pwn(6227) : error 036: empty statement
C:\Users\Jesus\Desktop\Comunidade OG\OG\gamemodes\OG-RP.pwn(52764) : warning 203: symbol is never used: "FloodAn"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
eu colocei cm vcs diseram,principalmente como a humilde disse,depois fiz uns pequenos edits,e ficou assim(comando acima). Linha do erro:
pawn Код:
};
(A que esta debaixo de
pawn Код:
(SetPlayerInterior(playerid, 3));
Se me podessem ajudar-me agora taMBEM =)
Reply
#9

Tenta trocar o comando por este:

pawn Код:
if(strcmp(cmd, "/anuncio", true) == 0 || strcmp(cmd, "/an", true) == 0)
{
    if(IsPlayerConnected(playerid))
    {
        if(gPlayerLogged[playerid] == 0)
        {
            SendClientMessage(playerid, COLOR_DARKRED, "[ERRO:] Nгo estбs logado.");
            return 1;
        }
        new length = strlen(cmdtext);
        while ((idx < length) && (cmdtext[idx] <= ' '))
        {
            idx++;
        }
        new offset = idx;
        new result[128];
        while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
        {
            result[idx - offset] = cmdtext[idx];
            idx++;
        }
        result[idx - offset] = EOS;
        if(!strlen(result))
        {
            SendClientMessage(playerid, COLOR_LIGHTORANGE, "[Comando:] (/an)uncio [texto]");
            return 1;
        }
        if(!IsPlayerInRangeOfPoint(playerid, 20.0, 364.1921,168.3376,1019.9844))
        {
            if(GetPlayerVirtualWorld(playerid) == 3)
            {
                SetPlayerInterior(playerid, 3));
                if ((!adds) && (PlayerInfo[playerid][mstrvbcAdmin] < 1))
                {
                    format(string, sizeof(string), "Aguarda %d segundos para fazeres outro anъncio.",  (addtimer/1000));
                    SendClientMessage(playerid, COLOR_WHITE, string);
                    return 1;
                }
                new payout = idx * 15;
                if(GetPlayerEuros(playerid) < payout)
                {
                    SendClientMessage(playerid, COLOR_DARKRED, "[ERRO:]Nгo tens dinheiro suficiente para fazeres publicidade.");
                    return 1;
                }
                GivePlayerEuros(playerid, - payout);
                format(string, sizeof(string), "___________________________[Publicidade]___________________________");
                SendClientMessageToAll(COLOR_LIGHTGREEN,string);
                format(string, sizeof(string), "[Anъncio:] %s",  result);
                SendClientMessageToAll(COLOR_WHITE,string);
                format(string, sizeof(string), "[Anъncio:] Publicidade por: %s - Nъmero De Telemуvel: %d.",  GetPlayerNameEx(playerid),PlayerInfo[playerid][msPhoneNumber]);
                SendClientMessageToAll(COLOR_WHITE,string);
                SendClientMessageToAll(COLOR_LIGHTGREEN,"________________________________________________________________________________________________________________________");
                if (PlayerInfo[playerid][mstrvbcAdmin] < 1)
                {
                    SetTimer("AddsOn", addtimer, 0);
                    adds = 0;
                }
                format(string, sizeof(string), " Caracteres contidos: %d - Preзo: %d€ - Obrigado pelo seu anъncio.");
                SendClientMessage(playerid,COLOR_WHITE,string);
                PlayerActionMessage(playerid,15.0,"Deu algum dinheiro ao jornalista e fez o seu anuncio");
                return 1;
            }
            else
            {
                SendClientMessage(playerid, COLOR_WHITE, "Nгo te encontras no Negуcio.");
            }
        }
    }
    return 1;
}
Reply
#10

agora eu entro no server,entro na building,e uso /an,apareзe "[Comando:] (/an)uncio [texto]",mas quando uso /anuncio compro batatas,nгo acontece nada,nao aparece mensagem e nem apareзe o anuncio.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)