Raised This Month: $ Target: $400
 0% 

Bad Load


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Afro-Ankan
Member
Join Date: Jul 2009
Location: Sweden
Old 08-17-2010 , 11:04   Bad Load
Reply With Quote #1

PHP Code:
#include <amxmodx>
#include <sqlx>
#include <cstrike>
#define PLUGIN "Player_stats"
#define VERSION "1.0"
#define AUTHOR ""
new Host[]     = "hostname"
new User[]    = "username"
new Pass[]     = "password"
new Db[]     = "database"
new Handle:g_SqlTuple
new g_Error[512]
new 
iSurvive[33];
new 
iHeadshot[33];
new 
iSuicide[33];
new 
iKills[33];
//pcvar's
new cSurvive;
new 
cHeadshot;
new 
cSuicide;
new 
cKills;
 
public 
plugin_init() {
 
register_plugin(PLUGINVERSIONAUTHOR)
 
 
register_event("DeathMsg""Event_DeathMsg""a")
 
register_logevent"eRound_end"2"1=Round_End" );
 
 
cSurvive register_cvar("ps_survive""1")
 
cHeadshot register_cvar("ps_headshot""2")
 
cSuicide register_cvar("ps_suicide""1")
 
cKills register_cvar("ps_kills""1"
 
 
set_task(1.0"MySql_Init")
}
public 
MySql_Init()
{
 
g_SqlTuple SQL_MakeDbTuple(Host,User,Pass,Db)
 
 new 
ErrorCode,Handle:SqlConnection SQL_Connect(g_SqlTuple,ErrorCode,g_Error,charsmax(g_Error))
 if(
SqlConnection == Empty_Handle)
  
set_fail_state(g_Error)
 
 new 
Handle:Queries
 Queries 
SQL_PrepareQuery(SqlConnection,"CREATE TABLE IF NOT EXISTS tutorial (steamid varchar(32),stats INT(11))")
 
 if(!
SQL_Execute(Queries))
 {
  
SQL_QueryError(Queries,g_Error,charsmax(g_Error))
  
set_fail_state(g_Error)
 
 }
 
 
SQL_FreeHandle(Queries)
 
 
SQL_FreeHandle(SqlConnection)   
}  
public 
Load_MySql(id)
{
 new 
ErrorCode,Handle:SqlConnection SQL_Connect(g_SqlTuple,ErrorCode,g_Error,charsmax(g_Error))
 
 if(
g_SqlTuple == Empty_Handle)
  
set_fail_state(g_Error)
 
 new 
szSteamId[32], szTemp[512]
 
get_user_authid(idszSteamIdcharsmax(szSteamId))
 
 new 
Data[1]
 
Data[0] = id
 
 
//we will now select from the table `tutorial` where the steamid match
 
format(szTemp,charsmax(szTemp),"SELECT * FROM `tutorial` WHERE (`tutorial`.`steamid` = '%s')"szSteamId)
 
SQL_ThreadQuery(g_SqlTuple,"register_client",szTemp,Data,1)
 
 
SQL_FreeHandle(SqlConnection)
}
public 
register_client(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
 if(
FailState == TQUERY_CONNECT_FAILED)
 {
  
log_amx("Load - Could not connect to SQL database.  [%d] %s"ErrcodeError)
 }
 else if(
FailState == TQUERY_QUERY_FAILED)
 {
  
log_amx("Load Query failed. [%d] %s"ErrcodeError)
 }
 
 new 
id
 id 
Data[0]
 
 if(
SQL_NumResults(Query) < 1
 {
  
//.if there are no results found
 
  
new szSteamId[32]
  
get_user_authid(idszSteamIdcharsmax(szSteamId)) // get user's steamid
 
  //  if its still pending we can't do anything with it
  
if (equal(szSteamId,"ID_PENDING"))
   return 
PLUGIN_HANDLED
 
  
new szTemp[512]
 
  new 
ErrorCode,Handle:SqlConnection SQL_Connect(g_SqlTuple,ErrorCode,g_Error,charsmax(g_Error))
  if(
g_SqlTuple == Empty_Handle)
   
// stop the plugin with an error message
  
set_fail_state(g_Error)
 
  
// now we will insturt the values into our table.
  
format(szTemp,charsmax(szTemp),"INSERT INTO `tutorial` ( `steamid` , `exp`)VALUES ('%s','0');",szSteamId)
  
SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szTemp)
 
 
  
// and of course, free the connection
  
SQL_FreeHandle(SqlConnection)
 } 
 else 
 {
  
// if there are results found
  
iSurvive[id]         = SQL_ReadResult(Query1)
 }
 
 return 
PLUGIN_HANDLED
}
public 
Save_MySql(id)
{
 
// ok, we're ready to connect
 
new ErrorCode,Handle:SqlConnection SQL_Connect(g_SqlTuple,ErrorCode,g_Error,511)
 if(
g_SqlTuple == Empty_Handle)
  
// stop the plugin with an error message
 
set_fail_state(g_Error)
 
 new 
szSteamId[32], szName[32], szTemp[512]
 
get_user_authid(idszSteamIdcharsmax(szSteamId))
 
get_user_name(idszNamecharsmax(szName))
 
 
// Here we will update the user hes information in the database where the steamid matches.
 
format(szTemp,charsmax(szTemp),"UPDATE `tutorial` SET `exp` = '%i' WHERE `tutorial`.`steamid` = '%s';",iSurvive[id], szSteamId)
 
SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szTemp)
 
 
// and of course, free the connection
 
SQL_FreeHandle(SqlConnection)
}  
public 
Event_DeathMsg()
{
 new 
iKiller read_data(1)
 new 
iVictim read_data(2)
 
 if(
is_user_alive(iKiller))
 {
  if(
read_data(3))
  {
   
iHeadshot[iKiller] += get_pcvar_num(cHeadshot)
  }
  else
  {
   
iKills[iKiller] += get_pcvar_num(cKills)
  }
 }
 
iSuicide[iVictim] -= get_pcvar_num(cSuicide)
}  
public 
eRound_end()
{
 new 
iPlayers[32], iNumiPid;
 
 
get_playersiPlayersiNum"a" );
 
 for( new 
iiNumi++ )
 {
  
iPid iPlayers[i];
  new 
CsTeams:team cs_get_user_team(iPid);
 
  if( 
team == CS_TEAM_T && is_user_alive(iPid) )
  {
   
iSurvive[iPid] += get_pcvar_num(cSurvive)
 
  }
 }

anyone knows why i get Bad Load :S

THANKS!
__________________
My Current Projects:
Pistols vs Pistols Public
Progress [ | | | | | | | | | | ]
Only 10% Completed
Afro-Ankan is offline
Send a message via MSN to Afro-Ankan
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 21:56.


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