AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Prokreedz edit top10 problem (https://forums.alliedmods.net/showthread.php?t=50595)

kinoute 01-29-2007 21:42

Prokreedz edit top10 problem
 
Hello,

I use this plugin but I have a problem with the /top15, indeed when a player is present in the top and when he does a new score, his name is again added on a new line and the old score is always here.. I think its normal and It is the plugin which makes that but I thus meet myself with a top performed with doubloons.. How fix that?

I found this part of the prokreedz.sma :

PHP Code:

public topten_update(id) { 
     new 
szvault[64], szmap[32], kreedztime 
     get_mapname
(szmap,32
     
format(szvault,64,"pk_%s",szmap
     
kreedztime get_systime() - timer_time[id-1
      
     new 
vault nvault_open(szvault// Now we have to sort the new list [IMG]http://xtreme-jumps.eu/e107_images/emoticons/smilie11.gif[/IMG]  
     
if(vault != -1) { 
         new 
szkey[8
         for(new 
i=1;i<=10;i++) { 
             new 
szreturn[128
             new 
arg1[32], arg2[8
             
format(szkey,8,"%d",i
             
nvault_get(vault,szkey,szreturn,128
              
             if(
parse(szreturn,arg1,32,arg2,8) == || kreedztime str_to_num(arg2)) { 
                 new 
sznew[128], szname[32
                 
get_user_name(id,szname,32
                 
format(sznew,128,"^"%s^" ^"%d^" ^"%d^"",szname,kreedztime,checkpointnum[id-1]) 
                 if(
10) { 
                     for(new 
x=10;x>i;x--) { 
                         new 
sztemp[128], sztempkey[8
                         
format(sztempkey,8,"%d",x-1
                         
nvault_get(vault,sztempkey,sztemp,128
                          
                         if(!
equal(sztemp,"")) { 
                             
format(sztempkey,8,"%d",x
                             
nvault_pset(vault,sztempkey,sztemp
                         } 
                     } 
                 } 
                 
nvault_pset(vault,szkey,sznew
                  
                 if(
== 1
                     
client_print(0,print_chat,"[ProKreedz] %s has established a new record",szname
                  
                 break 
             } 
         } 
         
nvault_close(vault
     } 
 } 

I suppose that it is in this place that the top is updated, how to limit the number of records by player to the only one in the top ? I would like to have twice no same player in top10.


thank you in advance and sorry for my bad english!

kinoute 01-30-2007 16:12

Re: Prokreedz edit top10 problem
 
Anyone ?

A guys posted this message on xtreme-jumps forums

Quote:

u have to add much lines of code for that

1. u have to save steam id from the players which are in top10

2. when someone reach target, it should check if ther is an entry to this steam id (new function)

if no, do nothing

if yes, check if new time is better

if yes, load topten_update
But i have no Knowledge in programming.. A coder can help me ?

Thanks you in advance !!

kinoute 02-05-2007 00:35

Re: Prokreedz edit top10 problem
 
Anyone ?

drx 03-10-2007 18:03

Re: Prokreedz edit top10 problem
 
hi

didnt test it that much, so its not gueranteed that its bugfree (if you find some, pls post theme here).

here it is:


replace your whole topten_update function with this:
PHP Code:

getTopTenPlace(id) {
        
    new 
currentMap[32];
    
get_mapname(currentMap32);
    
    new 
topTenVault[64];
    
format(topTenVault64"pk_%s"currentMap);
    
    new 
kzTime;    
    
kzTime get_systime() - timer_time[id-1];
    
    new 
vault nvault_open(topTenVault);
    new 
vaultKey[8];
    new 
vaultReturn[128];
    new 
arg1[32], arg2[8];
    
    new 
ret;
    
    if(
vault != INVALID_HANDLE) {
        
        for(new 
1<= 10i++) {
        
            
format(vaultKey8"%d"i);
            
            
nvault_get(vaultvaultKeyvaultReturn128);
            
            if(
parse(vaultReturnarg132arg28) != 0) {
                
                if(
kzTime str_to_num(arg2)) {
                
                    
ret i;
                    break;
                
                } else {
                
                    
ret 0;
                
                }
            
            } else {
                
                
ret i;
                break;
            
            }
        
        }
        
    }
    
    
nvault_close(vault);
    
    return 
ret;
}

// ==================

isPlayerInTopTen(id) {

    new 
userName[32];
    
get_user_name(iduserName32);

    new 
currentMap[32];
    
get_mapname(currentMap32);
    
    new 
topTenVault[64];
    
format(topTenVault64"pk_%s"currentMap);
    
    new 
vault nvault_open(topTenVault);
    new 
vaultKey[8];
    new 
vaultReturn[128];
    new 
arg1[32], arg2[8];
    
    new 
ret;
    
    if(
vault != INVALID_HANDLE) {
    
        for(new 
1<= 10i++) {
        
            
format(vaultKey8"%d"i);
            
            
nvault_get(vaultvaultKeyvaultReturn128);
            
            if(
parse(vaultReturnarg132arg28) != && equal(userNamearg1)) {
            
                
ret i;
                break;
            
            } else {
            
                
ret 0;
            
            }
        
        }
    
    }
    
    
nvault_close(vault);
    
    return 
ret;
}

// ==================

showTime(idnewPlace) {

    new 
userName[32];
    
get_user_name(iduserName32);
    
    new 
kzTime;    
    
kzTime get_systime() - timer_time[id-1];
    
    new 
minutesseconds
                        
    
if((kzTime 60.0) >= 1) {

        
minutes floatround(kzTime 60.0,floatround_floor);
        
kzTime -= (floatround(kzTime60.0,floatround_floor) * 60);
        
seconds kzTime;
        
    } else {
        
        
minutes 0;
        
seconds kzTime;
    
    }

    
set_hudmessage(255255255, -1.0, -1.0);
    
    if(
newPlace == 1) {
    
        
show_hudmessage(0"%s finished the map in %d min %d sec and established a new record"userNameminutesseconds);
        
    } else if(
newPlace == 0) {
    
        
show_hudmessage(0"%s finished the map in %d min %d sec"userNameminutesseconds);
    
    } else {
    
        
show_hudmessage(0"%s finished the map in %d min %d sec and established a new Top10 time"userNameminutesseconds);
    
    }

}

// ==================

public topten_update(id) {
    
    new 
newPlace getTopTenPlace(id);
    
    new 
oldPlace isPlayerInTopTen(id);
    
    new 
userName[32];
    
get_user_name(iduserName32);

    new 
currentMap[32];
    
get_mapname(currentMap32);
    
    new 
kzTime;    
    
kzTime get_systime() - timer_time[id-1];
    
    new 
vaultEntry[128];
    
format(vaultEntry128"^"%s^" ^"%d^" ^"%d^""userNamekzTimecheckpointnum[id-1]);
    
    new 
topTenVault[64];
    
format(topTenVault64"pk_%s"currentMap);
    
    new 
vault nvault_open(topTenVault);
    
    if(
oldPlace 0) {
    
        if(
newPlace ) {
        
            new 
key[8];
            
            if(
newPlace oldPlace) {
        
                
format(key8"%d"oldPlace);
                
nvault_remove(vaultkey);
                
                for(new 
oldPlace10i++) {
                
                    new 
temp[128], tempKey[8]
                    
format(tempKey,8,"%d",i+1)
                    
nvault_get(vault,tempKey,temp,128)
                    
                    if(!
equal(temp,"")) {
                        
format(tempKey,8,"%d",i)
                        
nvault_pset(vault,tempKey,temp)
                    }
                    
                }
                
                for(new 
10newPlacei--) {
                
                    new 
temp[128], tempKey[8]
                    
format(tempKey,8,"%d",i-1)
                    
nvault_get(vault,tempKey,temp,128)
                    
                    if(!
equal(temp,"")) {
                        
format(tempKey,8,"%d",i)
                        
nvault_pset(vault,tempKey,temp)
                    }
                    
                }
                
                
format(key8"%d"newPlace);
                
nvault_pset(vaultkeyvaultEntry);
            
            } else if(
newPlace == oldPlace) {
                
                
format(key8"%d"oldPlace);
                
nvault_remove(vaultkey);
                
format(key8"%d"newPlace);
                
nvault_pset(vaultkeyvaultEntry);
            
            }
            
            
showTime(idnewPlace);
            
        
        } 
        
    } else {
    
        if(
newPlace 0) {
        
            for(new 
10newPlacei--) {
            
                new 
temp[128], tempKey[8]
                
format(tempKey,8,"%d",i-1)
                
nvault_get(vault,tempKey,temp,128)
                
                if(!
equal(temp,"")) {
                    
format(tempKey,8,"%d",i)
                    
nvault_pset(vault,tempKey,temp)
                }
                
            }
            
            new 
key[8];

            
format(key8"%d"newPlace);
            
nvault_pset(vaultkeyvaultEntry);
            
            
showTime(idnewPlace);
        
        } 
    
    }
    
    
nvault_close(vault);
    



aDr. 04-27-2007 05:21

Re: Prokreedz edit top10 problem
 
1 Attachment(s)
Works on Windows , but on linux dont work

slpknt 06-17-2008 10:44

Re: Prokreedz edit top10 problem
 
found a bug, if some one was 2nd and became 1st, the result of 3rd copies to 2nd place.
so one guy will be twice in the top10

vato loco [GE-S] 06-18-2008 02:59

Re: Prokreedz edit top10 problem
 
take a look at this !

http://forums.alliedmods.net/showthr...ight=prokreedz


All times are GMT -4. The time now is 00:40.

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