you dont need it, normally.
but it comes in handy for debugging stuff.
for example, static variables are of course static
and thus remain somewhere in the memory.
the following code proves that these Variables
can still be accessed, if you have their address.
pawn Code:
#include <a_samp>
public OnFilterScriptInit()
{
printf("static abc: %d",ReadAmxMemory(myfunc()));
return 1;
}
myfunc()
{
static abc=200;//remains after execution!
return ref(abc);
}
ref(...)
{
assert(numargs() == 1);
#emit load.s.pri 12 // first argument
#emit retn
return 0; // make compiler happy
}
ReadAmxMemory(address)
{
#emit lref.s.pri address
#emit retn
return 0; // make compiler happy
}
like it's said in the comments, "return 0" is just there so that
the compiler is "happy" and not throwing some warnings.
"return 0" actually never gets executed as "#emit retn" jumps back to the program pointer, decreasing the stack pointer by 1
What happens here is
1) ReadAmxMemory // reading from an address, specifyed by us
2) create a static variable "abc" and return a reference of abc for ReadAmxMemory
3) Now ReadAmxMemory has the address of abc after myfunc got executed
4) it'll print "static abc: 200", proving that stic really means static :P
ye... but really, you dont need it.
doing
instead of
is fine too