SA-MP Forums Archive
Need help... - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Need help... (/showthread.php?tid=170866)



Need help... - Libra_PL - 24.08.2010

Well, I was trying to make a Hidden Package script... But I something fucked up, now can anyone help me?

Код:
new str[128],Nick[24]; //Here is the error...
	GetPlayerName(playerid,Nick,24);
	new Cash = (random(30)+20)*5000;
	format(str,128,"~b~Player ~r~%s ~b~found hidden package and won ~g~%d$!",Nick,Cash);
	GameTextForAll(params[(strlen(tmp)+strlen(tmp2)+2)], strval(tmp2), strval(tmp));
	GivePlayerMoney(playerid,Cash);
	DestroyObject(Package);
	Package=0;
	}
Errors:

...\filterscripts\Adminscript.pwn(497 : error 003: declaration of a local variable must appear in a compound block
...\filterscripts\Adminscript.pwn(497 : error 017: undefined symbol "str"
...\filterscripts\Adminscript.pwn(497 : warning 215: expression has no effect
...\filterscripts\Adminscript.pwn(497 : error 001: expected token: ";", but found "]"
...\filterscripts\Adminscript.pwn(497 : fatal error 107: too many error messages on one line

Anyway, thanks for the help...

Lib


Re: Need help... - Vince - 24.08.2010

And what comes before that line?


Re: Need help... - playbox12 - 24.08.2010

Nvm what I said.

And we indeed need the above lines

Quote:

declaration of a local variable must appear in a compound block


The declaration of a local variable must appear between braces
(“{. . .}”) at the active scope level.
When the parser flags this error, a variable declaration appears
as the only statement of a function or the only statement below
an if, else, for, while or do statement. Note that, since local
variables are accessible only from (or below) the scope that their
declaration appears in, having a variable




Re: Need help... - Vince - 24.08.2010

Quote:
Originally Posted by playbox12
Посмотреть сообщение
pawn Код:
new str[128];
new Nick[24];
I think that would do the trick
There's absolutely nothing wrong with writing it like he did.
You can do:

pawn Код:
new str[128], Nick[24];

// or

new str[128];
new Nick[24];

// or

new
    str[128],
    Nick[24];



Re: Need help... - playbox12 - 24.08.2010

Yeah I edited my post after I posted it, I saw that I did it wrong :P


Re: Need help... - Libra_PL - 24.08.2010

Quote:
Originally Posted by Vince
Посмотреть сообщение
And what comes before that line?
Well, here it is (on OnPlayerPickUpPickup)...

Код:
if(pickupid == Package)

	new str[128],Nick[24];
	GetPlayerName(playerid,Nick,24);
	new Cash = (random(30)+20)*5000;
	format(str,128,"~b~Player ~r~%s ~b~found hidden package and won ~g~%d$!",Nick,Cash);
	GameTextForAll(params[(strlen(tmp)+strlen(tmp2)+2)], strval(tmp2), strval(tmp));
	GivePlayerMoney(playerid,Cash);
	DestroyPickup(Package);
	Package=0;
	}
And I'm not sure about these lines below:

Код:
new str[128],Nick[24];
Correct me if I'm wrong here

Lib