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

Nvault to SQL


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
sawled
Member
Join Date: Jun 2011
Old 03-20-2012 , 13:18   Nvault to SQL
Reply With Quote #1

Hi all ,


I found this plugin in one bulgarian scripting website.


Can someone make saving method to SQL.





Thank you
Attached Files
File Type: sma Get Plugin or Get Source (kills_counter.sma - 918 views - 5.0 KB)
sawled is offline
wickedd
Veteran Member
Join Date: Nov 2009
Old 03-20-2012 , 13:36   Re: Nvault to SQL
Reply With Quote #2

Wrong forum.
__________________
Just buy the fucking game!!!!
I hate No-Steamers and lazy ass people.
wickedd is offline
sawled
Member
Join Date: Jun 2011
Old 03-20-2012 , 13:41   Re: Nvault to SQL
Reply With Quote #3

Quote:
Originally Posted by wickedd View Post
Wrong forum.
Where i have to post it ?
sawled is offline
bLacK-bLooD
AlliedModders Donor
Join Date: Jun 2008
Old 03-20-2012 , 14:27   Re: Nvault to SQL
Reply With Quote #4

Suggestions/Requests
__________________
We all live under the same sky but we have different horizons.
bLacK-bLooD is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 03-20-2012 , 14:40   Re: Nvault to SQL
Reply With Quote #5

Add this line to the top of the plugin:
Code:
#include <nvault_to_sqlvault>

Then, compile locally with sqlvault.inc and the include I have attached.
Attached Files
File Type: inc nvault_to_sqlvault.inc (3.8 KB, 187 views)
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!

Last edited by Exolent[jNr]; 03-21-2012 at 11:04.
Exolent[jNr] is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 03-20-2012 , 15:57  
Reply With Quote #6

Quote:
Originally Posted by Exolent[jNr] View Post
Add this line to the top of the plugin:
Code:
#include <nvault_to_sqlvault>

Then, compile locally with sqlvault.inc and the include I have attached.
That is really cool exo
Doc-Holiday is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 03-20-2012 , 16:10   Re: Nvault to SQL
Reply With Quote #7

here is my version (works with both sqlite and mysql, configuration in amxmodx/configs/sql.cfg):
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <sqlx>

enum ELevelDefinition{
    
ELD_name[32],
    
ELD_kills
}

new const 
g_levels[][ELevelDefinition] ={
    {
"Newbie"0},
    {
"Veteran",9},
    {
"Pro",6},
    {
"Semi-Pro",3}
}


new 
g_sort[sizeof g_levels]

#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_kills[33]
new 
g_p_level[33]
new 
g_p_local_userid[33

new 
Trie:gt_chat
new Handle:g_sql_tuple
new g_sql_ready


public plugin_init(){
    
register_plugin("SQL Rank Mod""1.0""Sylwester")
    
g_max_players get_maxplayers()
    
RegisterHam(Ham_Killed"player""Player_KilledPost"1)
    
register_message(get_user_msgid("SayText"), "msg_SayText")

    for(new 
i,i<sizeof g_levelsj=++i){
        while(--
j>=&& g_levels[g_sort[j]][ELD_kills] > g_levels[i][ELD_kills]){
                
g_sort[j+1] = g_sort[j]
        }
        
g_sort[j+1] = i
    
}
    
    
gt_chat TrieCreate()
    
TrieSetCell(gt_chat"#Cstrike_Chat_All"1)
    
TrieSetCell(gt_chat"#Cstrike_Chat_AllDead"2)
    
TrieSetCell(gt_chat"#Cstrike_Chat_T"3)
    
TrieSetCell(gt_chat"#Cstrike_Chat_T_Dead"4)
    
TrieSetCell(gt_chat"#Cstrike_Chat_CT"5)
    
TrieSetCell(gt_chat"#Cstrike_Chat_CT_Dead"6)
    
TrieSetCell(gt_chat"#Cstrike_Chat_Spec"7)       
    
TrieSetCell(gt_chat"#Cstrike_Chat_AllSpec"8)
    
set_task(0.2"sql_init")
}


public 
sql_init(){
    
g_sql_tuple SQL_MakeStdTuple()
    new 
type[15]
    
get_cvar_string("amx_sql_type"typesizeof(type)-1)
    
SQL_SetAffinity(type)
    new 
cache[] = "CREATE TABLE IF NOT EXISTS `kills_counter` (`authid` VARCHAR(35) PRIMARY KEY, `kills` INTEGER);"
    
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=1id<=g_max_playersid++)
        if(
_Is(_in_serverid) && _Is(_authedid))
            
Player_Load(id)
}


public 
client_connect(id){
    
g_p_local_userid[id] = _GenerateUserId()
    
_UnSet(_authedid)
}


public 
client_authorized(id){
    if(
is_user_bot(id) || is_user_hltv(id))
        return
    
_Set(_authedid)
    if(
_Is(_in_serverid))
        
Player_Load(id)
}


public 
client_putinserver(id){
    
g_p_level[id] = 0
    g_p_kills
[id] = 0
    _Set
(_in_serverid)
    if(
_Is(_authedid))
        
Player_Load(id)
}


