AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Say command doesn't work (again...) (https://forums.alliedmods.net/showthread.php?t=153138)

kotinha 03-19-2011 08:30

Say command doesn't work (again...)
 
When I compile my code it doesn't give any errors, but if I say something in my server it doesn't print the message that it is supposed to print.

The other functions work normally, or at least I think they do ...

The code (unfinished, obviously...):
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <nvault>

#define PLUGIN "rank tags"
#define VERSION "1.0"
#define AUTHOR "thony"

new PlayerExp[33], PlayerLevel[33]
new 
g_vault
new ranktag_toggle
new iTag
new const LEVELS[4] = {
    
100,
    
200,
    
400,
    
800
}
new const 
TAGS[][32] = {
    
"Noob",
    
"Camper",
    
"Player",
    
"Master"
}
public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
// Open Vault
    
g_vault nvault_open("ranktags")
    
// Register events
    
register_event("DeathMsg""player_death""a")
    
register_event("client_connect""when_connect""a")
    
register_concmd("say""cmd_say");
    
// Register cvars
    
ranktag_toggleregister_cvar("ranktag_toggle""1")
}
public 
cmd_say(id)
{
    
// Get what player said and blocks message (not... yet)
    
static text2[200];
    
read_args(text2199);
    
remove_quotes(text2);
    
client_print(idprint_chat"You said %s"text2)
}
public 
when_connect(id
{
    if(
get_pcvar_num(ranktag_toggle)==1
    {
        
load_data(id)
    }
}
public 
player_death(id)
{
    
// If victim exp is different of 0 remove 1 exp point
    
PlayerExp[id]+=100
    
if (PlayerExp[id]!=0)
        
PlayerExp[id] -= 1;
    
// Get killer, if headshot, weapon
    
new killer read_data(1)
    new 
is_headshot read_data(3)
    new 
weapon read_data(4)
    
// Give exp to killer
    
if(is_headshot)
        
PlayerExp[killer] += 4
    
    
else if(weapon == CSW_KNIFE)
        
PlayerExp[killer] += 6
    
    
else
        
PlayerExp[killer] += 2
}
public 
load_data(id)
{
    
// Get player steamID
    
new steamid[35]
    
get_user_authid(id,steamid,34)
    
// Create variables to get data
    
new vaultkey[64], vaultdata[256]
    
// Put in right format to get data
    
format(vaultkey,63,"%s-ranktag",steamid
    
format(vaultdata,255,"%i#%i#",PlayerExp[id],PlayerLevel[id]) 
    
// Get player data
    
nvault_get(g_vault,vaultkey,vaultdata,255
    
replace_all(vaultdata255"#"" ")
    
// Create necessary variables...
    
new playerexp[32], playerlevel[32
    
// Separate strings and convert to num
    
parse(vaultdataplayerexp31playerlevel31
    
PlayerExp[id] = str_to_num(playerexp
    
PlayerLevel[id] = str_to_num(playerlevel)
    return 
PLUGIN_CONTINUE
    
    
// Player Exp and Player Level is right to go!
}
public 
get_tag(exp)
{
    for(new 
0i<=3i++)
    {
        if(
LEVELS[i]>=exp)
        {
            
iTag=i
            
break;
        }
    }
    return 
TAGS[iTag];



ConnorMcLeod 03-19-2011 09:22

Re: Say command doesn't work (again...)
 
PHP Code:

register_event("client_connect""when_connect""a"

WTF is this ?

Give up now when it is still early enough.

schmurgel1983 03-19-2011 11:07

Re: Say command doesn't work (again...)
 
all possible register_event hooks don't see client_connect
client_connect is a forward from amxmodx.inc
alsoooooo
Code:

public client_connect(client)
{
  // code here
}




ConnorMcLeod 03-19-2011 11:10

Re: Say command doesn't work (again...)
 
Also look on how to register event with proper flags.


All times are GMT -4. The time now is 14:36.

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