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 / 2 Weapons at a time only script. Long Post.

Author
Message
Combollian
13
Years of Service
User Offline
Joined: 20th Jul 2011
Location:
Posted: 5th Aug 2011 19:51
G'day,
I'm trying to learn the FPSC scripting language and stumbled across a thread talking about using a script to limit the player to only two weapons at any one time.
I've tried modding the weapon.fpi and then just started from scratch. I've got this so far.

;Artificial Intelligence Script

;Header

desc = Only allowed two weapons at a time

;Triggers
:state=0:setvar=WeaponCount 0
:state=0,varequal=WeaponCount 2,plrdistwithin=40:state=1,hudreset,hudx=50,hudy=85,hudsize=18,hudtext=Press 'Enter' to Swap Weapons,hudname=weapon_swap_press,hudhide=1,hudmake=display
:state=0,varless=WeaponCount 2,plrdistwithin=40:state=2,hudreset,hudx=50,hudy=85,hudsize=18,hudtext=Press 'Enter' to Take Weapon,hudname=weapon_take_press,hudhide=1,hudmake=display
:state=1,plrdistwithin=40:hudshow=weapon_swap_press,hudfadeout=weapon_swap_press
:state=1,varequal=WeaponCount 2,plrdistwithin=40,scancodekeypressed=28:state=0,playerdrop,plrsound=audiobank\items\pickup.wav,decvar=WeaponCount 1
:state=2,plrdistwithin=40:hudshow=weapon_take_press,hudfadeout=weapon_take_press
:state=2,varless=WeaponCount 2,plrdistwithin=40,scancodekeypressed=28:state=0,playertake,coloff,rundecal=-1,plrsound=audiobank\items\pickupweapon.wav,incvar=WeaponCount 1


;End of Script

I've added the dimvar=WeaponCount to the setup level file and setvarvalue=0

The script I made however seems to be ignoring the variable I created and just allowing the player to pick up a third weapon after his second instead of swapping it.
I'm aware of the mods out there however I'm using this as an opportunity to teach myself FPSC scripting language.
Just after some advice on fixing this problem.

Cheers
Combollian
13
Years of Service
User Offline
Joined: 20th Jul 2011
Location:
Posted: 6th Aug 2011 08:05 Edited at: 11th Aug 2011 05:31
Well, I've managed to get it to work, however the next two things I want to fix are when picking up a new weapon display that weapon and when dropping a weapon being able to come back to it and pick it up again.

here's the working script.

2Beastmode4u
13
Years of Service
User Offline
Joined: 14th Feb 2011
Location: Loading...
Posted: 7th Aug 2011 00:39 Edited at: 7th Aug 2011 00:40
Good work for someone learning the language. I hope to see more from you.


Cheers.
P.S.
Highlight all of the code in your post and press the code button.

God help me, Please.
Coalition Forces
13
Years of Service
User Offline
Joined: 7th May 2011
Location: In the Battlefield...
Posted: 8th Aug 2011 11:18
Man, you could be my life saver! Finally a two weapon script! thankyou for the script, although I still need to test it out.
Cheers mate!

coalitionforces, the team man.
yomomma
13
Years of Service
User Offline
Joined: 2nd May 2011
Location:
Posted: 15th Aug 2011 02:20
How do i add this code to my fpsc?

Turtle Productions
15
Years of Service
User Offline
Joined: 22nd Jan 2009
Location: Finland
Posted: 15th Aug 2011 09:20 Edited at: 15th Aug 2011 10:00
Thanks, Combollian!

For yomomma, first, copy the script,
open C:\Program Files\The Game Creators\FPS Creator\Files\scriptbank,
add there a new textfile,
paste the script there,
choose save as,
and write something for the name AND replace the .txt with .fpi and save.
Then in FPSC, open weapon entity's properties and change the main script to this one. You'll need to apply this script to every weapon entity you have in the map.

[EDIT] Also add "dimvar=WeaponCount" and "setvar=WeaponCount=0" in the setup level file, otherwise it won't work (said in the script).

I hope it helps

Thanks,
TP
yomomma
13
Years of Service
User Offline
Joined: 2nd May 2011
Location:
Posted: 15th Aug 2011 22:08
No it helps alot thaanks

SkullFire58
13
Years of Service
User Offline
Joined: 26th Jul 2011
Location: In my own little world...
Posted: 16th Aug 2011 03:24
Where can I find the setup level file you guys keep talking about?
Turtle Productions
15
Years of Service
User Offline
Joined: 22nd Jan 2009
Location: Finland
Posted: 16th Aug 2011 19:20
SkullFire58, depending on your project (what files you are using for fpi setup files), default is FPS Creator\Files\languagebank\english\gamebank\ and there mygame.

Do this:
Open FPSC
Go to File
Go to Build Game
Go to Level Settings
There you can see the Global Script, what is that setuplevel.fpi
But go back to Game Project Settings
Click New (game project filename) and write your game's name
Now go to Level Settings and you can see that the mygame folder has changed to that what is your game's name.
Press OK and now it works when the game is built.

Hope this helps.

Thanks,
TP
SkullFire58
13
Years of Service
User Offline
Joined: 26th Jul 2011
Location: In my own little world...
Posted: 16th Aug 2011 19:44
Thanks, I found the file. I just need to know where do I type "dimvar=WeaponCount" and "setvar=WeaponCount=0"?
Combollian
13
Years of Service
User Offline
Joined: 20th Jul 2011
Location:
Posted: 22nd Aug 2011 15:38
Quote: "Thanks, I found the file. I just need to know where do I type "dimvar=WeaponCount" and "setvar=WeaponCount=0"?"

anywhere in the setup level script however I put mine just before the script moves onto the :state=0:state=1 line.
Combollian
13
Years of Service
User Offline
Joined: 20th Jul 2011
Location:
Posted: 28th Aug 2011 19:09
G'day again, I'm looking for some guidance on how to get my new weapon that has been picked up to display, as oppose to the first weapon being displayed and the rest moving into the inventory. I've added the showplrweapon command when a player swaps with a weapon on the ground, however it won't display the newly picked up weapon.
Combollian
13
Years of Service
User Offline
Joined: 20th Jul 2011
Location:
Posted: 30th Aug 2011 11:31
I've been racking my brain and searching the forums for clues and guidance on how to improve my script. The problem with it is that after you have picked up two weapons, when you swap out for another one the current weapon is removed the new one is added but it is immediately thrown into the weapon inventory, therefore not displaying the weapon you just swapped for.

I've tried showplrweapon, however my understanding now is that it only works after you hideplrweapon, and it only works on the current weapon you were holding. Therefore dropping it would stop the showplrweapon function from working.

I'm looking for guidance on how to show the new weapon that your player picks up, not only when you swap one out but also when you are first obtaining those weapons.

The next problem of creating an entity of the weapon your player just dropped won't even be started on till I've worked the first one out.

Thanks for the assistance in advance.
SkullFire58
13
Years of Service
User Offline
Joined: 26th Jul 2011
Location: In my own little world...
Posted: 2nd Sep 2011 19:44 Edited at: 7th Oct 2011 18:06
@Combollian

Thanks for the help! This script will be very usefull when it's complete. Maybe you can set it so that you only need to press one specific button to swap between your current weapon slots like the Y button on the Xbox 360 instead of the default 1 and 2. Then, you might be able to set it so that if you press it once, it'll think you pressed it twice. The first time to pick up the weapon, and the second to switch to the other weapon slot. I don't know. Good luck!

Login to post a reply

Server time is: 2024-11-24 06:07:07
Your offset time is: 2024-11-24 06:07:07