Raised This Month: $32 Target: $400
 8% 

Returning String (Structure)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 12-05-2010 , 08:47   Returning String (Structure)
Reply With Quote #1

Code:
#include <amxmodx>   enum DATA {         DATA_NAME[32],         Float:DATA_HEALTH };   new Data[33][DATA];   public plugin_init()         register_clcmd("say /test", "SayTest");   public SayTest(client) {         Data[client][DATA_HEALTH] = _:100;           get_user_name(client, Data[client][DATA_NAME], 31);         client_print(client, print_chat, "[Test] Health: %f, name: %s", GetData(client, DATA_HEALTH), GetData(client, DATA_NAME));           return PLUGIN_HANDLED; }   stock any:GetData(client, DATA:data)         return Data[client][data];
Is it possible to return full string when you have an enumeration/structure?
Currently it prints:
Code:
[Test] Health: 100.000000, name: h
when it should print my full name "hleV".
It also terminates the string and after the "h" nothing else is written.
__________________

Last edited by hleV; 12-05-2010 at 08:50.
hleV is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-05-2010 , 13:59   Re: Returning String (Structure)
Reply With Quote #2

Strings cannot be returned. They have to be passed by reference.
__________________
fysiks is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 12-05-2010 , 14:34   Re: Returning String (Structure)
Reply With Quote #3

Strings can be returned, though sometimes it may tricky or impossible, like with an enum.

Simple exemple :

Code:
    getMapName()     {         new mapName[ MaxMapLength ];         get_mapname( mapName, charsmax( mapName ) );         return mapName;     }
__________________
Arkshine 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 12:09.


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