Raised This Month: $ Target: $400
 0% 

(solved) problem doing set_localinfo with a var


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
KiN | SuicideDog
Senior Member
Join Date: Mar 2004
Old 06-17-2004 , 01:07   (solved) problem doing set_localinfo with a var
Reply With Quote #1

ok.. I'm modding the orginal mapchooser plugin so that it remembers the last five maps. I'm using the setinfo instead of messing with the vault. I'm having a problem thou ..

Code:
/* AMX Mod X *   Nextmap Chooser Plugin (PLUS) * *  Modded by SuicideDog 6/16/2004 from orginal amxx mapchooser *  version fomr amxx * *  Changes: * *  Now saves the last five maps and doesn't call them up when voting *  Changed the ini file to mapchooser.ini // did this so I could have different maps for admin and the chooser plugin *  Change the timing on when the menu should try to come up. * *  Special thanks to Scarzzurs for helping me figure some stuff out. */ #include <amxmodx> #include <amxmisc> #define MAX_MAPS    128 #define SELECTMAPS  5 new g_mapName[MAX_MAPS][32] new g_mapNums new g_nextName[SELECTMAPS] new g_voteCount[SELECTMAPS+2] new g_mapVoteNum new g_teamScore[2] new g_lastMap[SELECTMAPS+2][32] new maps_ini_file[64]; new g_cstrikeRunning new bool:g_selected = false public plugin_init() {   register_plugin("Nextmap Chooser+","0.1","SuicideDog Mod")   register_menucmd(register_menuid("AMX Choose nextmap:"),(-1^(-1<<(SELECTMAPS+2))),"countVote")   register_cvar("amx_extendmap_max","90")   register_cvar("amx_extendmap_step","15")   register_event("RoundTime", "NewRound", "bc")   if ( ( g_cstrikeRunning = is_running("cstrike") ) != 0 ){       register_event("TeamScore", "team_score", "a")   }     for(new count = 1;count<=SELECTMAPS;++count){     new messagea[9]     format(messagea,8,"lastmap%c",count)     get_localinfo(messagea,g_lastMap[count],31)     server_print("Getting %s :  it equals $s", messagea, g_lastMap[count])   }       for(new count = 2;count<=SELECTMAPS;++count){     new messageb[9]     format(messageb,8,"lastmap%c",count)         set_localinfo(messageb,g_lastMap[count -1])     server_print("Setting %s :  it now equals $s", messageb, g_lastMap[count])   }     get_configsdir(maps_ini_file, 63);   format(maps_ini_file, 63, "%s/mapchooser.ini", maps_ini_file); } public NewRound(){    if ( loadSettings(maps_ini_file) )    set_task(6.0,"voteNextmap") } public checkVotes(){    new b = 0    for(new a = 0; a < g_mapVoteNum; ++a)       if (g_voteCount[b] < g_voteCount[a])          b = a    if ( g_voteCount[SELECTMAPS] > g_voteCount[b] ) {       new mapname[32]       get_mapname(mapname,31)       new Float:steptime = get_cvar_float("amx_extendmap_step")       set_cvar_float("mp_timelimit", get_cvar_float("mp_timelimit") + steptime )       client_print(0,print_chat,"Choosing finished. Current map will be extended to next %.0f minutes", steptime )       log_amx("Vote: Voting for the nextmap finished. Map %s will be extended to next %.0f minutes",          mapname , steptime )       return    }    if ( g_voteCount[b] && g_voteCount[SELECTMAPS+1] <= g_voteCount[b] )       set_cvar_string("amx_nextmap", g_mapName[g_nextName[b]] )    new smap[32]    get_cvar_string("amx_nextmap",smap,31)    client_print(0,print_chat,"Choosing finished. The nextmap will be %s", smap )    log_amx("Vote: Voting for the nextmap finished. The nextmap will be %s", smap) } public countVote(id,key){    if ( get_cvar_float("amx_vote_answers") ) {       new name[32]       get_user_name(id,name,31)       if ( key == SELECTMAPS )          client_print(0,print_chat,"%s chose map extending", name )       else if ( key < SELECTMAPS )          client_print(0,print_chat,"%s chose %s", name, g_mapName[g_nextName[key]] )    }    ++g_voteCount[key]    return PLUGIN_HANDLED } bool:isInMenu(id){    for(new a=0; a<g_mapVoteNum; ++a)       if (id==g_nextName[a])          return true    return false } public voteNextmap(){   new winlimit = get_cvar_num("mp_winlimit")   new maxrounds = get_cvar_num("mp_maxrounds")   if ( winlimit ) {     new c = winlimit - 2     if ( (c > g_teamScore[0]) && (c > g_teamScore[1]) ) {       g_selected = false       return     }   }   else  if ( maxrounds ) {     if ( (maxrounds - 2) > (g_teamScore[0] + g_teamScore[1]) ){       g_selected = false       return     }   }   else {     new timeleft = get_timeleft()     if (timeleft<1||timeleft>129){       g_selected = false       return     }   }   if (g_selected)     return   g_selected = true   new menu[512], a, mkeys = (1<<SELECTMAPS+1)   new pos = copy(menu,511,g_cstrikeRunning ? "\yAMX Choose nextmap:\w^n^n" : "AMX Choose nextmap:^n^n")   new dmax = (g_mapNums > SELECTMAPS) ? SELECTMAPS : g_mapNums   for(g_mapVoteNum = 0;g_mapVoteNum<dmax;++g_mapVoteNum){     a=random_num(0,g_mapNums-1)     while( isInMenu(a) )       if (++a >= g_mapNums) a = 0     g_nextName[g_mapVoteNum] = a     pos += format(menu[pos],511,"%d. %s^n",g_mapVoteNum+1,g_mapName[a])     mkeys |= (1<<g_mapVoteNum)     g_voteCount[g_mapVoteNum] = 0   }   menu[pos++]='^n'   g_voteCount[SELECTMAPS] = 0   g_voteCount[SELECTMAPS+1] = 0   new mapname[32]   get_mapname(mapname,31)   if ( (winlimit + maxrounds)==0 && (get_cvar_float("mp_timelimit") < get_cvar_float("amx_extendmap_max"))){     pos += format(menu[pos],511,"%d. Extend map %s^n",SELECTMAPS+1,mapname)     mkeys |= (1<<SELECTMAPS)   }   format(menu[pos],511,"%d. None",SELECTMAPS+2)   show_menu(0,mkeys,menu,15)   set_task(15.0,"checkVotes")   client_print(0,print_chat,"It's time to choose the nextmap...")   client_cmd(0,"spk Gman/Gman_Choose2")   log_amx("Vote: Voting for the nextmap started") } loadSettings(filename[]) {   if (!file_exists(filename)) return 0   new szText[32]   new a, pos= 0   new match = 0   new currentMap[32]   get_mapname(currentMap,31)   while ( (g_mapNums < MAX_MAPS) && read_file(filename,pos++,szText,31,a) )   {         server_print("checking for previous started")         if ( szText[0] != ';'     &&  parse(szText, g_mapName[g_mapNums] ,31 )     &&  is_map_valid( g_mapName[g_mapNums] )     &&  !equali( g_mapName[g_mapNums] ,currentMap) ){             server_print("Part 1 done now checking previous maps")             for(new count = 1;count <= SELECTMAPS;++count){         if (equali( g_mapName[g_mapNums] ,g_lastMap[count])){            server_print("Found match .. skipping")            match = 1         }           server_print("Didn't find match for that map")       }       if (match < 1){          server_print("Map added to list")          ++g_mapNums       }else match = 0                 }   }   server_print("Done checking")   return g_mapNums } public team_score(){   new team[2]   read_data(1,team,1)   g_teamScore[ (team[0]=='C') ? 0 : 1 ] = read_data(2) } public plugin_end(){   new current_map[32]   get_mapname(current_map,31 )   set_localinfo("lastMap1",current_map) }

