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

Previous Maps


Post New Thread Reply   
 
Thread Tools Display Modes
DarkGod
SourceMod DarkCrab
Join Date: Jul 2007
Location: Sweden
Old 06-06-2011 , 21:37   Re: Previous Maps
Reply With Quote #11

Quote:
Originally Posted by DPT View Post
DarkGod.. whats with that line of code?
handle: Handle:

Else it gives the tag mismatches.
__________________
DarkGod is offline
Send a message via AIM to DarkGod Send a message via MSN to DarkGod
DPT
Member
Join Date: Jun 2011
Old 06-07-2011 , 10:31   Re: Previous Maps
Reply With Quote #12

Alright, I fixed it and uploaded the new file. Thanks DarkGod
DPT is offline
alonelive
Senior Member
Join Date: Jan 2011
Location: Big snow country.. :)
Old 06-07-2011 , 10:56   Re: Previous Maps
Reply With Quote #13

Quote:
Originally Posted by DPT View Post
alonealive I'm sorry i didn't understand? In which program were you trying to compile the code?

DarkGod.. whats with that line of code?
Internal compilator (compile.exe), amxx v 181..
alonelive is offline
DPT
Member
Join Date: Jun 2011
Old 06-07-2011 , 11:31   Re: Previous Maps
Reply With Quote #14

alonealive, i have solved the problem.. Please download the new file and try it now
DPT is offline
alonelive
Senior Member
Join Date: Jan 2011
Location: Big snow country.. :)
Old 06-07-2011 , 14:21   Re: Previous Maps
Reply With Quote #15

Quote:
Originally Posted by DPT View Post
alonealive, i have solved the problem.. Please download the new file and try it now
Ok
alonelive is offline
Old 01-19-2012, 07:43
yamin
This message has been deleted by yamin.
Balage74
Member
Join Date: Dec 2006
Old 09-07-2012 , 13:08   Re: Previous Maps
Reply With Quote #16

Nice plugin, please complement this if you can, my idea:
- multiple server using this plugin one database-table (mysql table complement: server:port)-------------done
- reason of mapchange (change admin or end map)
- expand with nvault (if somebody want use 1 server)
thx
__________________

Last edited by Balage74; 09-12-2012 at 19:42. Reason: edit
Balage74 is offline
Send a message via MSN to Balage74 Send a message via Skype™ to Balage74
Balage74
Member
Join Date: Dec 2006
Old 09-12-2012 , 19:40   Re: Previous Maps
Reply With Quote #17

Code for multiple servers (all servers see own maps):

Code:
/* This plugin saves each played map in an SQL database (tried with MySQL). Upon requests from players through
   /previousmap and /previousmap_list commands, the plugin will show them which maps were played
   prior to the current map being played. In order to avoid unnecessary lag due to overloaded data
   in the database, this plugin will delete records (previos maps records) that are older than
   10 days from the database
   
   Player commands:-
   /previousmap: Displays the previous map played (before the current one)
   /previousmap_list Displays the last 10 maps played including time of change.
   
   */

#include <amxmodx>
#include <amxmisc>
#include <sqlx>

#define PLUGIN "Previous Maps"
#define VERSION "1.0"
#define AUTHOR "DPT"

new SErrorCode[512]

new fpreviousmap[25]

new Handle:SQLConnection
new Handle:SQLTuple
new motd[1024]


