AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   MapVote Ini (https://forums.alliedmods.net/showthread.php?t=294224)

DarthMan 02-22-2017 15:28

MapVote Ini
 
This is more of a request , but the thing is that I am not good at reading from ini files. I need a script that will read the map names from mapvote.ini and use it to create models in front of every mapvote_breaker entity, which is a func wall, without repeating any of them if there are more than or equal to 44 maps in the ini . For each model it should display the mapname in center if u get close to it. This is really important for me, because I want something that u can only find for CS, a map where u can vote other maps. This will be used for non-CS goldsrc servers. Thanks !

Natsheh 02-22-2017 17:47

Re: MapVote Ini
 
wrong section...

DarthMan 02-22-2017 17:56

Re: MapVote Ini
 
Quote:

Originally Posted by Natsheh (Post 2497623)
wrong section...

Yes, how can I move it to the request section?

Btw, I did this, with no luck :(

Code:

    ent_light_1 = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "light"))
    set_pev(ent_light_1, pev_origin, "-417.0, 952.0, -165.0")
    //entity_set_origin(ent_light_1,Float:{-417.0,952.0,-165.0})
    DispatchKeyValue(ent_light_1, "brightness", "5");
    DispatchKeyValue(ent_light_1, "style", "0");
    DispatchKeyValue(ent_light_1, "_light", "241 241 241");
    dllfunc( DLLFunc_Spawn, ent_light_1 );
    }


pizzahut 02-25-2017 12:07

Re: MapVote Ini
 
Part of your request, that is reading an ini file and selecting random maps from it, without duplicates.
Code:
#include <amxmodx> #include <amxmisc> #define MAXNAMES 500 #define PANELCOUNT 40 new g_mapnames[MAXNAMES][32] new g_mapcount new g_mapselected[MAXNAMES] new g_mapselection[PANELCOUNT] public plugin_init() {     register_plugin("Random map selection", "1", "pizzahut")     read_cfg_file()     register_event("ResetHUD", "display_maps", "be") } read_cfg_file() {     new configfile[200]     get_configsdir(configfile, charsmax(configfile))     format(configfile, charsmax(configfile), "%s/maps.ini", configfile)     if (file_exists(configfile))     {         new mapname[32], chars_read         for (new line; (line < file_size(configfile, 1)) && (g_mapcount < MAXNAMES); line++)         {             read_file(configfile, line, mapname, charsmax(mapname), chars_read)             if (is_map_valid(mapname))             {                 copy(g_mapnames[g_mapcount], charsmax(g_mapnames[]), mapname)                 g_mapcount++             }         }     }     new map     for (new panel; (panel < PANELCOUNT) && (panel < g_mapcount); panel++)     {         map = random(g_mapcount)         while (g_mapselected[map])             map = random(g_mapcount)         g_mapselected[map] = 1         g_mapselection[panel] = map     } } public display_maps(id) {     new map     for (new panel; (panel < PANELCOUNT) && (panel < g_mapcount); panel++)     {         map = g_mapselection[panel]         client_print(id, print_console, "%d. %s", panel + 1, g_mapnames[map])     }     client_print(id, print_chat, "Check console for the list of selected maps.") }

pizzahut 02-25-2017 15:29

Re: MapVote Ini
 
I forgot about pre-caching, plus this probably won't even work (not tested).

Code:
#include <amxmodx> #include <amxmisc> #include <engine> #define MAXNAMES 500 #define PANELCOUNT 40 new g_mapnames[MAXNAMES][32] new g_mapcount new g_mapselected[MAXNAMES] new g_mapselection[PANELCOUNT] public plugin_init() {     register_plugin("Assign maps to panels", "1", "pizzahut")     read_cfg_file()     display_maps() } read_cfg_file() {     new configfile[200]     get_configsdir(configfile, charsmax(configfile))     format(configfile, charsmax(configfile), "%s/maps.ini", configfile)     if (file_exists(configfile))     {         new mapname[32], chars_read         for (new line; (line < file_size(configfile, 1)) && (g_mapcount < MAXNAMES); line++)         {             read_file(configfile, line, mapname, charsmax(mapname), chars_read)             if (is_map_valid(mapname))             {                 copy(g_mapnames[g_mapcount], charsmax(g_mapnames[]), mapname)                 g_mapcount++             }         }     }     new map     for (new panel; (panel < PANELCOUNT) && (panel < g_mapcount); panel++)     {         map = random(g_mapcount)         while (g_mapselected[map])             map = random(g_mapcount)         g_mapselected[map] = 1         g_mapselection[panel] = map     } } display_maps() {     new ent, panel, ent_info_target, model_path[128]     new Float:mins[3], Float:maxs[3], Float:origin[3]     while ((ent = find_ent_by_tname(ent, "glass_votemap")))     {         entity_get_vector(ent, EV_VEC_mins, mins)         entity_get_vector(ent, EV_VEC_maxs, maxs)         origin[0] = (mins[0] + maxs[0]) / 2.0         origin[1] = (mins[1] + maxs[1]) / 2.0         origin[2] = (mins[2] + maxs[2]) / 2.0         ent_info_target = create_entity("info_target")         entity_set_origin(ent_info_target, origin)         format(model_path, charsmax(model_path), "models/fm/maps/%s.mdl",g_mapnames[g_mapselection[panel]])         entity_set_model(ent_info_target, model_path)         panel++     } }

