Raised This Month: $ Target: $400
 0% 

(solved) problem doing set_localinfo with a var


Post New Thread Reply   
 
Thread Tools Display Modes
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
KiN | SuicideDog
Senior Member
Join Date: Mar 2004
Old 06-17-2004 , 12:05  
Reply With Quote #2

Come one someone has got to be able to help me. I've been trying to it to remember my maps for sometime. I know deagles map management does this but I don't want all the other stuff his does. I've tried to convert some old amx plugins but I can't get it to work. Someone please help!! ARGH
__________________
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
jtp10181
Veteran Member
Join Date: May 2004
Location: Madison, WI
Old 06-17-2004 , 12:28  
Reply With Quote #3

the vault is super easy to use.... I suggest going that path and setting one value in the vault with a list of the last played maps with spaces in between, then after you load it you can use the parse function to bust it up into 5 separate strings again.

I have never used this setinfo thing you are trying to use.
__________________
jtp10181 is offline
Send a message via ICQ to jtp10181 Send a message via AIM to jtp10181 Send a message via MSN to jtp10181 Send a message via Yahoo to jtp10181
KiN | SuicideDog
Senior Member
Join Date: Mar 2004
Old 06-17-2004 , 13:24  
Reply With Quote #4

ok.. I fixed one of the problems

Code:
  for(new count = 1;count<=SELECTMAPS;++count){     new messagea[9]     num_to_str(count,countstr,1)     format(messagea,8,"lastmap%c",countstr)     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]     num_to_str(count,countstr,1)     format(messageb,8,"lastmap%c",countstr)         set_localinfo(messageb,g_lastMap[count -1])     server_print("Setting %s :  it now equals %s", messageb, g_lastMap[count])   }

on the console it gives me this:

Code:
Getting lastmap1 :  it equals
Getting lastmap2 :  it equals
Getting lastmap3 :  it equals
Getting lastmap4 :  it equals
Getting lastmap5 :  it equals
Setting lastmap2 :  it now equals
Setting lastmap3 :  it now equals
Setting lastmap4 :  it now equals
Setting lastmap5 :  it now equals
it looks like there is a problem with my array.. or how I'm dumping data to my array

any help for the amxx god's on this one.. I'm so close on this one
__________________
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
KiN | SuicideDog
Senior Member
Join Date: Mar 2004
Old 06-17-2004 , 14:01  
Reply With Quote #5

ok.. at this point I now need to know if my programming is screwed up or if it's just amxx. It wouldn't be the first time that I tried to do something that *should* work only to find out it won't work until .2
__________________
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
KiN | SuicideDog
Senior Member
Join Date: Mar 2004
Old 06-17-2004 , 16:09  
Reply With Quote #6

got it to work thanks to PM.. we be posting it shortly
__________________
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
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 14:41.


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