AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   unique match id (https://forums.alliedmods.net/showthread.php?t=96023)

usabrad86 06-29-2009 21:14

unique match id
 
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



fysiks 06-29-2009 23:45

Re: unique match id
 
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.

|PJ| Shorty 06-30-2009 09:46

Re: unique match id
 
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

usabrad86 07-02-2009 05:04

Re: unique match id
 
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?


All times are GMT -4. The time now is 15:33.

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