Raised This Month: $ Target: $400
 0% 

Is it possible to optimize this?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
neverminde
Senior Member
Join Date: Feb 2011
Location: St.Piter
Old 04-13-2011 , 09:35   Is it possible to optimize this?
Reply With Quote #1

hi, i have tried to write small and simple plugin by myself, which should make welcome hud massege. I think there are some useless code. Is it possible to make it better?
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>

#define PLUGIN "hud_welcome"
#define VERSION "1.0"
#define AUTHOR "neverminde111"

new bool:g_first[33]

public 
plugin_init()
{
    
register_pluginPLUGINVERSIONAUTHOR )
}
 
public 
client_connect(id)
{
    
g_first[id]=true;
}

public 
client_disconnect(iPlayer)
{
    if(
task_exists(iPlayer))
    {
        
remove_task(iPlayer)
    }


public 
client_putinserverid )
{
    
set_task(0.5,"welcome",id,_,_,"a",7)
}

public 
welcome(iPlayer)
{
    if(
g_first[iPlayer]==true)
    {
        
g_first[iPlayer]=false

        
new szName32 ]
        
get_user_nameiPlayerszName31 )
        
set_hudmessage(025500.050.6321.03.50.050.05)
        
show_hudmessage(iPlayer"Hi, %s, nice to see you",szName)    
    }
    return 
PLUGIN_HANDLED

neverminde is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 04-13-2011 , 09:53   Re: Is it possible to optimize this?
Reply With Quote #2

Code:
#include < amxmodx > #define PLUGIN "hud_welcome" #define VERSION "1.0" #define AUTHOR "neverminde111" public plugin_init( ) {     register_plugin( PLUGIN, VERSION, AUTHOR ); } public client_putinserver( id ) {     set_task( 0.5, "welcome", id ); } public welcome( iPlayer ) {     if( !is_user_connected( iPlayer ) )         return;         new szName[ 32 ];     get_user_name( iPlayer, szName, 31 );         set_hudmessage( 0, 255, 0, 0.05, 0.63, 2, 1.0, 3.5, 0.05, 0.05 );     show_hudmessage( iPlayer, "Hi, %s, nice to see you", szName ); }
__________________

Last edited by xPaw; 04-13-2011 at 15:37.
xPaw is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-13-2011 , 10:03   Re: Is it possible to optimize this?
Reply With Quote #3

You forget ,id.
__________________
Arkshine is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 04-13-2011 , 15:37   Re: Is it possible to optimize this?
Reply With Quote #4

Quote:
Originally Posted by Arkshine View Post
You forget ,id.
Heh
__________________
xPaw is offline
neverminde
Senior Member
Join Date: Feb 2011
Location: St.Piter
Old 04-14-2011 , 08:37   Re: Is it possible to optimize this?
Reply With Quote #5

Thanks!

I want to set coordinates from dictionary.
But I cant make float number from string.
message appears in the upper left corner. coordinates equal zero.
PHP Code:
public plugin_init( )
{   
...
    
register_dictionary("hud_welcome.txt")

....
    new 
Float:= (str_to_num("WH_X")/100.00//WH_X = 5
    
new Float:= (str_to_num("WH_Y")/100.00//WH_Y = 65 
and str_to_num = ("WH_X") doesnot working.

How to edit?

Last edited by neverminde; 04-14-2011 at 08:43.
neverminde is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 04-14-2011 , 08:45   Re: Is it possible to optimize this?
Reply With Quote #6

Why not just use cvars, it's easier for everybody.
__________________
Hunter-Digital is offline
neverminde
Senior Member
Join Date: Feb 2011
Location: St.Piter
Old 04-14-2011 , 08:56   Re: Is it possible to optimize this?
Reply With Quote #7

Ye maybe, but i want to know how to make it work. Its interesting.
neverminde is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 04-14-2011 , 09:28   Re: Is it possible to optimize this?
Reply With Quote #8

Using dictionary ? Not really possible, there are more keys for each language and the languages are parsed in-game to each client.

You *could* read the dicionary file separately, or another file actually, using the plugin and parsing the value... but that'll be just too much stuff when you can just use a cvar :}
__________________
Hunter-Digital is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-14-2011 , 09:32   Re: Is it possible to optimize this?
Reply With Quote #9

It's possible using LookupLangKey() but I don't understand well the purpose using ML system for that. Such functionnality has to be used for multilingual messages and nothing else. If you want something customizable easily, use cvars.
__________________
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 19:55.


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