From DarthMan:

Code:
public plugin_precache() {     new conffile_mdl[200]     new configdir_mdl[200]     get_configsdir(configdir_mdl,199)     format(conffile_mdl,199,"%s/mapvote_precache.ini",configdir_mdl)     if(!file_exists(conffile_mdl))     {         log_amx("amxmodx/configs/mapvote_precache.ini is missing!")         return 0     }     new lines = file_size(conffile_mdl,1)     new file[1024], len     for(new i=0;i<=lines;i++)     {         read_file(conffile_mdl,i,file,1023,len)         if(equal(file,"")) continue;         if(!equal(file,";",1)) precache_model(file);     }     return PLUGIN_HANDLED }

pizzahut 02-26-2017 13:12

Re: MapVote Ini
 
Known bug: May find several panels for a player.
Code:
public display_map_name(task_id) {     new ent     new entcount, entlist[32]     new panel     while ((ent = find_ent_by_tname(ent, "target_map")))     {         entcount = find_sphere_class(ent, "player", 100.0, entlist, sizeof(entlist))         if (entcount > 0) client_print(0, print_chat, "Found %d players at panel %d.", entcount, panel + 1)         for(new player_index; player_index < entcount; player_index++)         {             set_hudmessage(g_hud_colour[0], g_hud_colour[1], g_hud_colour[2], -1.0, -1.0, 0, 0.0, 0.8, 0.1, 0.1, -1)             show_hudmessage(entlist[player_index], g_mapnames[g_mapselection[panel]])         }         panel++     } }

DarthMan 02-27-2017 03:52

Re: MapVote Ini
 
Quote:

Originally Posted by pizzahut (Post 2498816)
Known bug: May find several panels for a player.
Code:
public display_map_name(task_id) {     new ent     new entcount, entlist[32]     new panel     while ((ent = find_ent_by_tname(ent, "target_map")))     {         entcount = find_sphere_class(ent, "player", 100.0, entlist, sizeof(entlist))         if (entcount > 0) client_print(0, print_chat, "Found %d players at panel %d.", entcount, panel + 1)         for(new player_index; player_index < entcount; player_index++)         {             set_hudmessage(g_hud_colour[0], g_hud_colour[1], g_hud_colour[2], -1.0, -1.0, 0, 0.0, 0.8, 0.1, 0.1, -1)             show_hudmessage(entlist[player_index], g_mapnames[g_mapselection[panel]])         }         panel++     } }

If possible, please no longer post the code here because I would not like the mapvote plugin to be public for everyone to be able to use it on any goldsrc game. Only post if I request something there or if someone else asks for smth related to mapvote.

wickedd 02-27-2017 06:24

Re: MapVote Ini
 
Quote:

Originally Posted by DarthMan (Post 2498996)
If possible, please no longer post the code here because I would not like the mapvote plugin to be public for everyone to be able to use it on any goldsrc game. Only post if I request something there or if someone else asks for smth related to mapvote.

Then go post somewhere else. :stupid:

DarthMan 02-27-2017 08:13

Re: MapVote Ini
 
Quote:

Originally Posted by wickedd (Post 2499019)
Then go post somewhere else. :stupid:

I did not ask here for the things that pizzahut did the last time. Yes, I told him to help me, but the thing is that what I actually asked for was not asked here, he just posted the code because I beleive he thinks thinked that it would be better to post it here for other people in case they want to make something simillar but they don't know how to.

pizzahut 02-27-2017 13:22

Re: MapVote Ini
 
It was not asked here, what?
Quote:

Originally Posted by DarthMan (Post 2497598)
I need a script that will read the map names from mapvote.ini and use it to create models in front of every mapvote_breaker entity, which is a func wall, without repeating any of them if there are more than or equal to 44 maps in the ini . For each model it should display the mapname in center if u get close to it.



All times are GMT -4. The time now is 20:43.

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