I dont understand that script, too complicated for me. I dont see where it responds to a scriptresponse and where you actually give/set the weapon
I dont understand that script, too complicated for me. I dont see where it responds to a scriptresponse and where you actually give/set the weapon
Using IznoGod's idea of the weapon array in maps\mp\gametypes\_weapons::init(), you can do this:
Which would allow you to check the response_number against the menu response:Code:level.weapons["m1carbine_mp"] = spawnstruct(); level.weapons["m1carbine_mp"].server_allowcvar = "scr_allow_m1carbine"; level.weapons["m1carbine_mp"].client_allowcvar = "ui_allow_m1carbine"; level.weapons["m1carbine_mp"].allow_default = 1; level.weapons["m1carbine_mp"].response_number = 1; level.weapons["m1garand_mp"] = spawnstruct(); level.weapons["m1garand_mp"].server_allowcvar = "scr_allow_m1garand"; level.weapons["m1garand_mp"].client_allowcvar = "ui_allow_m1garand"; level.weapons["m1garand_mp"].allow_default = 1; level.weapons["m1garand_mp"].response_number = 2; --------- ETC -------------------
Code:for(i = 0; i < level.weaponnames.size; i++) { weaponname = level.weaponnames[i]; if( level.weapons[weaponname].response_number == response ) self giveWeapon( weaponname ); }
Tally what do you mean with "Build a player array out of it"?
I mean create an array. Basic Scripting 101 - only "self" and "level" definitions can be used throughout a script - you can pass the definition across to other functions. Otherwise, the definition would only work in a particular function. Using the word "weapon" wont carry its struct across to other functions. Hence why you were getting the "undefined" error - you created the weapon + number array in a function where and once your script left that function, the definition was dead (i.e. no longer valid).
Why all this hassle?
Code:level.weapon = []; level.weapon[0] = "greasegun_mp"; level.weapon[1] = "mp40_mp"; level.weapon[2] = "pps42_mp"; level.weapon[3] = "ppsh_mp"; level.weapon[4] = "sten_mp"; level.weapon[5] = "thompson_mp"; level.weapon[6] = "mac10_mp"; level.weapon[7] = "ak74_mp"; level.weapon[8] = "mp5_mp"; level.weapon[9] = "ump45_mp"; level.weapon[10] = "p90_mp"; level.weapon[11] = "bar_mp"; level.weapon[12] = "bren_mp"; level.weapon[13] = ""; level.weapon[14] = "fg42_mp"; level.weapon[15] = "rpd_mp"; level.weapon[16] = "acr_mp"; level.weapon[17] = "g43_mp"; level.weapon[18] = "m1garand_mp"; level.weapon[19] = "m1carbine_mp"; level.weapon[20] = "mp44_mp"; level.weapon[21] = "svt40_mp"; level.weapon[22] = "r700_mp"; level.weapon[23] = "barret_mp"; level.weapon[24] = "kar98k_mp"; level.weapon[25] = "enfield_mp"; level.weapon[26] = "mosing_nagant_mp"; level.weapon[27] = "springfield_mp"; level.weapon[28] = ""; level.weapon[29] = "m4"; level.weapon[30] = "aug_mp"; level.weapon[31] = "sig_mp"; level.weapon[32] = "ak47_mp"; level.weapon[33] = "famas_mp"; level.weapon[34] = "shotgun_mp"; level.weapon[35] = "winchester_mp"; level.weapon[36] = "db_mp"; level.weapon[37] = "benneli_mp"; level.weapon[38] = "kar98k_sniper_mp"; level.weapon[39] = "enfield_scope_mp"; level.weapon[40] = "mosin_nagant_sniper_mp";You can also alter the "i" value if the response doesn't match the weapon due to an array starting with index of 0.Code:for(i = 0; i < level.weapon.size; i++) { if(int(response) == i) self giveweapon(level.weapon[i]); }
Last edited by YuriJurek; 15th December 2014 at 18:11.
Ni3ls (15th December 2014)
Ni3ls (15th December 2014)
Last edited by YuriJurek; 15th December 2014 at 18:16.