Raised This Month: $51 Target: $400
 12% 

[EDIT] Remove SQL


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
5aloOod
Senior Member
Join Date: Jun 2013
Location: hell
Old 02-18-2014 , 09:43   [EDIT] Remove SQL
Reply With Quote #1

Hello everyone
i need help to remove sql support from this code which is done by Kia

Steamid and rank will be save by cfg file like that
"STEAMID" "RANK"
or by a command like
amx_setrank "STEAMID" "RANK"

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <sqlx>
#include <fakemeta>
#include <cstrike>

#define PLUGIN "Custom Rang Info"
#define VERSION "1.0.3"
#define AUTHOR "Kia"

// ===============================================================================
//     Editing begins here
// ===============================================================================

// Add SQL Data here

new Host[]        = ""
new User[]        = ""
new Pass[]        = ""
new Db[]       = ""

// ===============================================================================
//     and stops here. DO NOT MODIFY BELOW UNLESS YOU KNOW WHAT YOU'RE DOING
// ===============================================================================

// ===============================================================================
//     Variables
// ===============================================================================

/* Booleans */

new bool:iStart[33];
new 
bool:g_authed[33]
new 
bool:g_sql_ready false
new bool:g_loaded[33]
new 
bool:g_bHasRank[33]

/* Handler */

new Handle:g_SqlConnection
new Handle:g_SqlTuple

/* Strings */

new g_Error[512]
new 
g_szOldName[33][33]
new 
g_szRank[33][64]

/* Integer */

new maxplayers;

/* Pointer */

new g_pHookSay

// ===============================================================================
//     plugin_init
// ===============================================================================

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
/* SQL */
    
    
maxplayers get_maxplayers()
    
set_task(0.1"MySql_Init")
    
    
/* CVars */
    
    
g_pHookSay register_cvar("cri_hooksay""1")
    
    
/* ClCmds */
    
    
register_clcmd("say""ClCmd_Say")
    
register_clcmd("say_team""ClCmd_SayTeam")
}

// ===============================================================================
//     client_authorized - Called when a player joins the Server
// ===============================================================================

public client_authorized(id)
{
    
g_authed[id] = true
    g_bHasRank
[id] = false
    
    g_szOldName
[id][0] = EOS
    g_szRank
[id][0] = EOS
    
    Load_MySql
(id)
}

// ===============================================================================
//     client_disconnect - Called when a player leaves the Server
// ===============================================================================

public client_disconnect(id)
{
    
g_szOldName[id][0] = EOS
    g_szRank
[id][0] = EOS
    
    iStart
[id] = false
    g_bHasRank
[id] = false
}

// ===============================================================================
//     ClCmd_Say - Called when someone types something in the public chat
// ===============================================================================

