Jump to content

Setting Ammo to zero help


eleglas

Recommended Posts

I'm sorry my reply isn't very helpful (though after TGBlank's post you probably don't need any more help), but I really like this idea. Changing the weapon during battle should always be a tactical choice, with drawbacks (can't shoot for a while) as well as benefits (new weapon is better suitable for changed battlefield conditions). It's also more realistic, because I don't think it's generally a good idea to carry loaded weapons in your backpack.

 

Edit:

Oops, now I don't have a good excuse for not thinking a solution myself. I'll be sure to post if I figure a way.

Link to comment
Share on other sites

Then you did it wrong. If it CTDs then you messed up with the references.

 

You need a short to store the amount of ammo of the weapon through getitemcount, then removeitem that amount, with the correct flags so it doesn't spam the player. all that in an onequip block.

 

Then on gamemode, if the variable you used to store the ammo amount is not 0, add ammo to the player. You may need to include a check so it doesnt happen in the same frame as the onequip one.

Link to comment
Share on other sites

Still doesn't work, have a look at my code:

 

SCN DartGunAmmoScript

Short Ammo

Begin OnEquip

Player.Removeitem AmmoDart 100000

END

Begin Gamemode

Set Ammo to GetItemCount AmmoDart

If Ammo == 0
Player.Additem AmmoDart 100000

EndIf
END

Begin OnUnequip

Removeme

END

Link to comment
Share on other sites

Your crashing error may be for 3 reasons, first:

Set Ammo to GetItemCount AmmoDart

You cannot call getitemcount on an item reference.

 

 

Second is wrong reference (ie, the ammo not being called ammodart).

 

 

Third is the game may not be liking you removing and adding an item on the same frame.

------------

 

Change This:

Set Ammo to GetItemCount AmmoDart

For This:

Set Ammo to Player.GetItemCount AmmoDart

And move it right below OnEquip.

 

----

Change This:

If Ammo == 0
Player.Additem AmmoDart 100000

EndIf

 

for this:

If (Player.GetItemCount AmmoDart == 0)
 Player.Additem AmmoDart Ammo
EndIf

-----

 

Also try to keep your code idented, helps people understanding it, and helps yourself understanding it.

-----

 

Once you have the code working, change the additem and removeitem commands from the form "additem <item> <ammount>" to "additem <item> <ammount> 1". This will stop them from spamming the player with xxx item added messages.

 

 

Apart from that, why are you calling removeme on onunequip? are you aware of what effect does that have?.

Link to comment
Share on other sites

The script works... sort of. It doesn't CTD anymore, however it doesn't do the desired effect.

 

Any other Ideas?

 

Ohh and the removeme is because this weapons has 2 modes, stun and frenzy, changes weapons for each, but I want the illusion that only the ammo is changing.

Link to comment
Share on other sites

Removeme is removing the item when you unequip it manually, not through most scripts, and definitely not replacing it with any other. For ammo choosing it is better to do things through the onequip block and a quest.

 

Can you describe what is it doing?, it may be needed to insert a short delay before adding the ammo. Sort of:

 

Begin GameMode
 If (Ammo)
if (Count == 4)
  Player.Additem AmmoDart Ammo 1
  Set Ammo to 0
  Set Count to 0
Else
  Set Count to Count + 1
EndIf
 EndIf
End

That script instead of the gamemode block you had should wait 4 frames before adding the ammo back.

You'd need to declare a new short called Count btw.

Link to comment
Share on other sites

Nope, no help there either.

 

What the gun does is, well you choose your mode, it equips that weapon, that then when you unequip it, it removes the gun from your inventory, so you have to choose the mode again, it does that through an Ingestible.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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