Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

FPSC Classic Scripts / Internal variable (ply's mod)

Author
Message
Fps n00b
15
Years of Service
User Offline
Joined: 24th Apr 2009
Location:
Posted: 21st Aug 2009 18:28
I wrote this piece of code trying to make "energy" for your gun.
I am new to the internal variable recognition and am hoping that anyone can tell me how to stop the gun from firing if the variable is 0. ( I have it so that the gun recharges ) With my code the variable stops at 0 but the gun continiues to fire!

:always,plrusinggun=0,timergreater=0500,varless=energy 49:addvar=energy 1,timerstart
:always,plrfiredweap,vargreater=energy 1:subvar=energy 1
:always:setvar=$CA energy
zeza
16
Years of Service
User Offline
Joined: 27th Jun 2008
Location:
Posted: 21st Aug 2009 20:04
try hiding the weapon when energy equals 0, like this
:varequal=energy 0:hideplrgun
:vargreater=energy 1:showplrgun

Hope This Helps
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 22nd Aug 2009 02:20
There's an easier way.

Bind the ammo of your weapon to the variable you're wanting to use. You do this by adding the "bindammotovar" option to the gunspec of your weapon. So, if you're wanting to have the "energy" variable handle the ammunition of your weapon it would look like:


This will make it so the variable reflects the ammo the player has in that weapon, so if the player uses the weapon then the variable goes down. However, you will also be able to change the variable yourself to directly control how much ammo the player has.

Now, since the variable is automatically updated with the weapon's ammo amount, you won't need to worry about tracking it yourself. So you can pretty much eliminate all of your script except the first line (which is the line that recharges the weapon). The bonus of this is that when the variable reaches 0, the player's weapon really is out of ammo and so won't be able to fire anymore, but as soon as you add to that variable the player will have ammo again!



(For future reference, you CAN bind multiple weapons' ammos to the same variable and they will ALL share the same ammunition )


On another note, Ply's Mod has entity timers, so it'd be best to use those instead of the global timer. Just replace "timergreater" with "etimergreater" and replace "timerstart" with "etimerstart". This prevents other scripts that use timers from interfering with this script's timer.


[*tears of joy* I still have great, unique features! ]


The one and only,


zeza
16
Years of Service
User Offline
Joined: 27th Jun 2008
Location:
Posted: 22nd Aug 2009 02:41
Can't believe I forgot about that.

Hope This Helps
Fps n00b
15
Years of Service
User Offline
Joined: 24th Apr 2009
Location:
Posted: 23rd Aug 2009 22:01
Thanks! (omg I love ply's mod now!)
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 23rd Aug 2009 22:36
Quote: " (omg I love ply's mod now!) "


Another satisfied customer


The one and only,


Login to post a reply

Server time is: 2024-11-25 06:56:45
Your offset time is: 2024-11-25 06:56:45