[HELP]Understanding parameters - 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: [HELP]Understanding parameters (
/showthread.php?tid=394404)
[HELP]Understanding parameters -
CoDeZ - 22.11.2012
Hello, i wanted to know if parameters will share with other callbacks so i made this simple test script
pawn Код:
#include <a_samp>
main ()
{
}
public OnGameModeInit()
{
SetTimer("TestCallBack",1000,0);
SetTimer("TestCallBack2",1500,0);
return 1;
}
forward TestCallBack(string[],integer);
public TestCallBack(string[],integer)
{
integer=50;
return 1;
}
forward TestCallBack2(string[],integer);
public TestCallBack2(string[],integer)
{
printf("string=%s",string);
printf("integer=%d",integer);
return 1;
}
and i got this printed.
Код:
[15:15:34] string=TestCallBack
[15:15:34] integer=50
So conclusion is, parameters are shared with other callbacks, but the questions is :
why string = TestCallBack not TestCallBack2?
Also, when i tried to add this under testcallback callback.
i got this one
Код:
test.pwn(15) : error 046: unknown array size (variable "string")
so added an array size like this.
But then, i get this error.
Код:
test.pwn(15) : error 006: must be assigned to an array
Can someone please explain it?
Re: [HELP]Understanding parameters -
xMCx - 22.11.2012
it worked like that
pawn Код:
#include <a_samp>
main ()
{
}
public OnGameModeInit()
{
SetTimer("TestCallBack",1000,0);
SetTimer("TestCallBack2",1500,0);
return 1;
}
forward TestCallBack(integer);
public TestCallBack(integer)
{
new string[12];
integer=50;
string="Hello";
return 1;
}
forward TestCallBack2(string[],integer);
public TestCallBack2(string[],integer)
{
printf("string=%s",string);
printf("integer=%d",integer);
return 1;
}
but idk..
Re: [HELP]Understanding parameters -
CoDeZ - 22.11.2012
But what if i want to share the string between the two call backs?