public ClCmd_Say(id)
{
    new 
iMode get_pcvar_num(g_pHookSay)
    
    new 
szMsg[500]
    
    
read_args(szMsgcharsmax(szMsg))
    
remove_quotes(szMsg)
    
    if(!
szMsg[0] || iMode <= 0)
        return 
PLUGIN_HANDLED
    
else if(iMode == 1)
        
print_color(0id0"%s^x03%s ^x01: %s"is_user_alive(id) ? "" "^x01*DEAD* "g_szOldName[id], szMsg)
    else if(
iMode == 2)
        
print_color(0id0"%s^x04[%s] ^x03%s ^x01: %s"is_user_alive(id) ? "" "^x01*DEAD* "g_szRank[id], g_szOldName[id], szMsg
    
    return 
PLUGIN_HANDLED
}

// ===============================================================================
//     ClCmd_SayTeam - Called when someone types something in the Team Chat
// ===============================================================================

public ClCmd_SayTeam(id)
{
    new 
iMode get_pcvar_num(g_pHookSay)
    
    new 
szMsg[500]
    
    
read_args(szMsgcharsmax(szMsg))
    
remove_quotes(szMsg)
    
    if(!
szMsg[0] || iMode <= 0)
        return 
PLUGIN_HANDLED

    
new players[32], pnumtempid
    get_players
(playerspnum"e"cs_get_user_team(id) == CS_TEAM_CT "CT" "TERRORIST")
    
    for( new 
ii<pnumi++ ) 
    {
        
tempid players[i]
        
        if(
iMode == 1)
            
print_color(tempidid0"%s^x03%s ^x01(Team) : %s"is_user_alive(id) ? "" "^x01*DEAD* "g_szOldName[id], szMsg)
        else if(
iMode == 2)
            
print_color(tempidid0"%s^x04[%s] ^x03%s ^x01(Team) : %s"is_user_alive(id) ? "" "^x01*DEAD* "g_szRank[id], g_szOldName[id], szMsg
    }
    
    return 
PLUGIN_HANDLED
}

// ===============================================================================
//     ColorChat
// ===============================================================================

public print_color(idcidcolor, const message[], any:...)
{
    new 
msg[192]
    
vformat(msgcharsmax(msg), message5)
    
/*      //if you want to use ML, enable
    replace_all(msg, charsmax(msg), "!g", "^x04")
    replace_all(msg, charsmax(msg), "!n", "^x01")
    replace_all(msg, charsmax(msg), "!t", "^x03")*/
    
new param
    
if (!cid) return
    else 
param cid
    
new team[32]
    
get_user_team(paramteam31)
    switch (
color)
    {
        case 
0msg_teaminfo(paramteam)
            case 
1msg_teaminfo(param"TERRORIST")
            case 
2msg_teaminfo(param"CT")
            case 
3msg_teaminfo(param"SPECTATOR")
        }
    if (
idmsg_saytext(idparammsg)
    else 
msg_saytext(0parammsg)
    if (
color != 0msg_teaminfo(paramteam)
}

msg_saytext(idcidmsg[])
{
    
message_begin(id?MSG_ONE:MSG_ALLget_user_msgid("SayText"), {0,0,0}, id)
    
write_byte(cid)
    
write_string(msg)
    
message_end()
}

msg_teaminfo(idteam[])
{
    
message_begin(MSG_ONEget_user_msgid("TeamInfo"), {0,0,0}, id)
    
write_byte(id)
    
write_string(team)
    
message_end()
}


// ===============================================================================
//     SetRank
// ===============================================================================

public SetRank(id)
{
    
get_user_name(idg_szOldName[id], charsmax(g_szOldName))
    
    new 
szName[33]
    
formatex(szNamecharsmax(szName), "%s^n%s"g_szOldName[id], g_szRank[id])
    
    
set_user_info(id"name"szName)
}



// ===============================================================================
//     SQL
// ===============================================================================

public MySql_Init()
{
    
// we tell the API that this is the information we want to connect to,
    // just not yet. basically it's like storing it in global variables
    
g_SqlTuple SQL_MakeDbTuple(Host,User,Pass,Db)
    
    
// ok, we're ready to connect
    
new ErrorCode
    g_SqlConnection 
SQL_Connect(g_SqlTuple,ErrorCode,g_Error,charsmax(g_Error))
    if(
g_SqlConnection == Empty_Handle)
    {
        
// stop the plugin with an error message
        
set_fail_state(g_Error)
    }
    
    new 
Handle:Queries
    
// we must now prepare some random queries
    
Queries SQL_PrepareQuery(g_SqlConnection,"CREATE TABLE IF NOT EXISTS cri_ranks (steamid varchar(32), rank varchar(64))")
    
    if(!
SQL_Execute(Queries))
    {
        
// if there were any problems
        
SQL_QueryError(Queries,g_Error,charsmax(g_Error))
        
set_fail_state(g_Error)
    }
    
    
// close the handle
    
SQL_FreeHandle(Queries)
    
    
g_sql_ready true
    
for(new i=1i<=maxplayersi++)
    {
        if(
g_authed[i])
        {
            
Load_MySql(i)
        }
    }
}

public 
Load_MySql(id)
{
    if(
g_sql_ready)
    {
        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 `furienmoney` where the steamid match
        
format(szTemp,charsmax(szTemp),"SELECT `rank` FROM `cri_ranks` WHERE (`cri_ranks`.`steamid` = '%s')"szSteamId)
        
SQL_ThreadQuery(g_SqlTuple,"register_client",szTemp,Data,1)
    }
}

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)
    {
        
SQL_ReadResult(Query0g_szRank[id], charsmax(g_szRank))
        
g_bHasRank[id] = true
        
        
new szAuthID[33]
        
get_user_authid(idszAuthIDcharsmax(szAuthID))
        
        
log_to_file("CustomRankInfo.txt""Found Rank : %s for Player with Auth ID : %s"g_szRank[id], szAuthID)
        
        
SetRank(id)
    }
    else
    {
        
g_bHasRank[id] = false
        get_user_name
(idg_szOldName[id], charsmax(g_szOldName))
    }    
    
    
g_loaded[id] = true
    
return PLUGIN_HANDLED
}

public 
IgnoreHandle(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
    
SQL_FreeHandle(Query)
    
    return 
PLUGIN_HANDLED
}

public 
plugin_end()
{
    if(
g_SqlConnection != Empty_Handle)
    {
        
SQL_FreeHandle(g_SqlConnection//free connection handle here
    
}

Thanks

Last edited by 5aloOod; 02-21-2014 at 00:40.
5aloOod is offline
Torge
Veteran Member
Join Date: Oct 2011
Old 02-19-2014 , 13:03   Re: [EDIT] Remove SQL
Reply With Quote #2

If you remove the SQL from that plugin you should know that this plugin isn't saving stuff then anymore.
So also tell us about what way you wanna save it then if not SQL..
Torge is offline
Bloods
Member
Join Date: Aug 2013
Old 02-19-2014 , 20:02   Re: [EDIT] Remove SQL
Reply With Quote #3

I don't know how to code but I've just removed everything that's SQL Related.. Not sure if it's right but give it a shot!

Quote:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <sqlx>
#include <fakemeta>
#include <cstrike>

#define PLUGIN "Custom Rang Info"
#define VERSION "1.0.3"
#define AUTHOR "Kia"

// ============================================= ==================================
// Variables
// ============================================= ==================================

/* Booleans */

new bool:iStart[33];
new bool:g_authed[33]
new bool:g_loaded[33]
new bool:g_bHasRank[33]

/* Strings */

new g_Error[512]
new g_szOldName[33][33]
new g_szRank[33][64]

/* Integer */

new maxplayers;

/* Pointer */

new g_pHookSay

// ============================================= ==================================
// plugin_init
// ============================================= ==================================

public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)

/* SQL */

maxplayers = get_maxplayers()
/* CVars */

g_pHookSay = register_cvar("cri_hooksay", "1")

/* ClCmds */

register_clcmd("say", "ClCmd_Say")
register_clcmd("say_team", "ClCmd_SayTeam")
}

// ============================================= ==================================
// client_authorized - Called when a player joins the Server
// ============================================= ==================================

public client_authorized(id)
{
g_authed[id] = true
g_bHasRank[id] = false

g_szOldName[id][0] = EOS
g_szRank[id][0] = EOS

}

// ============================================= ==================================
// client_disconnect - Called when a player leaves the Server
// ============================================= ==================================

public client_disconnect(id)
{
g_szOldName[id][0] = EOS
g_szRank[id][0] = EOS

iStart[id] = false
g_bHasRank[id] = false
}

// ============================================= ==================================
// ClCmd_Say - Called when someone types something in the public chat
// ============================================= ==================================

public ClCmd_Say(id)
{
new iMode = get_pcvar_num(g_pHookSay)

new szMsg[500]

read_args(szMsg, charsmax(szMsg))
remove_quotes(szMsg)

if(!szMsg[0] || iMode <= 0)
return PLUGIN_HANDLED
else if(iMode == 1)
print_color(0, id, 0, "%s^x03%s ^x01: %s", is_user_alive(id) ? "" : "^x01*DEAD* ", g_szOldName[id], szMsg)
else if(iMode == 2)
print_color(0, id, 0, "%s^x04[%s] ^x03%s ^x01: %s", is_user_alive(id) ? "" : "^x01*DEAD* ", g_szRank[id], g_szOldName[id], szMsg)

return PLUGIN_HANDLED
}

// ============================================= ==================================
// ClCmd_SayTeam - Called when someone types something in the Team Chat
// ============================================= ==================================

public ClCmd_SayTeam(id)
{
new iMode = get_pcvar_num(g_pHookSay)

new szMsg[500]

read_args(szMsg, charsmax(szMsg))
remove_quotes(szMsg)

if(!szMsg[0] || iMode <= 0)
return PLUGIN_HANDLED

new players[32], pnum, tempid
get_players(players, pnum, "e", cs_get_user_team(id) == CS_TEAM_CT ? "CT" : "TERRORIST")

for( new i; i<pnum; i++ )
{
tempid = players[i]

if(iMode == 1)
print_color(tempid, id, 0, "%s^x03%s ^x01(Team) : %s", is_user_alive(id) ? "" : "^x01*DEAD* ", g_szOldName[id], szMsg)
else if(iMode == 2)
print_color(tempid, id, 0, "%s^x04[%s] ^x03%s ^x01(Team) : %s", is_user_alive(id) ? "" : "^x01*DEAD* ", g_szRank[id], g_szOldName[id], szMsg)
}

return PLUGIN_HANDLED
}

// ============================================= ==================================
// ColorChat
// ============================================= ==================================

public print_color(id, cid, color, const message[], any:...)
{
new msg[192]
vformat(msg, charsmax(msg), message, 5)
/* //if you want to use ML, enable
replace_all(msg, charsmax(msg), "!g", "^x04")
replace_all(msg, charsmax(msg), "!n", "^x01")
replace_all(msg, charsmax(msg), "!t", "^x03")*/
new param
if (!cid) return
else param = cid
new team[32]
get_user_team(param, team, 31)
switch (color)
{
case 0: msg_teaminfo(param, team)
case 1: msg_teaminfo(param, "TERRORIST")
case 2: msg_teaminfo(param, "CT")
case 3: msg_teaminfo(param, "SPECTATOR")
}
if (id) msg_saytext(id, param, msg)
else msg_saytext(0, param, msg)
if (color != 0) msg_teaminfo(param, team)
}

msg_saytext(id, cid, msg[])
{
message_begin(id?MSG_ONE:MSG_ALL, get_user_msgid("SayText"), {0,0,0}, id)
write_byte(cid)
write_string(msg)
message_end()
}

msg_teaminfo(id, team[])
{
message_begin(MSG_ONE, get_user_msgid("TeamInfo"), {0,0,0}, id)
write_byte(id)
write_string(team)
message_end()
}


// ============================================= ==================================
// SetRank
// ============================================= ==================================

public SetRank(id)
{
get_user_name(id, g_szOldName[id], charsmax(g_szOldName))

new szName[33]
formatex(szName, charsmax(szName), "%s^n%s", g_szOldName[id], g_szRank[id])

set_user_info(id, "name", szName)
}
Bloods is offline
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 02-20-2014 , 01:29   Re: [EDIT] Remove SQL
Reply With Quote #4

He wants it saving by NVault.
__________________
Kia is offline
5aloOod
Senior Member
Join Date: Jun 2013
Location: hell
Old 02-20-2014 , 04:21   Re: [EDIT] Remove SQL
Reply With Quote #5

Quote:
Originally Posted by Bloods View Post
I don't know how to code but I've just removed everything that's SQL Related.. Not sure if it's right but give it a shot!
so where can i add the steam id + rank ?
Quote:
Originally Posted by Kia View Post
He wants it saving by NVault.
Yeah, or by command or from cfg file
__________________
اَشْهَدُ اَنْ لَّآ اِلٰهَ اِلَّا اللہُ وَحْدَه لَا شَرِيْكَ لَه وَ اَشْهَدُ اَنَّ مُحَمَّدًا عَبْدُه وَرَسُوْلُه
5aloOod is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 02-20-2014 , 07:14   Re: [EDIT] Remove SQL
Reply With Quote #6

Quote:
Originally Posted by Kia View Post
He wants it saving by NVault.
How do you know? He never mentioned that in this thread.

Quote:
Originally Posted by 5aloOod View Post
so where can i add the steam id + rank ?
You don't as you asked to remove SQL which is how the ranks are saved. Unless you actually wanted the SQL parts converted to something else, but you didn't mention anything about that
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
5aloOod
Senior Member
Join Date: Jun 2013
Location: hell
Old 02-21-2014 , 00:41   Re: [EDIT] Remove SQL
Reply With Quote #7

Quote:
Originally Posted by YamiKaitou View Post
You don't as you asked to remove SQL which is how the ranks are saved. Unless you actually wanted the SQL parts converted to something else, but you didn't mention anything about that
thread edited
__________________
اَشْهَدُ اَنْ لَّآ اِلٰهَ اِلَّا اللہُ وَحْدَه لَا شَرِيْكَ لَه وَ اَشْهَدُ اَنَّ مُحَمَّدًا عَبْدُه وَرَسُوْلُه
5aloOod 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 12:15.


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