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(PLUGIN, VERSION, AUTHOR)
// 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_toggle= register_cvar("ranktag_toggle", "1")
}
public cmd_say(id)
{
// Get what player said and blocks message (not... yet)
static text2[200];
read_args(text2, 199);
remove_quotes(text2);
client_print(id, print_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(vaultdata, 255, "#", " ")
// Create necessary variables...
new playerexp[32], playerlevel[32]
// Separate strings and convert to num
parse(vaultdata, playerexp, 31, playerlevel, 31)
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 i = 0; i<=3; i++)
{
if(LEVELS[i]>=exp)
{
iTag=i
break;
}
}
return TAGS[iTag];
}
|