AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP]Strange error (hud messages) (https://forums.alliedmods.net/showthread.php?t=237140)

Flick3rR 03-18-2014 16:41

[HELP]Strange error (hud messages)
 
Hello, this is the code and I couldn't fix the error. Thanks for help!

PHP Code:

   #include <amxmodx> 
   #include <dhudmessage>

    #define PLUGIN "WinMSG" 
    #define VERSION "0.0.2" 

    
new Trie:g_tReplacements 


    
public plugin_init() 

        
register_plugin(PLUGINVERSION""
        
register_message(get_user_msgid("TextMsg"), "Message_TextMsg"
    
}

public 
hud_message(id)
{
    new 
g_name[32]
    
get_user_name(idg_name[id], 32)
    
g_tReplacements TrieCreate()  
    
TrieSetString(g_tReplacements"#Bomb_Planted",              "[CS-MaxGaminG.iNFO]^n%s zaloji bombata!"g_name);
    
TrieSetString(g_tReplacements"#CTs_Win",                   "[CS-MaxGaminG.iNFO]^nCounter-Teroristite specheliha!");
    
TrieSetString(g_tReplacements"#Terrorists_Win",            "[CS-MaxGaminG.iNFO]^nTeroristite specheliha!");
    
TrieSetString(g_tReplacements"#Round_Draw",                "[CS-MaxGaminG.iNFO]^nRundut se provali!");
    
TrieSetString(g_tReplacements"#Target_Saved",              "[CS-MaxGaminG.iNFO]^nCelta beshe zapazena!");
    
TrieSetString(g_tReplacements"#Game_Commencing",           "[CS-MaxGaminG.iNFO]^nDavaite, boi!");
    
TrieSetString(g_tReplacements"#Bomb_Defused",              "[CS-MaxGaminG.iNFO]^n%s obezvredi bombata!"g_name);
    
TrieSetString(g_tReplacements"#Target_Bombed",              "[CS-MaxGaminG.iNFO]^nBombata izbuhna!");
    
TrieSetString(g_tReplacements"##Auto_Team_Balance_Next_Round""[CS-MaxGaminG.iNFO]^nAvto Team Balance sled runda!");
}

    
    public 
Message_TextMsg(iMsgIdiMsgDestid
    { 
        if( !
id && get_msg_arg_int(1) == print_center 
        { 
            new 
szMessage[64
            
get_msg_arg_string(2szMessagecharsmax(szMessage)) 
            if( 
TrieGetString(g_tReplacementsszMessageszMessagecharsmax(szMessage)) ) 
            { 
                
set_dhudmessage(255255255, -1.00.212010.00.10.2)
                
show_dhudmessage(0szMessage
                return 
PLUGIN_HANDLED 
            

        } 
        return 
PLUGIN_CONTINUE 
    


And this is the error:
PHP Code:

ErrorNumber of arguments does not match definition on line 22 

and
PHP Code:

ErrorNumber of arguments does not match definition on line 28 

These are lines where in the hud i used g_name...

YamiKaitou 03-18-2014 16:48

Re: [HELP]Strange error (hud messages)
 
TrieSetString does not format strings, so you will need to call format first, then pass the formated string to TrieSetString

Flick3rR 03-18-2014 17:01

Re: [HELP]Strange error (hud messages)
 
Allright, my english is so bad, so i can't understand you clearly. If you can give me some example, I may get what are you talking about... :D And how does the format calling happen..

Black Rose 03-18-2014 17:06

Re: [HELP]Strange error (hud messages)
 
Bad:
Code:
new variable[] = "text"; TrieSetString(hTrie, "This is %s", variable);

Good:
Code:
new variable[] = "text"; new string[64]; formatex(string, charsmax(string), "This is %s", variable); TrieSetString(hTrie, string);

Flick3rR 03-18-2014 17:16

Re: [HELP]Strange error (hud messages)
 
I'll try this, but the main idea is to get the user name (this, who is planting the bomb). All the other stuff are working, but when i try to add the name, this happens. Thanks!


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

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