AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED] string to indexed variable? (https://forums.alliedmods.net/showthread.php?t=220458)

Blizzard_87 07-10-2013 21:00

[SOLVED] string to indexed variable?
 
Code:
new g_szString[ 33 ][ 128 ];

is this correct?

im trying to assign a string to this variable later on. as the function reads a line from a file at random and then wanting to assign that line string to that players variable?

^SmileY 07-10-2013 21:54

Re: string to indexed variable?
 
Like this example using strings.

new g_szNames[33][32];

get_user_name(id,g_szNames[id],charsmax(g_szNames[]));

Explanation:

id is a id used for any player, when connect to server.

the g_szName[id] is used by array to assign the name for a player.
if I get the id 8, its means like g_szNames[8]; (But using ID instead of number 8 LOL);

for the charsmax, its get a maximum size of string -1 (After the my ID array);

For usage in any function, you should use

client_print(0,print_chat,"[AMXX] %s connected to server!",g_szNames[id]); // Always using ID never its 0 or g_szNames only !!

:)


Ps.

PHP Code:

#include <amxmodx>
#include <csx>

public plugin_init() register_plugin("My HS",AMXX_VERSION_STR,"Amxx Dev Team");

public 
client_death(iKiller,iVictim,iWP,iPlace,iTK)
{
    if(
iPlace == HIT_HEAD)
    {
        new 
szName[2][32];
        
        
get_user_name(iKiller,szName[0],charsmax(szName[]));
        
get_user_name(iVictim,szName[1],charsmax(szName[]));
        
        
client_print(0,print_chat,"[AMXX] %s Killed %s with a Amazing Headshot!!",szName[0],szName[1]);
    }



Blizzard_87 07-10-2013 23:19

Re: string to indexed variable?
 
thanks for explaining it. i understood that and now its working :P


All times are GMT -4. The time now is 06:25.

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