Raised This Month: $51 Target: $400
 12% 

[TUT] Dynamic / Fake Natives


Post New Thread Reply   
 
Thread Tools Display Modes
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-29-2012 , 19:39   Re: [TUT] Dynamic / Fake Natives
Reply With Quote #21

Because g_iUserID[] is never filled anywhere in the plugin, it's your job to do so...
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-29-2012 , 19:41   Re: [TUT] Dynamic / Fake Natives
Reply With Quote #22

Quote:
Originally Posted by V I R U S View Post
I have a question about returning a local value:


PHP Code:
#include <amxmodx>

new g_iUserID[33];

public 
plugin_init()
register_plugin("Dynamic Native Test - Handler""1.0""Hawk552")

public 
plugin_natives() {
  
register_library("dyn_test")
  
register_native("getid","_getid")
}

// Here some other functions which set the UserID

public _getid(id) {
  return 
g_iUserID[id];

PHP Code:
#include <amxmodx>
#include <dyn_test>

public plugin_init()   
register_plugin("Dynamic Native Test - Caller""1.0""Hawk552")   

public 
client_putinserver(id) {
  
server_print("UserID: %i"getid(id));

PHP Code:
#pragma reqlib "dyn_test"

native getid(id
Sooooo, i can compile this without a single error. The trouble is, that the caller doesn't return a value. It's simple empty.

Some trick?
You need to re-look at the example in the first post. You are trying to pass "id" through the function which doesn't work like that (with the way you register the native).
__________________
fysiks is offline
V I R U S
Senior Member
Join Date: Jul 2004
Location: Russia / Germany
Old 01-29-2012 , 20:17   Re: [TUT] Dynamic / Fake Natives
Reply With Quote #23

fysiks,
you mean this part?
PHP Code:
public _getid(id
ConnorMcLeod,
take look at this part
PHP Code:
// Here some other functions which set the UserID 
There is an other function which uses MySQL.



If i call the g_iUserID[id]directly, it works like a charm...
__________________
V I R U S is offline
Send a message via ICQ to V I R U S
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-29-2012 , 20:22   Re: [TUT] Dynamic / Fake Natives
Reply With Quote #24

Quote:
Originally Posted by V I R U S View Post
fysiks,
you mean this part?
PHP Code:
public _getid(id
Yes. Notice how it doesn't match the example.
__________________
fysiks is offline
V I R U S
Senior Member
Join Date: Jul 2004
Location: Russia / Germany
Old 01-29-2012 , 20:26   Re: [TUT] Dynamic / Fake Natives
Reply With Quote #25

But it seems to work if i just print the "id" in server console. Seems that the parameter "id" works...
PHP Code:
public _getid(iPluginiParams) {
  if(
iParams != 1)
    return 
PLUGIN_CONTINUE
  
  
new id get_param(1)
  if(!
id)
    return 
PLUGIN_CONTINUE
  
  server_print
("ID: %i"id);
  
server_print("UserID: %s"g_iUserID[id]);        
    
  return 
PLUGIN_HANDLED

1st print is ok, 2nd is empty...
__________________

Last edited by V I R U S; 01-29-2012 at 20:32.
V I R U S is offline
Send a message via ICQ to V I R U S
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-29-2012 , 20:34   Re: [TUT] Dynamic / Fake Natives
Reply With Quote #26

You are trying to print a string with a scalar value (I'm assuming your variable name is accurate).
__________________

Last edited by fysiks; 01-29-2012 at 20:35.
fysiks is offline
V I R U S
Senior Member
Join Date: Jul 2004
Location: Russia / Germany
Old 01-29-2012 , 20:54   Re: [TUT] Dynamic / Fake Natives
Reply With Quote #27

Quote:
Originally Posted by fysiks View Post
You are trying to print a string with a scalar value (I'm assuming your variable name is accurate).
I've tryed it with all possible types, string, integer, bool... No one works.
BTW, that was just a misstype =)
__________________

Last edited by V I R U S; 01-29-2012 at 20:55.
V I R U S is offline
Send a message via ICQ to V I R U S
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-29-2012 , 21:28   Re: [TUT] Dynamic / Fake Natives
Reply With Quote #28

Quote:
Originally Posted by V I R U S View Post
I've tryed it with all possible types, string, integer, bool... No one works.
BTW, that was just a misstype =)
Then there is something wrong with the array or it doesn't contain anything. Show the full code.
__________________
fysiks is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-30-2012 , 01:20   Re: [TUT] Dynamic / Fake Natives
Reply With Quote #29

Since we know that returning an integer via dynamic natives works fine, you may post in scripting/help forum.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 06-29-2012 , 14:34   Re: [TUT] Dynamic / Fake Natives
Reply With Quote #30

I'm having trouble loading my extension plugin. I think it has to do with the .inc file. I tried with #pragma reqlib FragsBrass with and without quotes. (the file name is FragsBrass.inc) But it just doesn't seem to work. Am i missing something?

Core Program:
Spoiler


FragsBrass.inc:
Spoiler


My Extension:
Spoiler


seen in brass_powers.sma:
bkf_setPowers(id) is a working forward defined in the core. It was tested before i included the header, and the workings thereof.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:10.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode