28.11.2012, 18:46
Hello,
I am having a conflict with variables being assigned (or that is the only thing I can figure). As the script below shows, I'm creating a variable and assigning the value of "1" to it. Inside the OnFilterScriptInit function, I call a custom function, LoadMap, which gets passed that variable. All the function does it print the variable, so it would be expected to print the value "1". However, it prints a value of "109" for me. Here is the script:
I'm assuming there is a problem with memory of the script, however am not sure. I've been screwing around for the past hour or so trying to isolate the problem, and came across something interesting. It seems calling the printf() function before calling LoadMap, it will pass the correct value of 1. Here is the script, which prints the expected result:
Can anyone give me a reason as to why this is happening? I tried using different functions before the LoadMap function as well, but that did not fix the problem either. I suppose only functions that use the variable prior to passing it to LoadMap would fix this issue but have not tested it. My brother had a similar problem quite some time ago (memory of variables getting incorrectly assigned due to function call (assuming that is the problem), which was caused by strcat) and he never got a solution to it.
Thanks.
I am having a conflict with variables being assigned (or that is the only thing I can figure). As the script below shows, I'm creating a variable and assigning the value of "1" to it. Inside the OnFilterScriptInit function, I call a custom function, LoadMap, which gets passed that variable. All the function does it print the variable, so it would be expected to print the value "1". However, it prints a value of "109" for me. Here is the script:
pawn Код:
#include <a_samp>
new
g_CurMap = 1;
public OnFilterScriptInit()
{
LoadMap(g_CurMap);
return 1;
}
stock LoadMap(mapID)
{
printf("mapID: %i", mapID);
}
pawn Код:
#include <a_samp>
new
g_CurMap = 1;
public OnFilterScriptInit()
{
printf("g_CurMap: %i", g_CurMap);
LoadMap(g_CurMap);
return 1;
}
stock LoadMap(mapID)
{
printf("mapID: %i", mapID);
}
Thanks.