You added name saving but, you forgot to back-quote it. Try this (not tested):
PHP Code:
#include < amxmodx >
#include < colorchat >
#include < hamsandwich >
#include < fakemeta >
#include < engine >
#include < sqlx >
native pm_get_user_points(id);
native pm_get_user_totalpoints(id);
native pm_add_user_points(id, iPoints);
stock pm_add_user_point(client, point)
{
return pm_add_user_points(client, pm_get_user_points(client) + iPoints);
return pm_add_user_points(client, pm_get_user_totalpoints(client) + iPoints);
}
new vOrigin[33][3];
new vOldOrigin[33][2][3]; // 0 = Crouched ; 1 = Normal
new const Prefix[] = "[Gpark]";
new vJump[33];
new vJumpRank[256][32];
#define _GenerateUserId() (_pg_last_userid = (_pg_last_userid+1)%0xffffff)
new _pg_last_userid
#define _Set(%1,%2) %1|=1<<%2
#define _UnSet(%1,%2) %1&=~(1<<%2)
#define _Is(%1,%2) (%1&1<<%2)
new _in_server, _authed, _loaded
new g_max_players
new g_p_local_userid[33]
new Handle:g_sql_tuple
new Handle:g_sql_connection
new g_sql_ready
public plugin_init( )
{
register_plugin( "Jump Counter", "0.1.3", "anderseN" )
register_clcmd( "say /jumps", "Jumpinfo" )
g_max_players = get_maxplayers()
set_task(0.2, "sql_init")
RegisterHam( Ham_Player_Jump, "player", "Ham_Player_Jump_Post", 1 );
}
public plugin_end()
{
if(g_sql_connection != Empty_Handle)
{
SQL_FreeHandle(g_sql_connection)
g_sql_connection = Empty_Handle
}
}
public sql_init()
{
if(g_sql_tuple != Empty_Handle)
{
SQL_FreeHandle(g_sql_tuple)
g_sql_tuple = Empty_Handle
}
if(g_sql_connection != Empty_Handle)
{
SQL_FreeHandle(g_sql_connection)
g_sql_connection = Empty_Handle
}
new type[15]
get_cvar_string("amx_sql_type", type, sizeof(type)-1)
SQL_SetAffinity(type)
g_sql_tuple = SQL_MakeStdTuple()
new err_code, err[512]
g_sql_connection = SQL_Connect(g_sql_tuple, err_code, err, 511)
if(g_sql_connection == Empty_Handle)
{
log_amx("SQL Error (SQL_Connect): %s", err)
set_task(10.0, "sql_init")
return
}
new cache[] = "CREATE TABLE IF NOT EXISTS `jump_count` (`authid` VARCHAR(35) PRIMARY KEY, `name` VARCHAR(64), `jumps` INTEGER, `title` VARCHAR(64));"
SQL_ThreadQuery(g_sql_tuple, "qh_create_table", cache)
}
public qh_create_table(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
if(FailState)
{
log_amx("SQL Error (qh_create_table): %s", Error)
set_task(10.0, "sql_init")
return
}
g_sql_ready = true
for(new id=1; id<=g_max_players; id++)
if(_Is(_in_server, id) && _Is(_authed, id))
Player_Load(id)
}
public client_connect(id)
{
g_p_local_userid[id] = _GenerateUserId()
_UnSet(_authed, id)
}
public client_authorized(id)
{
if(is_user_bot(id) || is_user_hltv(id))
return
_Set(_authed, id)
if(_Is(_in_server, id))
Player_Load(id)
}
public client_putinserver(id)
{
vJump[id] = 0
_Set(_in_server, id)
if(_Is(_authed, id))
Player_Load(id)
}
public client_disconnect(id)
{
Player_Save(id)
_UnSet(_authed, id)
_UnSet(_in_server, id)
_UnSet(_loaded, id)
remove_task(id)
}
public Player_Load(id)
{
if(!g_sql_ready)
return
new authid[36]
get_user_authid(id, authid, sizeof(authid)-1)
new cache[128]
formatex(cache, sizeof(cache)-1, "SELECT `jumps` FROM `jump_count` WHERE `authid`='%s';", authid)
new data[2]
data[0] = id
data[1] = g_p_local_userid[id]
SQL_ThreadQuery(g_sql_tuple, "qh_Player_Load", cache, data, 2)
}
public qh_Player_Load(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
new id = Data[0]
if(!_Is(_in_server, id) || g_p_local_userid[id] != Data[1])
return
if(FailState)
{
log_amx("SQL Error (qh_Player_Load): %s", Error)
set_task(10.0, "Player_Load", id)
return
}
_Set(_loaded, id)
if(!SQL_MoreResults(Query))
return
vJump[id] = SQL_ReadResult(Query, 0)
}
public Player_Save(id)
{
if(!_Is(_loaded, id))
return
new authid[36]
get_user_authid(id, authid, sizeof(authid)-1)
new name[36]
get_user_name(id, name, sizeof(name)-1)
new cache[128]
new quoted_name[72]
SQL_QuoteString(g_sql_connection, quoted_name, sizeof(quoted_name)-1, name)
new quoted_rank[64]
SQL_QuoteString(g_sql_connection, quoted_rank, sizeof(quoted_rank)-1, vJumpRank[id])
formatex(cache, sizeof(cache)-1, "REPLACE INTO `jump_count` (`authid`,`name`,`jumps`,`title`)VALUES('%s', '%s','%d', '%s');", authid, quoted_name, vJump[id], quoted_rank)
SQL_ThreadQuery(g_sql_tuple, "qh_Player_Save", cache)
}
public qh_Player_Save(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
if(FailState)
{
log_amx("SQL Error (qh_Player_Save): %s", Error)
return
}
}
public Jumpinfo( id )
{
if( vJump[id] <= 200 )
{
vJumpRank[id] = "New Player";
}
else if( 200 < vJump[id] <= 500 )
{
vJumpRank[id] = "Newbie";
}
else if( 500 < vJump[id] <= 1000 )
{
vJumpRank[id] = "Beginner";
}
else if( 1000 < vJump[id] <= 2000 )
{
vJumpRank[id] = "Good Luck";
}
else if( 2000 < vJump[id] <= 5000 )
{
vJumpRank[id] = "Getting Started";
}
else if( 5000 < vJump[id] <= 10000 )
{
vJumpRank[id] = "Active Jumper";
}
else if( 10000 < vJump[id] <= 15000 )
{
vJumpRank[id] = "Moderate Jumper";
}
else if( 15000 < vJump[id] <= 25000 )
{
vJumpRank[id] = "Pro Jumper";
}
else if( 25000 < vJump[id] <= 50000 )
{
vJumpRank[id] = "Insane Jumper";
}
else if( 50000 < vJump[id] <= 100000 )
{
vJumpRank[id] = "1337 Jumper";
}
else if( 100000 < vJump[id] <= 200000 )
{
vJumpRank[id] = "Skilled Jumper";
}
else if( 200000 < vJump[id] <= 300000 )
{
vJumpRank[id] = "Going Crazy";
}
else if( 300000 < vJump[id] <= 500000 )
{
vJumpRank[id] = "Rabbit";
}
else if( 500000 < vJump[id] <= 1000000 )
{
vJumpRank[id] = "Veteran";
}
else if( 1000000 < vJump[id] )
{
vJumpRank[id] = "Official Gamepark Legend";
}
new szName[ 33 ];
get_user_name( id, szName, 32 );
Print(0, "^1%s^3 has a total of^1 %d^3 Jumps. Rank:^4 %s^3 !", szName, vJump[id], vJumpRank[id])
}
public Ham_Player_Jump_Post( const id )
{
if( ( pev( id, pev_flags ) & FL_ONGROUND ) && !( pev( id, pev_oldbuttons ) & IN_JUMP ) )
{
if (get_user_team(id) == 1)
{
static Distance[2];
get_user_origin( id, vOrigin[ id ] );
Distance[1] = get_distance( vOldOrigin[id][1], vOrigin[id] );
if( Distance[1] >= 50 )
{
vJump[ id ]++
new szName[ 33 ];
get_user_name( id, szName, 32 );
if(vJump[id] == 200)
{
Print(0, "Congratulations to^1 %s^3 who has reached^1 200^3 jumps! Rank^4 Newbie^3 !", szName)
client_cmd(0, "spk buttons/button9.waw");
}
else if(vJump[id] == 500)
{
Print(0, "Congratulations to^1 %s^3 who has reached^1 500^3 jumps! Rank^4 Beginner^3 !", szName)
client_cmd(0, "spk buttons/button9.waw");
}
else if(vJump[id] == 1000)
{
Print(0, "Congratulations to^1 %s^3 who has reached^1 1000^3 jumps! Rank^4 Good Luck^3 !", szName)
client_cmd(0, "spk buttons/button9.waw");
}
else if(vJump[id] == 2000)
{
Print(0, "Congratulations to^1 %s^3 who has reached^1 2000^3 jumps! Rank^4 Getting Started^3 !", szName)
client_cmd(0, "spk buttons/button9.waw");
}
else if(vJump[id] == 5000)
{
Print(0, "Congratulations to^1 %s^3 who has reached^1 5000^3 jumps! Rank^4 Active Jumper^3 !", szName)
client_cmd(0, "spk buttons/button9.waw");
Print(id, "You received^4 80^3 points for reaching^4 5,000^3 jumps !")
pm_add_user_points(id, 80);
}
else if(vJump[id] == 10000)
{
Print(0, "Congratulations to^1 %s^3 who has reached^1 10,000^3 jumps! Rank^4 Moderate Jumper^3 !", szName)
client_cmd(0, "spk buttons/button9.waw");
Print(id, "You received^4 80^3 points for reaching^4 10,000^3 jumps !")
pm_add_user_points(id, 80);
}
else if(vJump[id] == 15000)
{
Print(0, "Congratulations to^1 %s^3 who has reached^1 15,000^3 jumps! Rank^4 Pro Jumper^3 !", szName)
client_cmd(0, "spk buttons/button9.waw");
Print(id, "You received^4 80^3 points for reaching^4 15,000^3 jumps !")
pm_add_user_points(id, 80);
}
else if(vJump[id] == 25000)
{
Print(0, "Congratulations to^1 %s^3 who has reached^1 25,000^3 jumps! Rank^4 Insane Jumper^3 !", szName)
client_cmd(0, "spk buttons/button9.waw");
Print(id, "You received^4 80^3 points for reaching^4 25,000^3 jumps !")
pm_add_user_points(id, 80);
}
else if(vJump[id] == 50000)
{
Print(0, "Congratulations to^1 %s^3 who has reached^1 50,000^3 jumps! Rank^4 1337 Jumper^3 !", szName)
client_cmd(0, "spk buttons/button9.waw");
Print(id, "You received^4 80^3 points for reaching^4 50,000^3 jumps !")
pm_add_user_points(id, 80);
}
else if(vJump[id] == 100000)
{
Print(0, "Congratulations to^1 %s^3 who has reached^1 100,000^3 jumps! Rank^4 Skilled Jumper^3 !", szName)
client_cmd(0, "spk buttons/button9.waw");
Print(id, "You received^4 100^3 points for reaching^4 100,000^3 jumps !")
pm_add_user_points(id, 100);
}
else if(vJump[id] == 200000)
{
Print(0, "Congratulations to^1 %s^3 who has reached^1 200,000^3 jumps! Rank^4 Going Crazy^3 !", szName)
client_cmd(0, "spk buttons/button9.waw");
Print(id, "You received^4 100^3 points for reaching^4 200,000^3 jumps !")
pm_add_user_points(id, 100);
}
else if(vJump[id] == 300000)
{
Print(0, "Congratulations to^1 %s^3 who has reached^1 300,000^3 jumps! Rank^4 Rabbit^3 !", szName)
client_cmd(0, "spk buttons/button9.waw");
Print(id, "You received^4 100^3 points for reaching^4 300,000^3 jumps !")
pm_add_user_points(id, 100);
}
else if(vJump[id] == 500000)
{
Print(0, "Congratulations to^1 %s^3 who has reached^1 500,000^3 jumps! Rank^4 Veteran^3 !", szName)
client_cmd(0, "spk buttons/button9.waw");
Print(id, "You received^4 100^3 points for reaching^4 500,000^3 jumps !")
pm_add_user_points(id, 100);
}
else if(vJump[id] == 1000000)
{
Print(0, "Congratulations to^1 %s^3 who has reached^1 1,000,000^3 jumps! Rank^4 Official Gamepark Legend^3 !", szName)
client_cmd(0, "spk buttons/button9.waw");
Print(id, "You received^4 500^3 points for reaching^4 1,000,000^3 jumps !")
pm_add_user_points(id, 500);
}
vOldOrigin[ id ][ 1 ][ 0 ] = vOrigin[ id ][ 0 ];
vOldOrigin[ id ][ 1 ][ 1 ] = vOrigin[ id ][ 1 ];
vOldOrigin[ id ][ 1 ][ 2 ] = vOrigin[ id ][ 2 ];
}
else
{
set_hudmessage(255, 0, 255, -1.0, 0.74, 0, 0.8, 2.0)
show_hudmessage(id, "[Jumps] Do not jump at the same spot")
}
}
}
return HAM_IGNORED;
}
Print(id, const szMessage[], any:...)
{
static szBuffer[192];
vformat(szBuffer, charsmax(szBuffer), szMessage, 3);
ColorChat(id, GREY, "^04%s^03 %s", Prefix, szBuffer);
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/