public 
client_disconnect(id){
    
Player_Save(id)
    
_UnSet(_authedid)
    
_UnSet(_in_serverid)
    
_UnSet(_loadedid)
}


public 
Player_KilledPost(victimattacker){
    if(
victim==attacker || !(1<=attacker<=g_max_players))
        return
    
g_p_kills[attacker]++
    if(
g_p_level[attacker]+1<sizeof(g_levels) && g_levels[g_sort[g_p_level[attacker]+1]][ELD_kills] <= g_p_kills[attacker])
        
g_p_level[attacker]++
}


public 
Player_Load(id){
    if(!
g_sql_ready)
        return   
    new 
authid[36]
    
get_user_authid(idauthidsizeof(authid)-1)
    new 
cache[128]
    
formatex(cachesizeof(cache)-1"SELECT `kills` FROM `kills_counter` 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"cachedata2)
}


public 
qh_Player_Load(FailState,Handle:Query,Error[],Errcode,Data[],DataSize){
    new 
id Data[0]
    if(!
_Is(_in_serverid) || 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(_loadedid)
    if(!
SQL_MoreResults(Query))
        return
    
g_p_kills[id] = SQL_ReadResult(Query0)
    new 
level
    
do{
        
level++
    }while(
level <  sizeof(g_levels) && g_levels[g_sort[level]][ELD_kills] <= g_p_kills[id])
    
g_p_level[id] = level-1    
}
    
    
public 
Player_Save(id){
    if(!
_Is(_loadedid)) 
        return
    new 
authid[36]
    
get_user_authid(idauthidsizeof(authid)-1)
    new 
cache[128]
    
formatex(cachesizeof(cache)-1"REPLACE INTO `kills_counter` (`authid`,`kills`)VALUES('%s','%d');"authidg_p_kills[id])
    
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 
msg_SayText(msg_idmsg_destmsg_ent){
    static 
name[32], cache[256], poschat_id
    get_msg_arg_string
(2cache255)

    if(!
TrieGetCell(gt_chatcachechat_id))
        return 
PLUGIN_CONTINUE
    
    
new id get_msg_arg_int(1)
    
get_user_name(idname31)
    
    switch(
chat_id){
        case 
1pos formatex(cachesizeof(cache)-1"^1")
        case 
2pos formatex(cachesizeof(cache)-1"^1*DEAD* ")
        case 
3pos formatex(cachesizeof(cache)-1"^1(Terrorist) ")
        case 
4pos formatex(cachesizeof(cache)-1"^1*DEAD*(Terrorist) ")
        case 
5pos formatex(cachesizeof(cache)-1"^1(Counter-Terrorist) ")
        case 
6pos formatex(cachesizeof(cache)-1"^1*DEAD*(Counter-Terrorist) ")
        case 
7pos formatex(cachesizeof(cache)-1"^1(Spectator) ")
        case 
8pos formatex(cachesizeof(cache)-1"^1*SPEC* ")
    }
    
    
pos += formatex(cache[pos], sizeof(cache)-1"^4[%s] ^3%s^1: "g_levels[g_sort[g_p_level[id]]][ELD_name], name)
    
    
get_msg_arg_string(4cache[pos], sizeof(cache)-pos)
    
set_msg_arg_string(4"")
    
cache[191] = 0
    set_msg_arg_string
(2cache)
    return 
PLUGIN_CONTINUE

__________________
Impossible is Nothing
Sylwester is offline
Old 03-20-2012, 16:13
Exolent[jNr]
This message has been deleted by Exolent[jNr].
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 03-21-2012 , 11:07   Re: Nvault to SQL
Reply With Quote #8

More fixes to include.

Here is a plugin to copy over NVault vaults to SQLVault.

Server Commands (no admin console):
nvault_to_sqlvault "myvault" -- will convert into SQLite"
nvault_to_sqlvault "myvault" "default" -- will convert into MySQL server info from "amx_sql_*" cvars
nvault_to_sqlvault "myvault" "host" "user" "pass" "db" -- will convert into specified MySQL server info
Attached Files
File Type: sma Get Plugin or Get Source (nvault_to_sqlvault.sma - 881 views - 2.6 KB)
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!

Last edited by Exolent[jNr]; 03-21-2012 at 11:07.
Exolent[jNr] is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 03-21-2012 , 19:24   Re: Nvault to SQL
Reply With Quote #9

Quote:
Originally Posted by Exolent[jNr] View Post
More fixes to include.

Here is a plugin to copy over NVault vaults to SQLVault.

Server Commands (no admin console):
nvault_to_sqlvault "myvault" -- will convert into SQLite"
nvault_to_sqlvault "myvault" "default" -- will convert into MySQL server info from "amx_sql_*" cvars
nvault_to_sqlvault "myvault" "host" "user" "pass" "db" -- will convert into specified MySQL server info
NICE!!!! now i can upgrade to sql without losing my data lol.
Doc-Holiday is offline
fucked_up_kid
Junior Member
Join Date: Apr 2012
Old 11-23-2012 , 16:26   Re: Nvault to SQL
Reply With Quote #10

Can someone do the same but only sql to nvault ? Please?
fucked_up_kid 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:29.


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