loop problem -
caoraivoso3 - 16.09.2013
well i create a cmd to open my house but it only works proprely whitch house id 0, i cannot open the others because the isplayerinrangeofpoint.
the command:
CMD:abrirporta(playerid,params[])
{
for(new i = 0; i < MAX_CASAS;i++)
{
if(!IsPlayerInRangeOfPoint(playerid,8.0,CInfo[i][entradax],CInfo[i][entraday],CInfo[i][entradaz])) return SendClientMessage(playerid,-1,"estas lonje de casas para abrir.");
if ( CInfo[i][estadocasa] == 1)
{
CInfo[i][estadocasa] = 0;
SendClientMessage(playerid,-1,"fexaste casa.");
return 1;
}
if (CInfo[i][estadocasa] == 0)
{
CInfo[i][estadocasa] = 1;
SendClientMessage(playerid,-1,"abriste casa.");
return 1;
}
}
return 1;
}
anyone can help me?
Re: loop problem -
caoraivoso3 - 16.09.2013
Quote:
Originally Posted by ******
Then don't use "return".
|
but i need to return some value i am using z_cmd
Re: loop problem -
caoraivoso3 - 17.09.2013
anyone can help me with this problem?
Re: loop problem -
DanishHaq - 17.09.2013
pawn Код:
CMD:abrirporta(playerid, params[])
{
for(new i = 0; i < MAX_PLAYERS; i ++)
{
if(!IsPlayerInRangeOfPoint(playerid,8.0,CInfo[i][entradax],CInfo[i][entraday],CInfo[i][entradaz])) return SendClientMessage(playerid,-1,"estas lonje de casas para abrir.");
if(CInfo[i][estadocasa] == 1)
{
CInfo[i][estadocasa] = 0;
SendClientMessage(playerid, -1, "fexaste casa.");
}
else
{
CInfo[i][estadocasa] = 1;
SendClientMessage(playerid, -1, "abriste casa.");
}
}
return 1;
}
Re: loop problem - Patrick - 17.09.2013
Try these and tell me if it works
pawn Код:
CMD:abrirporta(playerid,params[])
{
for(new i = 0; i < MAX_CASAS; i++)
{
if(IsPlayerInRangeOfPoint(playerid, 8.0,CInfo[i][entradax], CInfo[i][entraday], CInfo[i][entradaz]))
{
if (CInfo[i][estadocasa] == 1)
{
CInfo[i][estadocasa] = 0;
SendClientMessage(playerid,-1,"fexaste casa.");
}
else if (CInfo[i][estadocasa] == 0)
{
CInfo[i][estadocasa] = 1;
SendClientMessage(playerid,-1,"abriste casa.");
}
} else return SendClientMessage(playerid,-1,"estas lonje de casas para abrir.");
}
return 1;
}
Re: loop problem -
DanishHaq - 17.09.2013
Quote:
Originally Posted by pds2012
Try these and tell me if it works
pawn Код:
CMD:abrirporta(playerid,params[]) { for(new i = 0; i < MAX_CASAS; i++) { if(IsPlayerInRangeOfPoint(playerid, 8.0,CInfo[i][entradax], CInfo[i][entraday], CInfo[i][entradaz])) { if (CInfo[i][estadocasa] == 1) { CInfo[i][estadocasa] = 0; SendClientMessage(playerid,-1,"fexaste casa."); } else if (CInfo[i][estadocasa] == 0) { CInfo[i][estadocasa] = 1; SendClientMessage(playerid,-1,"abriste casa."); } } else return SendClientMessage(playerid,-1,"estas lonje de casas para abrir."); } return 1; }
|
That won't work because if he's not defined MAX_CASAS, then it will return an error. Try mine, it'll work I'm 99% sure.
Re: loop problem - Patrick - 17.09.2013
Quote:
Originally Posted by DanishHaq
That won't work because if he's not defined MAX_CASAS, then it will return an error. Try mine, it'll work I'm 99% sure.
|
There's no really much difference, they work just the same, but I just edited something and fixed the code that he had. if there's an error, he can post it in here and I could fix it properly, i don't have the whole script which includes the variable and defines he has, obviously we can't really compile that code if there's any error
+ Your code doesn't do with the house system he has, he's trying to
execute a command [/enter] which In my mind
pawn Код:
#define MAX_CASAS (Value)
is equals to MAX_HOUSE, as I translated the meaning of those words before editing and checking the code,
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i ++)
Check's the MAX_PLAYERS which mean players are connected to the server and it doesn't really make sense why
YOU Edited it when he's not basing it on the max connected player, he's try to fix his command
/enter(I guess)
PS: Read the topic first before replying.
Re: loop problem -
caoraivoso3 - 17.09.2013
thanks guys i am not in home bue when i get here i will test it. and i have defined MAX_CASAS but what is the problem here i dont see what pds2012 does. and yes i have enter command that if the player is with the house opened and he is close to the house he can enters.
Re: loop problem - Patrick - 17.09.2013
Quote:
Originally Posted by caoraivoso3
thanks guys i am not in home bue when i get here i will test it. and i have defined MAX_CASAS but what is the problem here i dont see what pds2012 does. and yes i have enter command that if the player is with the house opened and he is close to the house he can enters.
|
If you didn't test it we don't know if it works, but is this a house system? because it's hard to understand when it is in another language. if it is a house system, can you show me the
enum please?
Re: loop problem -
caoraivoso3 - 17.09.2013
the enum is right and i dont have the script but you can ask what you want i can aswer