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

Retrieving strings using fake natives.....[Solved]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
abdul-rehman
Veteran Member
Join Date: Jan 2010
Location: Khi, Pakistan
Old 07-11-2010 , 14:45   Retrieving strings using fake natives.....[Solved]
Reply With Quote #1

I tried many ways of retrieving strings using dynamic natives but i failed this is the main plugin that i was using:
Code:
#include <amxmodx> #include <amxmisc> public plugin_natives() {     register_native("get_persons_name", "_get_persons_name", 1) } public _get_persons_name(plugin, paramsnum) {     // No parameters passed     if(!paramsnum)         return -1         new name[32]     get_user_name(get_param(1), name, 30)     set_string(2, name, get_param(3))     return 1 }

sub plugin looks like this
i use the native to retrieve a persons name [Its just for testing purposes]
Code:
#include <amxmodx> #include <amxmisc> #include < name > public plugin_init() {     // Plugin registeration     register_plugin("-New","1.0","@bdul!")         register_clcmd("say test", "hook") } public hook(id) {     new name[32]     get_persons_name(id, name, charsmax(name))         client_print( id, print_chat, "******* Your Name : %s", name) }

Include file looks like this:
PHP Code:
#if defined _name_included
  #endinput
#endif
#define _name_included

native get_persons_nameid, const string[], len 
The Problem:
When i type test for checking i get this stupid run-time error:
PHP Code:
L 07/11/2010 23:27:57Wrong style of dynamic native
L 07
/11/2010 23:27:57: [AMXXRun time error 10 (plugin "example.amxx") (native "get_param") - debug not enabled!
L 07/11/2010 23:27:57: [AMXXTo enable debug modeadd "debug" after the plugin name in plugins.ini (without quotes).
L 07/11/2010 23:27:57Unhandled dynamic native error
L 07
/11/2010 23:27:57: [AMXXRun time error 10 (plugin "working.amxx") (native "get_persons_name") - debug not enabled!
L 07/11/2010 23:27:57: [AMXXTo enable debug modeadd "debug" after the plugin name in plugins.ini (without quotes). 
I dont know why these errors are occuring and due to this the native is not performing what it is supposed to do
So if please some one can help me then it would be great

Thnx in advance....
__________________

My Plugins For ZP

Inactive due to College and Studies

Last edited by abdul-rehman; 07-12-2010 at 11:57.
abdul-rehman is offline
Send a message via Yahoo to abdul-rehman Send a message via Skype™ to abdul-rehman
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-11-2010 , 16:34   Re: Retrieving strings using fake natives.....I need Urgent Help PLZ
Reply With Quote #2

First of all you need to read this: "[AMXX] To enable debug mode, add "debug" after the plugin name in plugins.ini (without quotes)."

You are registering the native with style 1 but are actually using style 0.

There is also an error in the third param of get_user_nam(), it can't be hardcoded to work correclty.
__________________
fysiks is offline
abdul-rehman
Veteran Member
Join Date: Jan 2010
Location: Khi, Pakistan
Old 07-11-2010 , 17:52   Re: Retrieving strings using fake natives.....I need Urgent Help PLZ
Reply With Quote #3

Quote:
Originally Posted by fysiks View Post
First of all you need to read this: "[AMXX] To enable debug mode, add "debug" after the plugin name in plugins.ini (without quotes)."

You are registering the native with style 1 but are actually using style 0.

There is also an error in the third param of get_user_nam(), it can't be hardcoded to work correclty.
OK then i dont wont to enable debug mode and what should i do to make my native compatible with style 1 [If possible]
__________________

My Plugins For ZP

Inactive due to College and Studies
abdul-rehman is offline
Send a message via Yahoo to abdul-rehman Send a message via Skype™ to abdul-rehman
grimvh2
Veteran Member
Join Date: Nov 2007
Location: Fishdot Nation
Old 07-11-2010 , 19:53   Re: Retrieving strings using fake natives.....I need Urgent Help PLZ
Reply With Quote #4

at top of plugin_natives()

PHP Code:
register_library("includename"
and in include i use this

PHP Code:
#if defined _includename_included
    #endinput
#endif

#define _includename_included

#pragma reqlib includename 
__________________
I am out of order!
grimvh2 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-11-2010 , 20:24   Re: Retrieving strings using fake natives.....I need Urgent Help PLZ
Reply With Quote #5

Quote:
Originally Posted by abdul-rehman View Post
OK then i dont wont to enable debug mode and what should i do to make my native compatible with style 1 [If possible]
If you don't want to enable debug mode then you obviously don't know what debug means.

Use style 0. If you want to use style 1 then you can find information about it the tutorials section (or elsewhere).
__________________
fysiks is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-12-2010 , 01:28   Re: Retrieving strings using fake natives.....I need Urgent Help PLZ
Reply With Quote #6

Try this :

Code:
#include <amxmodx>

#define FIRST_PLAYER_ID 1

new g_iMaxPlayers
#define IsPlayer(%1)	( FIRST_PLAYER_ID <= %1 <= g_iMaxPlayers )

#define CHECK_PLAYER(%1) \
	if( !IsPlayer(%1) ) \
	{ \
		log_error(AMX_ERR_NATIVE, "Player out of range (%d)", %1); \
		return 0; \
	} \
	else if( !is_user_connected(%1) ) \
	{ \
		log_error(AMX_ERR_NATIVE, "Invalid player (%d)", %1); \
		return 0; \
	}

public plugin_init()
{
	register_plugin("My Awesome Fake Native", "0.1", "ConnorMcLeod")

	g_iMaxPlayers = get_maxplayers()
}

public plugin_natives()
{
    register_native("get_persons_name", "get_persons_name", 0)
}

public get_persons_name(plugin, paramsnum) // get_persons_name(index, name[], len)
{
	if( paramsnum != 3 )
	{
		log_error(AMX_ERR_NATIVE, "Bad arguments num, expected 3, passed %d", paramsnum)
		return 0
	}

	new id = get_param(1)

	CHECK_PLAYER( id )    

	new name[32]
	get_user_name(id, name, charsmax(name))

	new len = get_param(3)
	name[len] = 0

	set_string(2, name, len)

	return 1
}
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
abdul-rehman
Veteran Member
Join Date: Jan 2010
Location: Khi, Pakistan
Old 07-12-2010 , 02:49   Re: Retrieving strings using fake natives.....I need Urgent Help PLZ
Reply With Quote #7

Quote:
Originally Posted by ConnorMcLeod View Post
Try this :

Code:
#include <amxmodx>

#define FIRST_PLAYER_ID 1

new g_iMaxPlayers
#define IsPlayer(%1)	( FIRST_PLAYER_ID <= %1 <= g_iMaxPlayers )

#define CHECK_PLAYER(%1) \
	if( !IsPlayer(%1) ) \
	{ \
		log_error(AMX_ERR_NATIVE, "Player out of range (%d)", %1); \
		return 0; \
	} \
	else if( !is_user_connected(%1) ) \
	{ \
		log_error(AMX_ERR_NATIVE, "Invalid player (%d)", %1); \
		return 0; \
	}

public plugin_init()
{
	register_plugin("My Awesome Fake Native", "0.1", "ConnorMcLeod")

	g_iMaxPlayers = get_maxplayers()
}

public plugin_natives()
{
    register_native("get_persons_name", "get_persons_name", 0)
}

public get_persons_name(plugin, paramsnum) // get_persons_name(index, name[], len)
{
	if( paramsnum != 3 )
	{
		log_error(AMX_ERR_NATIVE, "Bad arguments num, expected 3, passed %d", paramsnum)
		return 0
	}

	new id = get_param(1)

	CHECK_PLAYER( id )    

	new name[32]
	get_user_name(id, name, charsmax(name))

	new len = get_param(3)
	name[len] = 0

	set_string(2, name, len)

	return 1
}
Conner one question...How can i make it compatible with style 1 if i want
if its possible then please tell me
btw thnks for your code i will use it as a backup...
__________________

My Plugins For ZP

Inactive due to College and Studies
abdul-rehman is offline
Send a message via Yahoo to abdul-rehman Send a message via Skype™ to abdul-rehman
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-12-2010 , 06:57   Re: Retrieving strings using fake natives.....I need Urgent Help PLZ
Reply With Quote #8

from kz-arg

PHP Code:
public native_kz_get_configsdir(name[], len)
{
    
param_convert(1)
    
    new 
lalin[64]
    
get_localinfo("amxx_configsdir"lalin,63)
    
    return 
formatex(namelen"%s/%s"lalinKZ_DIR)

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
abdul-rehman
Veteran Member
Join Date: Jan 2010
Location: Khi, Pakistan
Old 07-12-2010 , 11:57   Re: Retrieving strings using fake natives.....I need Urgent Help PLZ
Reply With Quote #9

Problem solved thnx to conner, fysiks and every one who responded to my thread.....i will give you credits in my next version of Zombie Plague Advance
__________________

My Plugins For ZP

Inactive due to College and Studies
abdul-rehman is offline
Send a message via Yahoo to abdul-rehman Send a message via Skype™ to abdul-rehman
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 09:43.


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