AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Is it possible to optimize this? (https://forums.alliedmods.net/showthread.php?t=154798)

neverminde 04-13-2011 09:35

Is it possible to optimize this?
 
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



xPaw 04-13-2011 09:53

Re: Is it possible to optimize this?
 
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 ); }

Arkshine 04-13-2011 10:03

Re: Is it possible to optimize this?
 
You forget ,id.

xPaw 04-13-2011 15:37

Re: Is it possible to optimize this?
 
Quote:

Originally Posted by Arkshine (Post 1448895)
You forget ,id.

Heh

neverminde 04-14-2011 08:37

Re: Is it possible to optimize this?
 
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?

Hunter-Digital 04-14-2011 08:45

Re: Is it possible to optimize this?
 
Why not just use cvars, it's easier for everybody.

neverminde 04-14-2011 08:56

Re: Is it possible to optimize this?
 
Ye maybe, but i want to know how to make it work. Its interesting.

Hunter-Digital 04-14-2011 09:28

Re: Is it possible to optimize this?
 
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 :}

Arkshine 04-14-2011 09:32

Re: Is it possible to optimize this?
 
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.


All times are GMT -4. The time now is 19:55.

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