AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Map not changed after voting! (https://forums.alliedmods.net/showthread.php?t=299956)

argox 07-31-2017 11:53

Map not changed after voting!
 
Hi, I need a lot of help from everyone here, I have a auto mix plugin running almost everything perfectly, the problem occurs when the votemap, which when finalized the vote the chosen map is not loaded.

Here is the votemap code, please wait for help.

PHP Code:

/* ------------ VARIABLES THE VOTEMAP */
new gMapsIniFile[64],gMapsDisponiveis[30][20],gMapsChosen[4][20],ggVotes[5]
new 
gMapsCounter,gDoneMaps,gChangeMapTo,ggVoteMenu,gPlacar,gAviso 

PHP Code:

public VoteMap(){  
    
getmaps() 
    new 
rnd 
    
while (gDoneMaps != && gMapsCounter 0) { 
        
rnd random(gMapsCounter
        
copy(gMapsChosen[gDoneMaps++], 19gMapsDisponiveis[rnd]) 
        
gMapsDisponiveis[rnd] = gMapsDisponiveis[--gMapsCounter
    }         
    
    
ggVoteMenu menu_create("\r Alugue seu servidor. ^n\y[ \w WhatsApp: 33 98436-9586 - \rVOTEMAP \y]^n","votethemap");
    
    new 
num[11
    for(new 
0gDoneMapsi++)  { 
        
num_to_str(inum10
        
menu_additem(ggVoteMenugMapsChosen[i], num0)
    }
    
menu_additem(ggVoteMenu"\yExtender mapa atual""4"0
    new 
players[32], pnumtempid
    
get_players(playerspnum"ch"); 
    for( new 
ii<pnumi++ ) { 
        
tempid players[i]; 
        
client_print(tempid,print_chat,"[ VOTEMAP ] Selecione o proximo mapa...")
        
menu_display(tempidggVoteMenu); 
    }
    
//client_cmd(0, "spk ^"get red(e80) ninety(s45) to check(e20) use bay(s18) mass(e42) cap(s50)^"")  
    
set_task(10.0"EndVote");  
    return 
PLUGIN_HANDLED



public 
votethemap(id,menu,item){
    if( 
item == MENU_EXIT ) {        
        
menu_display(idggVoteMenu)
        
        return 
PLUGIN_HANDLED;
    }
    
    new 
data[6], szName[64];
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdata,charsmax(data), szName,charsmax(szName), callback);
    new 
voteid str_to_num(data);
    new 
playerna[32]
    
get_user_name(idplayerna31)
    
    if (
voteid != 4)
        
client_print(0,print_chat,"[ VOTEMAP ] %s Escolheu %s para o proximo mapa... ",playerna,gMapsChosen[voteid])
    else 
        
client_print(0,print_chat,"[ VOTEMAP ] %s Escolheu Extender o Mapa atual...",playerna)
    
    
ggVotes[voteid]++;
    return 
PLUGIN_HANDLED;
}

public 
getmaps(){ 
    
get_configsdir(gMapsIniFile63); 
    
format(gMapsIniFile63"%s/maps.ini"gMapsIniFile); 
    
    new 
mapsfile fopen(gMapsIniFile"r"
    new 
linefortest[50
    
    while (
gMapsCounter sizeof(gMapsDisponiveis) && !feof(mapsfile)) { 
        
fgets(mapsfilelinefortest49
        
trim(linefortest
        
        new 
getcurrentmap[32]
        
get_mapname(getcurrentmap31)
        
        if ((
is_map_valid(linefortest)) && (!equali(linefortestgetcurrentmap))) 
            
copy(gMapsDisponiveis[gMapsCounter++], 24linefortest)  
    } 
    
    
fclose(mapsfile
}  

public 
EndVote(){ 
    
show_menu(00"^n"1); 
    new 
best 0
    for(new 
1sizeof(ggVotes); i++) { 
        if(
ggVotes[i] > ggVotes[best]) 
            
best i
    }
    
    
ggVotes[0] = 0
    ggVotes
[1] = 0
    ggVotes
[2] = 0
    ggVotes
[3] = 0
    ggVotes
[4] = 0
    
    
if(best == 4) { 
        
client_print(0,print_chat,"[ VOTEMAP ] Uma nova votacao ira iniciar em 10 Segundos");
        
set_task(10.0,"VoteMap")
    }
    else if(
best >= 5){
        
client_print(0,print_chat,"[ VOTEMAP ] Carregando Mapa %s",gMapsChosen[best]);
        
gChangeMapTo best;
    }
    if(
best <= 3){ 
        
client_print(0,print_chat,"[ VOTEMAP ] Mapa atual sera estendido...");
        
client_print(0,print_chat,"[ VOTEMAP ] Recarregando Modo FUN em 10 Segundos.");
        
set_task(10.0,"Fun",_,_,_,_,_);
        
best 0;
    } 
    
    return 
PLUGIN_HANDLED
}

public 
ChangeMap(){
    new 
maptochangeto[25]
    
    
remove_task()
    
copy(maptochangeto24gMapsChosen[gChangeMapTo])
    
server_cmd("changelevel %s"maptochangeto)
    return 
PLUGIN_CONTINUE



leonardo121 07-31-2017 12:16

Re: Map not changed after voting!
 
Are you calling this function?
Quote:

ChangeMap()

argox 07-31-2017 12:26

Re: Map not changed after voting!
 
Quote:

Originally Posted by leonardo121 (Post 2538881)
Are you calling this function?

Yes, see at the end of the code

leonardo121 07-31-2017 12:29

Re: Map not changed after voting!
 
is defined , But you're not calling it.

argox 07-31-2017 12:45

Re: Map not changed after voting!
 
Quote:

Originally Posted by leonardo121 (Post 2538884)
is defined , But you're not calling it.

What would be the correct variable to call the changemap function

leonardo121 07-31-2017 12:55

Re: Map not changed after voting!
 
PHP Code:

 else if(best >= 5){ 
        
client_print(0,print_chat,"[ VOTEMAP ] Carregando Mapa %s",gMapsChosen[best]); 
        
gChangeMapTo best
    } 

:arrow:

PHP Code:

 else if(best >= 5){ 
        
client_print(0,print_chat,"[ VOTEMAP ] Carregando Mapa %s",gMapsChosen[best]); 
        
gChangeMapTo best
        
ChangeMap() // here ?
    



Put all the code , and we can help you

argox 07-31-2017 13:23

Re: Map not changed after voting!
 
Quote:

Originally Posted by leonardo121 (Post 2538892)
PHP Code:

 else if(best >= 5){ 
        
client_print(0,print_chat,"[ VOTEMAP ] Carregando Mapa %s",gMapsChosen[best]); 
        
gChangeMapTo best
    } 

:arrow:

PHP Code:

 else if(best >= 5){ 
        
client_print(0,print_chat,"[ VOTEMAP ] Carregando Mapa %s",gMapsChosen[best]); 
        
gChangeMapTo best
        
ChangeMap() // here ?
    



Put all the code , and we can help you

Thanks, it now seems to have worked

leonardo121 07-31-2017 13:28

Re: Map not changed after voting!
 
if is your solution, put thread as solved

Natsheh 07-31-2017 13:31

Re: Map not changed after voting!
 
public ChangeMap(){
server_cmd("changelevel %s", gMapsChosen[gChangeMapTo])
return PLUGIN_CONTINUE
}

Why to be a complex...

argox 07-31-2017 15:16

Re: Map not changed after voting!
 
Quote:

Originally Posted by Natsheh (Post 2538902)
public ChangeMap(){
server_cmd("changelevel %s", gMapsChosen[gChangeMapTo])
return PLUGIN_CONTINUE
}

Why to be a complex...

thanks


All times are GMT -4. The time now is 22:48.

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