Raised This Month: $ Target: $400
 0% 

MySQL Compile Error [URGENT]


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Fr0Gs
New Member
Join Date: Jan 2007
Old 01-12-2007 , 11:01   MySQL Compile Error [URGENT]
Reply With Quote #1

I got this code of the mysql examples but when i compile i get this error

Code:
// C:\Program Files\Valve\Steam\SteamApps\fr0gso\counter-strike\cstrike\addons\a
mxmodx\scripting\banbot.sma(27) : error 029: invalid expression, assumed zero
// C:\Program Files\Valve\Steam\SteamApps\fr0gso\counter-strike\cstrike\addons\a
mxmodx\scripting\banbot.sma(27) : error 029: invalid expression, assumed zero
// C:\Program Files\Valve\Steam\SteamApps\fr0gso\counter-strike\cstrike\addons\a
mxmodx\scripting\banbot.sma(28) : error 029: invalid expression, assumed zero
// C:\Program Files\Valve\Steam\SteamApps\fr0gso\counter-strike\cstrike\addons\a
mxmodx\scripting\banbot.sma(28) : error 029: invalid expression, assumed zero
// C:\Program Files\Valve\Steam\SteamApps\fr0gso\counter-strike\cstrike\addons\a
mxmodx\scripting\banbot.sma(29) : error 029: invalid expression, assumed zero
// C:\Program Files\Valve\Steam\SteamApps\fr0gso\counter-strike\cstrike\addons\a
mxmodx\scripting\banbot.sma(29) : error 029: invalid expression, assumed zero
// C:\Program Files\Valve\Steam\SteamApps\fr0gso\counter-strike\cstrike\addons\a
mxmodx\scripting\banbot.sma(30) : error 029: invalid expression, assumed zero
// C:\Program Files\Valve\Steam\SteamApps\fr0gso\counter-strike\cstrike\addons\a
mxmodx\scripting\banbot.sma(30) : error 029: invalid expression, assumed zero
// C:\Program Files\Valve\Steam\SteamApps\fr0gso\counter-strike\cstrike\addons\a
mxmodx\scripting\banbot.sma(33) : error 029: invalid expression, assumed zero
// C:\Program Files\Valve\Steam\SteamApps\fr0gso\counter-strike\cstrike\addons\a
mxmodx\scripting\banbot.sma(33) : error 029: invalid expression, assumed zero
// C:\Program Files\Valve\Steam\SteamApps\fr0gso\counter-strike\cstrike\addons\a
mxmodx\scripting\banbot.sma(34) : error 029: invalid expression, assumed zero
// C:\Program Files\Valve\Steam\SteamApps\fr0gso\counter-strike\cstrike\addons\a
mxmodx\scripting\banbot.sma(34) : error 029: invalid expression, assumed zero
// C:\Program Files\Valve\Steam\SteamApps\fr0gso\counter-strike\cstrike\addons\a
mxmodx\scripting\banbot.sma(34) : warning 215: expression has no effect
// C:\Program Files\Valve\Steam\SteamApps\fr0gso\counter-strike\cstrike\addons\a
mxmodx\scripting\banbot.sma(34) : error 001: expected token: ";", but found "if"
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <dbi>

#define PLUGIN "MySQL Example"
#define VERSION "1.0"
#define AUTHOR "Sphinx"

//The MySQL DataBase Connection.
new Sql:dbc 

//The result, it tells us if the command/query worked and such
//Used like this
//"result = dbi_query(dbc, "The command sent to the database")
new Result:result

//We need to check to see if the player is new, so we have this.
//If its 0 that means he is completely new to the server
//If its above 0 that means he has a recorded time.
new g_ConnectTime[33]

//What we are using the MySQL database for, storing the information
//You can alter this anyway you like.
new g_PlayerInfo[33]

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
//Initializes the connection
    
set_task(0.1,"sql_init")
}
public 
client_disconnect(id) {
    
//Checks to make sure we have a connection, if we don't then don't continue.
    
if (dbc == SQL_FAILED) {
        return 
PLUGIN_HANDLED;
    }
    
//We need to retrieve the Steamid
    
new authid[32]
    
get_user_authid(id,authid,31)
    
    
//We retrieve how long they have been on the server, on this connection.
    //It will get stored into ConnectTime,
    
new playtime get_user_time (id)
    
    
//This one will check to see that the player has a entry set up. It will just echo in the
    //The database as "Empty Set" if he doesn't have one, so its harmless to have if he doesn't have
    //A slot.
    
result dbi_query(dbc,"SELECT * FROM tablename WHERE steamid = '%s'",authid)
    if (
result == RESULT_FAILED) {
        
log_amx("[MySQL Test] MySQL Query Failed!!")
        return 
PLUGIN_CONTINUE
        
// It failed for some reason, probably becuase DBC failed.
    
}
    
// We were talking about this earlier, 0 means create a fresh entry.
    
else if (g_ConnectTime[id]== 0) {
        
//This tells the database to create an entry, storing the players steamid, connect time, and w/e else you want.
        
result dbi_query(dbc,"INSERT INTO tablename (steamid, connecttime, playerinfo) values ('%s',%i,%i)",authid,playtime,g_PlayerInfo[id])
    }
    else {
            
//So we add this connection with the overall ConnectTime
        
new store_time = (playtime g_ConnectTime[id])
        
result dbi_query(dbc,"UPDATE tablename SET connecttime='%i'. playerinfo='%i' WHERE steamid='%s'",store_time,g_PlayerInfo[id],authid)
    }
    
// We have to free the result, so it can save properly.
    
dbi_free_result(result);
    return 
PLUGIN_CONTINUE;
}
public 
client_authorized(id) {
    if (
dbc == SQL_FAILED) {
        return 
PLUGIN_HANDLED;
    }
    new 
authid[32]
    
get_user_authid(id,authid,31)
    
result dbi_query(dbc,"SELECT * FROM tablename WHERE steamid = '%s'",authid)
    if (
result == RESULT_FAILED) {
        
log_amx("[MySQL Test] MySQL Query Failed!!")
        return 
PLUGIN_CONTINUE // Query failed! Sorry :P
    
}
    
// If he doesn't have a entry, we shall put up the defualts.
    
else if (result == RESULT_NONE) {
        
g_ConnectTime[id] = 0
        g_PlayerInfo
[id] = 0
    
}
    else {
        
dbi_nextrow(result// This retrieves data from your entry.
        //Loads up the recorded connect time, so we can tell that they have been on the server before
        
g_ConnectTime[id] = dbi_result(result,"connecttime")
        
        
//Loads up the information you stored last time they played.
        
g_PlayerInfo[id] = dbi_result(result"playerinfo")
    }
    
// You MUST free the result!
    
dbi_free_result(result)
    return 
PLUGIN_HANDLED;
}
public 
sql_init() {
    new 
error[256]
    
// The database connection, cvars work here too.
    
dbc dbi_connect("localhost""Username""password""databasename"error,255)
    if (
dbc == SQL_FAILED) {
        
log_amx("[MySQL Test] SQL Connection Failed = %s"error)
    }
    else 
        
//You don't have to do this, I just recommend it if you are going to make your plugin public.
        //This will Create a table to store the information to, with the proper values.
        
dbi_query(dbc,"CREATE TABLE IF NOT EXISTS `tablename` (`steamid` VARCHAR(32) NOT NULL,`connecttime` INT NOT NULL,`playerinfo` INT NOT NULL, PRIMARY KEY(`steamid`))")
    }
}
public 
plugin_end() {
    
// Close the connection
    
dbi_close(dbc);

Fr0Gs is offline
 



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 22:31.


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