What is the problem in this loop? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: What is the problem in this loop? (
/showthread.php?tid=333725)
What is the problem in this loop? -
iKn0w - 12.04.2012
PHP Code:
for(new i = 1; i < 4; i++)
{
new p[128];
format(p, 128, "Rope%d", i);
if(Player[playerid][p] != 0)
{
}
}
What is the problem here? it's need to find the first one that not available.
but the problem with the format and the variable.
This is the error:
PHP Code:
error 033: array must be indexed (variable "p")
Re: What is the problem in this loop? -
park4bmx - 12.04.2012
pawn Code:
for(new i = 1; i < 4; i++)
{
new p[128];
format(p, 128, "Rope%d", i);
if(strcmp(p, "TEXT")//comparing the Two Strings
{
}
}
Re: What is the problem in this loop? -
iKn0w - 12.04.2012
But I need in the Player enum.
Player[playerid][p] <
Like:
Player[playerid][Rope1]
Player[playerid][Rope2]
Player[playerid][Rope3]
I want to check what isn't available, if its founded so will happend something.
Re: What is the problem in this loop? -
iKn0w - 12.04.2012
I'll give rep to the person that can help me.
Re: What is the problem in this loop? -
iKn0w - 12.04.2012
Someone?
Re: What is the problem in this loop? -
mineralo - 12.04.2012
I'm not sure what exactly what should do but try
pawn Code:
for(new i = 1; i < 4; i++)
{
new p[128];
format(p, 128, "Rope%d", Player[playerid][i]);
if(Player[playerid][i] != 0)
{
SendClientMessage(playerid,-1,p);
}
}
Re: What is the problem in this loop? -
iKn0w - 12.04.2012
Its not good, Its takes the number not the Ropenumber.
Re: What is the problem in this loop? -
mineralo - 12.04.2012
tell exactly what its should do
Re: What is the problem in this loop? -
Macluawn - 12.04.2012
You could use
Player[playerid][Rope][idx] and then the following code should work.
pawn Code:
for(new i = 1; i != 3; i++)
{
if(Player[playerid][Rope][i] == 0) continue;
//code goes here
}
And change
Player[playerid][Rope1]
Player[playerid][Rope2]
Player[playerid][Rope3]
To
Player[playerid][Rope][4]
in enum