Jump to content

Script workaround\counter alternative help?


Xilandro

Recommended Posts

I'm trying to figure out how to track ammo added into player's inventory to replace it.

Something like this quest script + Gamemode

set AmmoCount to player.GetItemCount 556cal
if AmmoCount > 0
    player.AddItem 223cal AmmoCount
    player.RemoveItem 556cal AmmoCount

But there will me more counters, for 9mm ammo, .308, .44, and so on. And i'm not sure, but will it make the game unstable? Or counters will not affect the game if there's nothing to count? Is there another way to track added ammo in inventory without running counters everytime? Something like "Is ID in container" function?

 

There's also one more way. By tracking players current ammo

set currentAmmo to GetPlayerCurrentAmmo
    if currentAmmo == 556cal
        set AmmoCount to player.GetItemCount 556cal
        player.AddItem 223cal AmmoCount
        player.RemoveItem 556cal AmmoCount
    endif

But of course it will work only when player is using that ammo already.

 

Any ideas?

Link to comment
Share on other sites

I think what you're doing is the only way. It doesn't even look like you can run OnAdd blocks with them, since the only thing related to scripts I see on the ammo form is the impact script.

 

I don't think it will make the game unstable though. It's a simple "do something if this is greater than zero" situation, which it won't be for 99% of the time.

Link to comment
Share on other sites

Make an armor form, don't add any biped slots to it, and mark it unplayable. We call these "tokens."

 

Add an object script to your token and use the GetContainer function to obtain a reference to the actor who has it.

 

scn AmmoTokenOS

ref actorref
short ammocount

begin gamemode

	if(actorref)
		set ammocount to actorref.getitemcount 556cal
		if(ammocount)
			actorref.additem 223cal ammocount 1
			actorref.removeitem 556cal ammocount 1
		endif
		set ammocount to actorref.getitemcount otherammo
		if(ammocont)
			actorref.additem replacementammo ammocount 1
			acotrref.removeitem otherammo ammocount 1
		endif
	else
		set actorref to getcontainer
	endif
	
end ; gamemode
Then you just have to add your token to the inventory of the player or any other NPC you want the ammo replacement to run on.

 

 

 

I would actually complicate this even further using form lists so you can add ammo to the replacement process without editing the script, but this should get the job done.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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