Starting ammo/availability of spawned weapons

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
tom9077
Private
Posts: 6
Joined: Mon Jan 31, 2005 8:07 am

Starting ammo/availability of spawned weapons

Post by tom9077 »

I have scripted weapons so that they spawn on multiplayer DM maps. They work properly and everything but I can't seem to limit how many rounds of bullets are in the gun when you pick it up. For example when I pick up a this Colt .45 I spawned it comes with full 100 rounds. How do I make the Colt .45 comes with 0 rounds so that you have to go and pick up ammo clips somewhere else? I'm using this code here:

Code: Select all

local.colt45 = spawn models/weapons/colt45.tik origin ( 895.63 501.87 437.17 )
And how do I limit how often you can pick up spawned items? Say I have a pistol clip lying on the floor. When I go over it I can continuesly pick it up until I have full ammo. Is there a way I can put a time limit on it or something so I can only pick it up every 30 seconds or so?

Thanks for any help.
Rookie One.pl
Site Admin
Posts: 2752
Joined: Fri Jan 31, 2003 7:49 pm
Location: Nowa Wies Tworoska, Poland
Contact:

Post by Rookie One.pl »

Spawn interval thingy (off the top of my head):

Code: Select all

thread spawnColt:
   local.spawnDelay = 10 // this sets the colt to spawn in 10 seconds interval
   while (1)
   {
      local.colt45 = spawn spawn models/weapons/colt45.tik origin ( 895.63 501.87 437.17 )
      local.colt45 set_respawn 0
      wait local.spawnDelay
      local.colt45 set_respawn 1
   }
Should work.
Admin
Image
Image
Honour guide me.

here's my stuff - inequation.org | here's where I work - thefarm51.com
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post by lizardkid »

clarification:

you need to stop the colt from spawning multiple times, spawning just one will probably get you a colt and an extra clip. picking it up when you have a colt will give you 16 extra rounds.

if it doesn't work then you can fake it;

make a "dummy" colt, place a trigger_use around it wit hthe following key/values.

setthread/giveColt
wait/10

and put this in your script (as a separate thread)

Code: Select all

giveColt:

local.targetPlayer = parm.other

local.targetPlayer give colt45
local.targetPlayer ammo pistol  0

end
this just gives a colt with no ammo to the player that picked it up.
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
Rookie One.pl
Site Admin
Posts: 2752
Joined: Fri Jan 31, 2003 7:49 pm
Location: Nowa Wies Tworoska, Poland
Contact:

Post by Rookie One.pl »

You can remove this line:

Code: Select all

local.targetPlayer ammo pistol  0 
as it does absolutely nothing. ;)
Admin
Image
Image
Honour guide me.

here's my stuff - inequation.org | here's where I work - thefarm51.com
Master-Of-Fungus-Foo-D
Muffin Man
Posts: 1544
Joined: Tue Jan 27, 2004 12:33 am
Location: cali, United States

Post by Master-Of-Fungus-Foo-D »

no! make it this if you want the player to have full ammo on the pistol

Code: Select all

giveColt: 

local.targetPlayer = parm.other 

local.targetPlayer give colt45 
local.targetPlayer ammo pistol 999

end
Image
The Fungus Theme song!!!

Code: Select all

while (local.player istouching self)
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post by lizardkid »

actually,

Code: Select all

local.targetPlayer ammo pistol  0
takes all pistol rounds away from the player, faking him not getting or having any when he picks up teh pistol.
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
Rookie One.pl
Site Admin
Posts: 2752
Joined: Fri Jan 31, 2003 7:49 pm
Location: Nowa Wies Tworoska, Poland
Contact:

Post by Rookie One.pl »

lizardkid wrote:actually,

Code: Select all

local.targetPlayer ammo pistol  0
takes all pistol rounds away from the player, faking him not getting or having any when he picks up teh pistol.
It doesn't. :) This command does not set the player's ammo, its purpose is to give the player the amount of ammo given. To take ammo away you should use (I think):

Code: Select all

local.targetPlayer take ammo pistol 999 // takes 999 ammo from player
Admin
Image
Image
Honour guide me.

here's my stuff - inequation.org | here's where I work - thefarm51.com
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post by lizardkid »

doh! *slaps head* i forgot that... i've been using too many variables lately :P :roll:
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
tom9077
Private
Posts: 6
Joined: Mon Jan 31, 2005 8:07 am

Post by tom9077 »

Rookie One this is the code you gave me:

Code: Select all

thread spawnColt: 
   local.spawnDelay = 10 // this sets the colt to spawn in 10 seconds interval 
   while (1) 
   { 
      local.colt45 = spawn spawn models/weapons/colt45.tik origin ( 895.63 501.87 437.17 ) 
      local.colt45 set_respawn 0 
      wait local.spawnDelay 
      local.colt45 set_respawn 1 
   }
You put spawn in twice. I put this code in exactly (with only one spawn) and it didn't work. The gun didn't show up at all. I checked my spelling mistakes and nadda.

lizardkid how do I place a trigger_use around it with the keys/values you gave me? I think I'll look at some scripting tutorials to figure that out.
tom9077
Private
Posts: 6
Joined: Mon Jan 31, 2005 8:07 am

Post by tom9077 »

Rookie One I took out the colon at the end of spawnColt and it worked, well sorta. The model of the gun respawns every 10 seconds, but I can still pick up ammo when it's not there. I'll keep trying though.
tom9077
Private
Posts: 6
Joined: Mon Jan 31, 2005 8:07 am

Post by tom9077 »

Ok I'm lost. I've tried for hours and can't figure it out. Can I have some more help?
tom9077
Private
Posts: 6
Joined: Mon Jan 31, 2005 8:07 am

Post by tom9077 »

This game is fucked up. I put this code in right:

Code: Select all

thread spawnColt 
local.spawnDelay = 30
while (1) 
{ 
local.colt45 = spawn models/weapons/colt45.tik origin ( 895.63 501.87 437.17 ) 
local.colt45 set_respawn 0 
wait local.spawnDelay 
local.colt45 set_respawn 1 
}
I launched the game and it did what I said before - the colt respawns every so seconds but I can keep picking up ammo when it's not there. I tried this several times and I got the same results. Then, for some unknown reason, I started the game a few minutes ago, and it worked. Wtf? I didn't alter the code or anything. I guess it was just fucking with me.

Anyways thanks for all the help fellas.
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post by lizardkid »

well it looks like you need a bit of thread syntax help..

when you make a thread it needs to be lie this

Code: Select all

threadName:
//code
end
when you call a thread it needs to be in another thread and called liek this.

Code: Select all

thread myThread
but if it works like you want it so be it.
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
Master-Of-Fungus-Foo-D
Muffin Man
Posts: 1544
Joined: Tue Jan 27, 2004 12:33 am
Location: cali, United States

Post by Master-Of-Fungus-Foo-D »

why not, when the player picks up the colt (or in other words when your trigger is triggered), remove the trigger and colt? Or have a trigger_use(or multiple) around the colt so when a player goes to pick up the ammo n' such, he does, then the colt goes away FOR GOOD! so the layer cant keep getting ammo from the gone colt....(you can do this by:
Putting a trigger multiple around the gun on the floor, five it a sethhread of removecolt, and then write in your script,

Code: Select all

 wait 5 //gives the player time to pick it up
$colt45 remove
end
Image
The Fungus Theme song!!!

Code: Select all

while (local.player istouching self)
Post Reply