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

unique match id


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
usabrad86
Junior Member
Join Date: Jun 2009
Location: Florida
Old 06-29-2009 , 21:14   unique match id
Reply With Quote #1

can someone give me a sample code to generate a unique matchid
for ex. if i type in server console amx_newmatchid i need cvar sv_matchuid to go +1 BUT i need it to be unique(lets say server crashes or...something stupid)
i cant have sv_matchuid reset to 0.. BUT is server does crash on sv_matchuid "517" i need the the next match to be 518 and so on

why i need this.. its for my HLTV server so i dont get my demos mixed up and so people can download the hltv demo with the match id that know-of

im useing HLTV-invite to send commands to hltv

this is the code have for hltv-invite
PHP Code:
public hltv_record() {
    new 
cmd[64]
    
//GrabMatchID
    
new sv_matchuid[6]
    
get_cvar_string("sv_matchuid",sv_matchuid,6);

    
//stop-recording before start-recording
    
hltv_stoprecord()
    
    
//this is the command sent to HLTV
    
format(cmd63"record %s",sv_matchuid);
    
    
log_amx("Command sent to HLTV(%s).",cmd);
    
hltv_rcon_cmd(cmd);
    return 
PLUGIN_CONTINUE

usabrad86 is offline
Send a message via AIM to usabrad86
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-29-2009 , 23:45   Re: unique match id
Reply With Quote #2

If the server crashes the cvar will be reset to the default value.

You probably need to write the number to a file and update it (write to the file) when you send the record command.
__________________
fysiks is offline
|PJ| Shorty
Veteran Member
Join Date: Aug 2005
Location: Bavaria, Germany
Old 06-30-2009 , 09:46   Re: unique match id
Reply With Quote #3

why not using systime... itīs then not a following number but really unique
if you are using mysql too you could insert the systime to a table, second coloumn with auto increment value then you have a following unique number (maybe also possible with sqlite or nvault, i donīt know)

get_systime() http://www.amxmodx.org/funcwiki.php?go=func&id=251
__________________
There are only 10 types of people in the world:
Those who understand binary, and those who donīt.

Last edited by |PJ| Shorty; 06-30-2009 at 09:50.
|PJ| Shorty is offline
Send a message via ICQ to |PJ| Shorty Send a message via AIM to |PJ| Shorty Send a message via MSN to |PJ| Shorty Send a message via Yahoo to |PJ| Shorty Send a message via Skype™ to |PJ| Shorty
usabrad86
Junior Member
Join Date: Jun 2009
Location: Florida
Old 07-02-2009 , 05:04   Re: unique match id
Reply With Quote #4

well if you think HLTV allready puts time stamp in the demo

but i was also thinking about useing mysql to store and grab+1
and saving that to a cvar

you think this would work better?
usabrad86 is offline
Send a message via AIM to usabrad86
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 03:00.


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