View Full Version : [AJUDA] alterar comando
caoraivoso3
29/03/2012, 06:46 PM
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.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
Skun Fly
29/03/2012, 07:09 PM
Podes usar: IsPlayerInRangeOfPoint
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
humildadeforever
29/03/2012, 07:34 PM
Usa assim para verificar se está em certo local:
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:
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...
Jason`
29/03/2012, 07:40 PM
Podes usar: IsPlayerInRangeOfPoint
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.
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;
}
Skun Fly
29/03/2012, 07:46 PM
Errado.
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
humildadeforever
29/03/2012, 07:51 PM
Errado.
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:
if(!strcmp("/meucomando",cmdtext))
{
if(IsPlayerInRangeOfPoint(playerid, RAIO, CORDENADAX, CORDENADAY, CORDENADAZ))
{
SendClientMessage(playerid,COR,"Você está no local correto!");
}
return 1;
}
Ou então:
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 :D
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;
}
Jason`
29/03/2012, 07:54 PM
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
caoraivoso3
29/03/2012, 07:56 PM
Ja,agora,aproveito este topic,eu orienteime por voces,fico grato. O comando "finalizado" por min: 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: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: };(A que esta debaixo de (SetPlayerInterior(playerid, 3));Se me podessem ajudar-me agora taMBEM =)
Jason`
29/03/2012, 08:04 PM
Tenta trocar o comando por este:
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;
}
caoraivoso3
29/03/2012, 08:22 PM
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.
Jason`
29/03/2012, 08:25 PM
Tenta trocar
if(!IsPlayerInRangeOfPoint(playerid, 20.0, 364.1921,168.3376,1019.9844))
por
if(IsPlayerInRangeOfPoint(playerid, 20.0, 364.1921,168.3376,1019.9844))
caoraivoso3
29/03/2012, 08:52 PM
Boas,pedro,tem me ajudadado mt,quer dizer,voces todos,mas agora,quando estou dentro da building e uso o comando do anuncio,apareçe"Não estas dentro do negocio" :s
Skun Fly
29/03/2012, 09:07 PM
Boas,pedro,tem me ajudadado mt,quer dizer,voces todos,mas agora,quando estou dentro da building e uso o comando do anuncio,apareçe"Não estas dentro do negocio" :s
Verifica se as coordenadas estão certas e se o interior está certo.
ID's Interiores (http://weedarr.wikidot.com/interior)
caoraivoso3
29/03/2012, 10:07 PM
ja revi,e continua na mesma :s
Felipe_Wesker
29/03/2012, 10:07 PM
Boas,pedro,tem me ajudadado mt,quer dizer,voces todos,mas agora,quando estou dentro da building e uso o comando do anuncio,apareçe"Não estas dentro do negocio" :s
Se está dando isso é porque vc nao está perto da coordenada, faça oque o Skun Fly disse
EDIT: Tenta aumentar o "raio", vai ver voce nao está perto dos 20.0
Skun Fly
29/03/2012, 10:09 PM
ja revi,e continua na mesma :s
qual é o interior que vc quer?
caoraivoso3
29/03/2012, 10:40 PM
e o interior 3,coordenadas:366.9281,162.3711,1019.9844
Felipe_Wesker
29/03/2012, 10:45 PM
cao raivoso, tenta mudar a cordenada para algum lugar na rua mesmo (sem ser no interior) e testa.. vê se vai funcionar o cmd e talz, se funcionar, certamente voce nao está colocando o interior ou as coordenadas certas
caoraivoso3
29/03/2012, 11:06 PM
na rua,ja da,meti a coordenada an rua e defeni o interior como 0,e ja dava pa fazer o anuncio,so que agora,meti novamente o interior 3,e as coordenadas e nada :S
Felipe_Wesker
29/03/2012, 11:38 PM
Entao nao é o interior 3.. ou vc está pegando coords erradas, vc usou o /save dentro do interior?
caoraivoso3
30/03/2012, 07:35 AM
eu ja tentei usar as coordenadas do interior e as coordenadas do /save e nnada
Adicione ao seu OnGameModeInit :p:
AddStaticPickup(1239, 1, 366.9281, 162.3711, 1019.9844, -1);
E depois, ao seu OnPlayerCommandText :mrgreen::
if(strcmp(cmd, "/anuncio", true) == 0 || strcmp(cmd, "/an", true) == 0)
{
if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_DARKRED, "[ERRO:] Não estás logado.");
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)) return SendClientMessage(playerid, COLOR_LIGHTORANGE, "[Comando:] (/an)uncio [texto]");
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;
}
if(!IsPlayerInRangeOfPoint(playerid, 3.0, 366.9281, 162.3711, 1019.9844)) return SendClientMessage(playerid, COLOR_DARKRED, "[ERRO:]Não te encontras na building !");
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;
}
if(strcmp(cmd, "/building", true) == 0)
{
SetPlayerPos(playerid, 366.9281, 162.3711, 1019.9844);
SetPlayerInterior(playerid, 3);
return 1;
}
Um "i amarelo" será criado na posição na qual você tem que estar para mandar o anúncio. Para ir até esse local facilmente, digite /building.
Espero ter ajudado :p.
vBulletin® v3.8.6, Copyright ©2000-2013, Jelsoft Enterprises Ltd.