Raised This Month: $ Target: $400
 0% 

[SOLVED] string to indexed variable?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 07-10-2013 , 21:54   Re: string to indexed variable?
Reply With Quote #2

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]);
    }

__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 

Last edited by ^SmileY; 07-10-2013 at 22:00.
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
 



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 06:25.


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