Have some problems with local variable x! Please help me out. - 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: Have some problems with local variable x! Please help me out. (
/showthread.php?tid=386357)
Have some problems with local variable x! Please help me out. -
Scrillex - 20.10.2012
PHP код:
public playerTabbedLoop() {
foreach(Player, x) { [B][I][U]//ERROR LINE![/U][/I][/B]
if(playerVariables[x][pTabbed] == 0 && IsValidDynamic3DTextLabel(playerVariables[x][pAFKLabel]))
DestroyDynamic3DTextLabel(playerVariables[x][pAFKLabel]);
playerVariables[x][pConnectedSeconds] += 1;
if(playerVariables[x][pConnectedSeconds] < gettime()-1 && playerVariables[x][pTabbed] != 1 && playerVariables[x][pConnectedSeconds] >= 5 && GetPlayerState(x) != 9 && GetPlayerState(x) != 0 && GetPlayerState(x) != 7) {
playerVariables[x][pTabbed] = 1;
playerVariables[x][pAFKLabel] = CreateDynamic3DTextLabel("Paused.", COLOR_RED, 0, 0, 0, 7.5, x, _, 1, _, _, _, 7.5);
}
}
return 1;
}
Error:
PHP код:
warning 219: local variable "x" shadows a variable at a preceding level
warning 213: tag mismatch
warning 206: redundant test: constant expression is non-zero
error 022: must be lvalue (non-constant)
warning 215: expression has no effect
error 001: expected token: ";", but found ")"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line
Please help me out.
With respect Scrillex.
Thanks for your time.
Re: Have some problems with local variable x! Please help me out. -
_Khaled_ - 20.10.2012
Sorry, removed.
Re: Have some problems with local variable x! Please help me out. -
Scrillex - 20.10.2012
I know that it's shadowing only.. but why the rest errors are there?
+Checked script no x what have been defined isn't there..
I think it's some kinda glich or something...
+ still same errors if I change it to your code!
Re: Have some problems with local variable x! Please help me out. -
HyDrAtIc - 20.10.2012
Maybe?
Код:
public playerTabbedLoop() {
foreach(Player, x; { //ERROR LINE!
if(playerVariables[x][pTabbed] == 0 && IsValidDynamic3DTextLabel(playerVariables[x][pAFKLabel]))
DestroyDynamic3DTextLabel(playerVariables[x][pAFKLabel]);
playerVariables[x][pConnectedSeconds] += 1;
if(playerVariables[x][pConnectedSeconds] < gettime()-1 && playerVariables[x][pTabbed] != 1 && playerVariables[x][pConnectedSeconds] >= 5 && GetPlayerState(x) != 9 && GetPlayerState(x) != 0 && GetPlayerState(x) != 7) {
playerVariables[x][pTabbed] = 1;
playerVariables[x][pAFKLabel] = CreateDynamic3DTextLabel("Paused.", COLOR_RED, 0, 0, 0, 7.5, x, _, 1, _, _, _, 7.5);
}
}
return 1;
}
Re: Have some problems with local variable x! Please help me out. -
_Khaled_ - 20.10.2012
Yea what I did was obviously wrong that's why I removed it :/
Sorry.
Re: Have some problems with local variable x! Please help me out. -
Scrillex - 20.10.2012
NOP! Still same! To _Khaled_ All okay mate