Raised This Month: $ Target: $400
 0% 

Bad Load


Post New Thread Reply   
 
Thread Tools Display Modes
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
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 08-17-2010 , 11:17   Re: Bad Load
Reply With Quote #2

Make sure that the plugin in in the plugins folder and that the name in plugins.ini is right.
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-17-2010 , 18:35   Re: Bad Load
Reply With Quote #3

Depends on what the error is, it should show you at the bottome of the list of plugins when you do "amxx plugins" in the server console.
__________________
fysiks is offline
RedRobster
Veteran Member
Join Date: Apr 2010
Location: Your Closet
Old 08-17-2010 , 18:36   Re: Bad Load
Reply With Quote #4

He sent me a message on Steam, and if I'm not mistaken, he fixed it. It was something to do with opening the SQLx Database I think.
RedRobster is offline
Old 08-17-2010, 19:18
Zpoke
This message has been deleted by Zpoke. Reason: ...
Afro-Ankan
Member
Join Date: Jul 2009
Location: Sweden
Old 08-17-2010 , 19:24   Re: Bad Load
Reply With Quote #5

i havent really fixed the error. i took grim's tutorial code and just gonna try using mysql since i really suck at it..

here's the Error:

Code:
 [ 28] Player_stats            1.0         nobody             player_stats_co  error    
( 28) Error: Unknown MySQL server host 'hostname' (11001
a friend told me that you need to change something in the "addons\amxmodx\configs\sql.cfg"
__________________
My Current Projects:
Pistols vs Pistols Public
Progress [ | | | | | | | | | | ]
Only 10% Completed
Afro-Ankan is offline
Send a message via MSN to Afro-Ankan
vL.
Senior Member
Join Date: Aug 2009
Location: Estonia
Old 08-18-2010 , 04:08   Re: Bad Load
Reply With Quote #6

On that code you have to change the "username" "database" etc stuff to your own mysql data.
vL. is offline
Reply



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