Page 1 of 1
Starting ammo/availability of spawned weapons
Posted: Mon Jan 31, 2005 8:18 am
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.
Posted: Mon Jan 31, 2005 12:59 pm
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.
Posted: Mon Jan 31, 2005 7:56 pm
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.
Posted: Mon Jan 31, 2005 8:06 pm
by Rookie One.pl
You can remove this line:
as it does absolutely nothing.

Posted: Mon Jan 31, 2005 11:35 pm
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
Posted: Tue Feb 01, 2005 12:23 am
by lizardkid
actually,
takes all pistol rounds away from the player, faking him not getting or having any when he picks up teh pistol.
Posted: Tue Feb 01, 2005 2:11 pm
by Rookie One.pl
lizardkid wrote:actually,
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
Posted: Tue Feb 01, 2005 6:50 pm
by lizardkid
doh! *slaps head* i forgot that... i've been using too many variables lately

Posted: Tue Feb 01, 2005 9:51 pm
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.
Posted: Tue Feb 01, 2005 10:21 pm
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.
Posted: Wed Feb 02, 2005 1:24 am
by tom9077
Ok I'm lost. I've tried for hours and can't figure it out. Can I have some more help?
Posted: Wed Feb 02, 2005 1:50 am
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.
Posted: Wed Feb 02, 2005 2:50 am
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
when you call a thread it needs to be in another thread and called liek this.
but if it works like you want it so be it.
Posted: Wed Feb 02, 2005 11:25 pm
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