Jump to content

Begin gamemode working like begin onactivate


WastedTimeYT

Recommended Posts

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...