Raised This Month: $ Target: $400
 0% 

send string to native


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Min2liz
AlliedModders Donor
Join Date: Feb 2008
Location: Street
Old 05-02-2010 , 12:06   send string to native
Reply With Quote #1

Hi,

can anyone explain what I'm doing wrong or maybe can give short script for noob how need to do this.

i have main plugin with natives and sub-plugin with command /test For now I want to debug what's really works and try to print everything what I send to native, but don't work.

Main plugin:

Code:
public plugin_natives() {
	register_native("up_get_info","naive_get_info");
}
public naive_get_info(iPlugin,iParam) {	
	new id = get_param(1);
	new key[64];
	get_string(2,key,63);
	new txt[255]
	formatex(txt,254,"Key: %s ID: %s",key,id);
	return txt;
}
upanel.inc:

Code:
native up_get_info(id,key[])
sub-plugin:

Code:
#include <amxmodx>
#include <amxmisc>
#include <upanel>

public plugin_init() {	
	register_clcmd("say /test", "cmd_test");
	
}
public cmd_test(id) {
	client_print(id,print_chat,"test: %s",up_get_info(id,"test"));	
}
and I get strange things here. Of course have no idea why

Code:
test: <
Min2liz :  /test
Min2liz is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-02-2010 , 12:20   Re: send string to native
Reply With Quote #2

if I'm right, To set a string into the param 2 "key", format then after use set_string()
__________________
Arkshine is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 05-02-2010 , 12:49   Re: send string to native
Reply With Quote #3

Code:
formatex(txt,254,"Key: %s ID: %s",key,id);
"id" is an integer, not a string.
You didn't format correctly.

Also, I don't think you can return strings through natives.
(I may be wrong. Let me go check.)
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Min2liz
AlliedModders Donor
Join Date: Feb 2008
Location: Street
Old 05-02-2010 , 16:26   Re: send string to native
Reply With Quote #4

At this poin is working:
main plugin:
Code:
public native_get_info(iPlugin,iParam) {	
	new id = get_param(1);
	new key[255]
	get_string(2,key,255);
	set_string(1,key,255);
}
sub-plugin:
Code:
#include <amxmodx>
#include <amxmisc>
#include <upanel>

public plugin_init() {	
	register_clcmd("say /test", "cmd_test");
	
}
public cmd_test(id) {
	new test[255];
	test = "Test";
	up_get_info(id,test)
	client_print(id,print_chat,"test: %s",test);	
}
Maybe it's silly code but it's working. But now, how to change in native this string to anything else. Like if sub-plugin send "test", native return "test2"?

I tryed:
Code:
public native_get_info(iPlugin,iParam) {	
	new id = get_param(1);
	new key[255], test[255]
	get_string(2,key,255);
	test = "Test2";
	set_string(1,test,255);
}
but still get old one string "Test"
Min2liz is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 05-03-2010 , 19:25   Re: send string to native
Reply With Quote #5

You are using set_string() wrong.
The first argument is the argument of the native.
You are using "1", which is the "id".
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
AntiBots
Veteran Member
Join Date: May 2008
Location: Brazil
Old 05-03-2010 , 20:14   Re: send string to native
Reply With Quote #6

Also make.

get_somethingstring( id, buffer[], len);


Also if you want to return Strings, you can search for a module that I make "StringX".

Just return the pointer to the structure.
__________________
AntiBots is offline
Send a message via ICQ to AntiBots Send a message via MSN to AntiBots Send a message via Skype™ to AntiBots
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 03:41.


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