ItsMods

Full Version: Y U NO WORK
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
C++ Code
  1. scrambleClass()
  2. {
  3. WeaponPrimary = [];
  4. WeaponPrimary[WeaponPrimary.size] = "m4";
  5. PickWeapon = WeaponPrimary[randomInt(WeaponPrimary.size)];
  6. WeaponToGive = "";
  7. if(PickWeapon == "m4_mp")
  8. {
  9. M4Attach = [];
  10. M4Attach[M4Attach.size] = "";
  11. M4Attach[M4Attach.size] = "_acog";
  12. M4Attach[M4Attach.size] = "_reflex";
  13. M4Attach[M4Attach.size] = "_thermal";
  14. M4Attach[M4Attach.size] = "_eotech";
  15. WeaponToGive = "m4" + M4Attach[randomInt(M4Attach.size)] + "_mp";
  16. }
  17.  
  18. self takeAllWeapons();
  19. self clearPerks();
  20. wait 0.05;
  21. self giveWeapon(WeaponToGive, 0, false);
  22. wait 0.05;
  23. self switchToWeapon(WeaponToGive, 0, false);
  24. }
which error?

try to print result, maybe you will see error...
Hurrhurr

(06-19-2012, 00:25)broshaan Wrote: [ -> ]WeaponPrimary[WeaponPrimary.size] = "m4";
PickWeapon = WeaponPrimary[randomInt(WeaponPrimary.size)];
if(PickWeapon == "m4_mp")

Also you can just do:
Code:
PickWeapon = random(WeaponPrimary);

random(M4Attach)

Afaik.
(06-19-2012, 00:48)Nukem Wrote: [ -> ]Hurrhurr

(06-19-2012, 00:25)broshaan Wrote: [ -> ]WeaponPrimary[WeaponPrimary.size] = "m4";
PickWeapon = WeaponPrimary[randomInt(WeaponPrimary.size)];
if(PickWeapon == "m4_mp")

Also you can just do:
Code:
PickWeapon = random(WeaponPrimary);

random(M4Attach)

Afaik.

I fixed the problem I had, pick weapon should have said m4 not m4_mp.
But thanks for your random(), it looks way less messy
(06-19-2012, 01:33)broshaan Wrote: [ -> ]
(06-19-2012, 00:48)Nukem Wrote: [ -> ]Hurrhurr

(06-19-2012, 00:25)broshaan Wrote: [ -> ]WeaponPrimary[WeaponPrimary.size] = "m4";
PickWeapon = WeaponPrimary[randomInt(WeaponPrimary.size)];
if(PickWeapon == "m4_mp")

Also you can just do:
Code:
PickWeapon = random(WeaponPrimary);

random(M4Attach)

Afaik.

I fixed the problem I had, pick weapon should have said m4 not m4_mp.
But thanks for your random(), it looks way less messy

C++ Code
  1. WeaponToGive = "m4" + random(M4Attack) + random(M4Barrel) + "_mp";
  2. if("thermal" in WeaponToGive)
  3. {
  4. if("shotgun" in WeaponToGive){WeaponToGive = "m4_shotgun_thermal_mp";}
  5. if("gl" in WeaponToGive){WeaponToGive = "m4_gl_thermal_mp";}
  6. if("silencer" in WeaponToGive){WeaponToGive = "m4_silencer_thermal_mp";}
  7. if("heartbeat" in WeaponToGive){WeaponToGive = "m4_heartbeat_thermal_mp";}
  8. if("fmj" in WeaponToGive){WeaponToGive = "m4_fmj_thermal_mp";}
  9. if("xmags" in WeaponToGive){WeaponToGive = "m4_xmags_thermal_mp";}
}

HALP ME!

I dunno how to look for substrings
use [code] tags and please be more specific next time when you create a thread title
(06-19-2012, 02:43)broshaan Wrote: [ -> ]
(06-19-2012, 01:33)broshaan Wrote: [ -> ]
(06-19-2012, 00:48)Nukem Wrote: [ -> ]Hurrhurr

(06-19-2012, 00:25)broshaan Wrote: [ -> ]WeaponPrimary[WeaponPrimary.size] = "m4";
PickWeapon = WeaponPrimary[randomInt(WeaponPrimary.size)];
if(PickWeapon == "m4_mp")

Also you can just do:
Code:
PickWeapon = random(WeaponPrimary);

random(M4Attach)

Afaik.

I fixed the problem I had, pick weapon should have said m4 not m4_mp.
But thanks for your random(), it looks way less messy

C++ Code
  1. WeaponToGive = "m4" + random(M4Attack) + random(M4Barrel) + "_mp";
  2. if("thermal" in WeaponToGive)
  3. {
  4. if("shotgun" in WeaponToGive){WeaponToGive = "m4_shotgun_thermal_mp";}
  5. if("gl" in WeaponToGive){WeaponToGive = "m4_gl_thermal_mp";}
  6. if("silencer" in WeaponToGive){WeaponToGive = "m4_silencer_thermal_mp";}
  7. if("heartbeat" in WeaponToGive){WeaponToGive = "m4_heartbeat_thermal_mp";}
  8. if("fmj" in WeaponToGive){WeaponToGive = "m4_fmj_thermal_mp";}
  9. if("xmags" in WeaponToGive){WeaponToGive = "m4_xmags_thermal_mp";}
}

HALP ME!

I dunno how to look for substrings

I already posted in the shoutbox but if you didn't see it, it's:
Code:
if(isSubStr(WeaponToGive, "thermal")) { /* Blah */ }