[HELP]Understanding parameters
#1

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.
pawn Код:
string="Hello";
i got this one
Код:
test.pwn(15) : error 046: unknown array size (variable "string")
so added an array size like this.
pawn Код:
string[10]="Hello";
But then, i get this error.
Код:
test.pwn(15) : error 006: must be assigned to an array
Can someone please explain it?
Reply
#2

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..
Reply
#3

But what if i want to share the string between the two call backs?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)