More like programming help - Problem with GetPlayerPos
#1

I know it doesn't belong to scripting, but I want to get values from an invoked native from AMX by using a plugin, without using any premade GDKs for example "Invoke" or "sampgdk". I can already invoke natives, set their arguments properly and get its return value, because I already get their pointers during AMXLoad. But if I try to get values from example GetPlayerPos, it will return NULL from its three arguments (x, y, and z). Do you have any clue, how to get its arguments properly?

I would really appreciate some help from you.

Code snippets:
http://pastebin.com/sp9Ycp8D

Best regards

~ BigETI

P.S.: Do not suggest me to use premade GDKs, because I know what I am doing...
Reply
#2

What's the point of reading GetPlayerPos() parameters if you they are supposed to be set by you (or the server)? Anyway, the x, y and z parameters are passed by reference, so you have to obtain their address first (with amx_GetAddr), and then dereference it to get/set the actual value.

Quote:
Originally Posted by BigETI
Посмотреть сообщение
without using any premade GDKs
Quote:
Originally Posted by BigETI
Посмотреть сообщение
Do not suggest me to use premade GDKs
Are there multiple ones?
Reply
#3

Does it matter, if I try to use amx_GetAddr at its initialization or inside the selfmade GetPlayerPos function?
And can you show me a small example, please?

Quote:
Originally Posted by xeeZ
Посмотреть сообщение
Are there multiple ones?
I just wanted to say that in a general way...
Reply
#4

It's to be done inside GetPlayerPos, see the "Passing parameters by reference" section of the Plugin development guide:

https://sampforum.blast.hk/showthread.php?pid=1507428#pid1507428
Reply
#5

I thought you can only use amx_GetAddr inside a selfmade native function thing, since the "cell *params" argument can be picked and used to return the physical address.
Like:
http://pastebin.com/nXvq7Nrm

But in my scenario I can't image how I am supposed to use amx_GetAddr on a hooked native's params.

These are my attempts: http://pastebin.com/k3DXn0Ff
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)