WastedTimeYT Posted August 4, 2016 Share Posted August 4, 2016 I am trying to script something for an upcoming mod that makes some weapons react like they do in call of duty, but I came into a weird problem. The 12th line and the following should have began as soon as the player gets close enough to the object, in this case an activator, but when i try it out ingame the script works but like if were to begin with onactivate. If I walk up to the activator and click it it runs that script aslong as im close enough to the activator. When I first started making the script it worked out perfectly, but somewhere in the making it for some reason broke. Any help is appreciated, thanks in advance. Scn XXXServiceRiflePrimaryWeaponScript ;Refs ref AmmoGiven ref Activated ref GotAmmo ref HasPrimary ;------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ;Checks for the gun and gives the player ammo for their current gun begin gamemode set AmmoGiven to 1 + GetRandomPercent * 30 / 100 if getdistance Playerref <= 40 if player.getitemcount WeapNVServiceRifle == 1 if GotAmmo == 0 player.additem Ammo556mm AmmoGiven disable set GotAmmo to 1 endif endif endif end ;------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ;Checks for a primary weapon Begin Gamemode if player.getitemcount WeapNVServiceRifle == 1 set HasPrimary to 1 endif if player.getitemcount Weap10mmSubmachineGun == 1 set HasPrimary to 1 endif end ;------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ;Checks if player has no primary begin gamemode if player.getitemcount WeapNVServiceRifle == 0 if player.getitemcount Weap10mmSubmachineGun == 0 set HasPrimary to 0 endif endif end ;------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ;Removes the players current weapon and gives them the new one, or gives the player the gun when they have none begin onactivate if HasPrimary == 0 player.additem WeapNVServiceRifle 1 player.additem Ammo556mm AmmoGiven disable endif if player.getitemcount Weap10mmSubmachineGun == 1 player.removeitem Weap10mmSubmachineGun 1 XXXGunDropMarkerREF.placeatme Weap10mmSubmachineGun 1 15 0 player.additem WeapNvServiceRifle 1 player.additem Ammo556mm AmmoGiven disable endif end ;------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Link to comment Share on other sites More sharing options...
uhmattbravo Posted August 5, 2016 Share Posted August 5, 2016 I could be wrong, but you could/ probably should condense that down to one gamemode block with multiple if statements instead of using so many separate game mode blocks. Link to comment Share on other sites More sharing options...
rickerhk Posted August 5, 2016 Share Posted August 5, 2016 That's right - use only one gamemode block in a script. Link to comment Share on other sites More sharing options...
WastedTimeYT Posted August 5, 2016 Author Share Posted August 5, 2016 Oh I didn't realize that could mess with things, but thanks for the help I'll try it right now. Link to comment Share on other sites More sharing options...
Recommended Posts