it doesn't look like the following part is working

Code:
 for(new count = 1;count<=SELECTMAPS;++count){     new messagea[9]     format(messagea,8,"lastmap%c",count)     get_localinfo(messagea,g_lastMap[count],31)     server_print("Getting %s :  it equals $s", messagea, g_lastMap[count])   }       for(new count = 2;count<=SELECTMAPS;++count){     new messageb[9]     format(messageb,8,"lastmap%c",count)         set_localinfo(messageb,g_lastMap[count -1])     server_print("Setting %s :  it now equals $s", messageb, g_lastMap[count])   }

which I use later in this section

Code:
    if ( szText[0] != ';'     &&  parse(szText, g_mapName[g_mapNums] ,31 )     &&  is_map_valid( g_mapName[g_mapNums] )     &&  !equali( g_mapName[g_mapNums] ,currentMap) ){             server_print("Part 1 done now checking previous maps")             for(new count = 1;count <= SELECTMAPS;++count){         if (equali( g_mapName[g_mapNums] ,g_lastMap[count])){            server_print("Found match .. skipping")            match = 1         }           server_print("Didn't find match for that map")       }       if (match < 1){          server_print("Map added to list")          ++g_mapNums       }else match = 0                 }   }   server_print("Done checking")   return g_mapNums }

can someone help me with this.. and tell me what I"m doing wrong?
__________________
Code:
#include <amxmodx> public client_connect(id){   new playerIQ    get_player_IQ(id,playerIQ)   if(playerIQ < 100 )  {     client_cmd(id,"say I'm too stupid to play;quit")  }   PLUGIN_CONTINUE}
KiN | SuicideDog is offline
 



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 14:41.


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