SA-MP Forums Archive
Problem with variable. [+rep] - 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: Problem with variable. [+rep] (/showthread.php?tid=333756)



Problem with variable. [+rep] - iKn0w - 12.04.2012

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?


Re: Problem with variable. [+rep] - ...: 1 :... - 12.04.2012

Errors?
Also, if "rope" is a number, use %i.


Re: Problem with variable. [+rep] - IstuntmanI - 12.04.2012

...: 1 :...: (lol) %d and %i are for numbers.

Post the errors. Also don't create a variable in a loop.


Re: Problem with variable. [+rep] - Macluawn - 12.04.2012

using strings in array dimensions shouldnt work..
See this


Re: Problem with variable. [+rep] - iKn0w - 12.04.2012

No!
I just want to check in the variable enum: Player if the Rope1, Rope2, Rope3.

Player[playerid][Rope1] etc...

-_-
Someone know the problem?!


Re: Problem with variable. [+rep] - ikkentim - 12.04.2012

#define MAX_ROPES 4

enum pInfo
{
Ropes[MAX_ROPES]
}
Players[MAX_PLAYERS][pInfo];

for(new i = 0; i < MAX_ROPES; i++)
{
if(Player[playerid][Ropes][i] != 0)
{

}
}