AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Returning String (Structure) (https://forums.alliedmods.net/showthread.php?t=144555)

hleV 12-05-2010 08:47

Returning String (Structure)
 
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.

fysiks 12-05-2010 13:59

Re: Returning String (Structure)
 
Strings cannot be returned. They have to be passed by reference.

Arkshine 12-05-2010 14:34

Re: Returning String (Structure)
 
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;     }


All times are GMT -4. The time now is 11:22.

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