public plugin_init()
 {
    new Host[64],User[64],Pass[64],Db[64]
    new ErrorCode


    register_plugin(PLUGIN, VERSION, AUTHOR)
    
    get_cvar_string("amx_sql_host",Host,63)
    get_cvar_string("amx_sql_user",User,63)
    get_cvar_string("amx_sql_pass",Pass,63)
    get_cvar_string("amx_sql_db",Db,63)
    
    SQLTuple = SQL_MakeDbTuple(Host,User,Pass,Db)
    
    SQLConnection = SQL_Connect(SQLTuple,ErrorCode,SErrorCode,511)
    
    if(SQLConnection == Empty_Handle) set_fail_state(SErrorCode)
    
    register_clcmd("say /previousmap", "Show_PreviousMap");
    
    register_clcmd("say /previousmap_list", "Show_PreviousMapList");
    
    new Handle:query1 = SQL_PrepareQuery(SQLConnection,"CREATE TABLE IF NOT EXISTS previous_maps (id int(11) NOT NULL AUTO_INCREMENT, map_name varchar(25) DEFAULT NULL, time_date datetime DEFAULT NULL, PRIMARY KEY (id))")

    SQL_Execute(query1);
                
    Load_PreviousMaps()
    
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

string:Load_PreviousMaps()
{
    new Handle:query1 = SQL_PrepareQuery(SQLConnection, "SELECT map_name, DATE_FORMAT(time_date, '%%l:%%i %%p %%d %%M') AS time_date FROM previous_maps ORDER BY id DESC LIMIT 0,10");
    
    SQL_Execute(query1);
        
    new map_name[26]
    new time_date[30]
    new len,a = 0;
    
    len = format(motd, 1023,"<body bgcolor=#000000><font color=#FFB000><pre>")
    len += format(motd[len], 1023-len,"%s %-22.22s %3s^n", "#", "Map Name", "Time")
    
    while(SQL_MoreResults(query1))
    {
        
    SQL_ReadResult(query1, 0, map_name, 25)
    
    if (a == 0)
    {
    SQL_ReadResult(query1, 0, fpreviousmap, 25)    
    }
    
    SQL_ReadResult(query1, 1, time_date, 29)
    
    len += format(motd[len], 1023-len,"%d %-22.22s %s^n", a+1, map_name, time_date)
         
    a++;
    SQL_NextRow(query1)
    }

        len += format(motd[len], 1023-len,"</body></font></pre>")
    
    SQL_FreeHandle(query1)
    
    
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

public Show_PreviousMapList(id)
{
    show_motd(id, motd, "The Last 10 Maps Played")
    
    return PLUGIN_CONTINUE
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

public Show_PreviousMap(id)
{
    client_print(id,print_chat,"[Previous Maps] The previous map was: %s", fpreviousmap)
    
    return PLUGIN_CONTINUE
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

public plugin_end()
{
    new mapname[26]
    new deleted_rows
    
    get_mapname(mapname, 25);
    
    new Handle:query1 = SQL_PrepareQuery(SQLConnection, "INSERT INTO previous_maps VALUES(NULL, '%s', NOW())", mapname);

    SQL_Execute(query1);

    new Handle:query2 = SQL_PrepareQuery(SQLConnection, "DELETE FROM previous_maps WHERE DATE(time_date) < CURDATE() - INTERVAL 10 DAY");
    
    SQL_Execute(query2);
    
    deleted_rows = SQL_AffectedRows(query2)
    
    if (deleted_rows > 0) log_amx("%d previous map records have been deleted from the database (older than 10 days)", deleted_rows);
    
    SQL_FreeHandle(SQLConnection);
    
    SQL_FreeHandle(query2);
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/
__________________
Balage74 is offline
Send a message via MSN to Balage74 Send a message via Skype™ to Balage74
P1raten
Senior Member
Join Date: Feb 2010
Old 02-03-2013 , 07:04   Re: Previous Maps
Reply With Quote #18

Quote:
Originally Posted by DPT View Post
Original Post
You should free the SQLTuple Handle.

You are using the query1 Handle across almost every function, so why not just make it global?
Having to re-declare it in every function is not optimal.

EDIT: Also, make use of static variables.
EDIT 2: One word: pcvars.
__________________
No salvation. Only madness.

Last edited by P1raten; 02-03-2013 at 07:43.
P1raten is offline
PoLiCe
Senior Member
Join Date: Apr 2013
Location: Xen™
Old 05-02-2013 , 05:46   Re: Previous Maps
Reply With Quote #19

Can you make a nVault version instead of SQL?
__________________
PoLiCe is offline
Send a message via MSN to PoLiCe Send a message via Skype™ to PoLiCe
wickedd
Veteran Member
Join Date: Nov 2009
Old 05-02-2013 , 10:50   Re: Previous Maps
Reply With Quote #20

Quote:
Originally Posted by PoLiCe View Post
Can you make a nVault version instead of SQL?
Read the thread, there's a link to another one that doesn't use MYSQL.
__________________
Just buy the fucking game!!!!
I hate No-Steamers and lazy ass people.
wickedd 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 08:59.


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