Raised This Month: $ Target: $400
 0% 

global values, player's indexes


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 11-30-2009 , 10:51   Re: global values, player's indexes
Reply With Quote #1

PHP Code:
#include <amxmodx>
 
public client_putinserver(id)
     
set_task(2.0"showName"id__"b")
 
public 
client_disconnect(id)
     
remove_task(id)
 
public 
showName(id)
{
     new 
szName[32]
 
     
get_user_name(idszNamecharsmax(szName))
 
     
set_hudmessage(210105300.010.760_1.9_0.1, -1)
     
show_hudmessage(id"Your name: %s"szName)

hectorz0r, your code will not work how he wants because your task will execute only once.. he wants the nick to be constantly printed... also, what's the deal with read_data() over there ? O.o
And also no codes would work because you two forgot a " in the set_task() and also you don't remove the task and there will be some serious load after many player connects and disconnects.

Also...
Quote:
Originally Posted by worldspawn View Post
this script must show you some hudmess with your name, but when new player connects in hudmess you will see his name and hudmess will be shown to all players.
Can anybody tell me how to prevent this?
That's because your global variable doesn't have indexes for every player, but for one, when a player connects the variable will be overwrite... if you want to use global string variables for each players you should do something like:
PHP Code:
new g_szName[33][32/* 33 because counting starts from 0 */
 
/* in a function that has a player id */
get_user_name(idg_szName[id], charsmax(g_szName[]) 
__________________

Last edited by Hunter-Digital; 11-30-2009 at 10:58.
Hunter-Digital 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 13:43.


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