Moved to the appropriate section. Post non-releases here next time
im working on a custom promod for my server, where i would like only specific attributes of weapons to be removed... ie: NO GL OR AKIMBO
so ive been playing around with my code but cant seem to figure out how to tell the game to remove only the "_akimbo" part of the dvar weapon name and leave the rest.
can anyone help? Thanks in advanced
example:
take glock_akimbo_silencer_mp
program detects "_akimbo" with isSub( and replaces it with the same weapon without "_akimbo" aka:
glock_silencer_mp
Moved to the appropriate section. Post non-releases here next time
i think you have to make an if statement with every weapon
Code:CurrentWeapon= self GetCurrentWeapon(); if (isSubStr(CurrentWeapon,"_akimbo") && isSubStr(CurrentWeapon,"glock") && isSubStr(CurrentWeapon,"silencer")) // if the guy have glock akimbo silencer { self takeweapon(glock_akimbo_silencer_mp);//take the weapon self giveweapon(glock_silencer_mp); // give the weapon without akimbo } if (isSubStr(CurrentWeapon,"_akimbo") && isSubStr(CurrentWeapon,"glock") && isSubStr(CurrentWeapon,"fmj")) // if the guy have glock akimbo fmj { self takeweapon(glock_akimbo_fmj_mp);//take the weapon self giveweapon(glock_fmj_mp); // give the weapon without akimbo } //...
I took this from my old Anti-Noob mod:
Hope you understand itCode:AntiWeapons() { self endon("death"); self endon("disconnect"); weaponList = self GetWeaponsListPrimaries(); for(i = 0; i < weaponList.size; i++) { if(isSubStr(weaponList[i], "glock") || isSubStr(weaponList[i], "akimbo") || isSubStr(weaponList[i], "ump45") || isSubStr(weaponList[i], "gl") || isSubStr(weaponList[i], "masada") || isSubStr(weaponList[i], "at4") || isSubStr(weaponList[i], "m79") || isSubStr(weaponList[i], "rpg") || isSubStr(weaponList[i], "thermal")) { self takeWeapon(weaponList[i]); self giveweapon("m4_mp"); wait 0.01; self switchtoweapon("m4_mp"); self iPrintLnBold("^1Your Weapon Was in the Noob List."); wait 3; self iPrintLnBold("^2Choose Another Class Next Time."); } } }
Larity2056 (07-12-2012)
Thanks jorndel. the only question i have is what EXACTLY isand what is GetWeaponListPrimaries exactly? a list of every single weapon in the gsc code?Code:if(isSubStr(weaponList[i], "glock") || isSubStr(weaponList[i], "akimbo") || isSubStr(weaponList[i], "ump45") || isSubStr(weaponList[i], "gl") || isSubStr(weaponList[i], "masada") || isSubStr(weaponList[i], "at4") || isSubStr(weaponList[i], "m79") || isSubStr(weaponList[i], "rpg") || isSubStr(weaponList[i], "thermal"))
basically i was just looking to remove GL's and akimbos...
i was thinking more of a switch case method that checked to see if the substring of what i DONT want is in the name of what the player has. then somehow (this is what i need help with) take the weapon name. remove the unwanted portion.. and use the same EXACT weapon. using switch and case for the weapons/attachments that i dont want.
im fairly new at programming with gsc and most all of it (besides the basic logic programming format) is somewhat confuzing to me... and there really isnt a "this is how to do this specific thing with gsc" tutorial out there for alot of the different things i would maybe like to do... that being said asking for help with gsc makes me feel like im asking to be spoon-fed script
it makes it hard when there are peices of code and functions that are GSC specific and specific to the game... its like trying to play the game without the graphics - or like looking at mw2 without the geometry.
__________________________________________________ _________________
is there a way to parse the accepted weapons from a text list? im sure theres a way but im not sure how its done
Last edited by Nachos; 07-12-2012 at 04:52 AM. Reason: Merged posts
I don't remember GSC so well, so I can't really say much about it
But what I think I would have tried.
Since I code C#.
I would try to find a way to remove that akimbo ''string'' from the weapon name.
And remove the extra _
I have no Idea how this would be done in GSC. Or if it's even do able...
____
Looked a little around.
If you could maybe manage to make an check system for the wep and attachment.
If the wep is: usp_fmj_akimbo
Then check:
Wep = usp
Attach = fmj
Attach2 = Akimbo (Ignore adding this to the weapon)
Give the player:
self giveweapon(Wep + "_"+Attach+"_"+Attach2+"mp");
Something like that
If you wonder how arrays are:
Xarray = [];
Xarray[0] = 1;
Xarray[1] = 2;
And then you loop over the values in the array list of the weps and attachments
Like: (I might have done it wrong, but something like it I think...)
check(val){
Xarray = [];
Xarray[0] = 1;
Xarray[1] = 2;
while(false)
{
if(val == Xarray[i])
return true;
}
}
Larity2056 (07-12-2012)
i know what youre saying.. im just not sure how to go about doing it... would i still have to check for each part within the weapon name? or is there a way to weed out only the attachment sub-strings?
i dont want to have to list EVERY SINGLE weapon/attachment combination and check to see if its a weapon && || attachment that i dont want... i may have to, but if theres an easier way (and im almost positive there is...) then i would much rather use that...
parsing to a txt file and checking for malicious sub-strings and removing only the portions within - like you said above.. but im not sure how to go about (in code) doing this
for now i think im going to just start checking through every weapon/attachment combo... unless someone can help me with an easier method... thanks jorndel - youve helped more than you know!
but it gives me no weapon... i have a secondary, but the primary gets removed...what am i doin wrong?Code:if (isSubStr(CurrentWeapon,"m4") || isSubStr(CurrentWeapon,"famas") || isSubStr(CurrentWeapon,"fal") || isSubStr(CurrentWeapon,"m16") || isSubStr(CurrentWeapon,"fn2000")) { self takeweapon(CurrentWeapon); wait 0.1; self giveweapon("scar_mp"); }
Last edited by Jorndel; 07-12-2012 at 09:03 PM.
ok so so far i have it check and replace unwanted weapons. but im not sure how to check for attachments without knowing what type of gun the player has... ie: Assault Rifle, SMG, LMG, or Sniper... or do i go through each one of:
and censor each one?... and replace them?
Last edited by Twizzy; 07-12-2012 at 10:28 PM.