Page 1 of 2

New Scripting Project

Posted: Tue Nov 21, 2006 9:51 pm
by BBmac
Thanks so much for the help with the last scripting project. I understand alot more with scripting and have done alot by myself. Now though... i want to make a trigger that will kill someone if they stay there too long. Can someone give me an example script of this?

Posted: Tue Nov 21, 2006 10:57 pm
by ViPER
don't forget the search feature - heres one we did recentley -

/forum/viewtopic.php?p=96636&highlight=#96636

Posted: Tue Nov 21, 2006 11:51 pm
by BBmac
lol sorry... i try keywords and things and I dont find anything... Ill start checking inside the topics more often for now on. But that is from one of my previous topics. That was about killing someone for going into a certain area. I want to do the same but I dont want the trigger to activate until player has been there for a certain amount of time, say 20 seconds. I found 2 other similar threads. 1 of them led to mod r us.net which i think url link they posted for it had been erased. The second one had some other stuff in it the person asking for help had added and made the understanding very confusing. This is the code i use for killing people for trying to roof glitch.

main:

thread doorblock

level waittill prespawn

doorblock:
local.trig = spawn trigger_multiple
local.trig targetname doorblock
local.trig.origin = ( -488 -1252 -926 )
local.trig setsize ( -20 -20 0 ) ( 60 60 150 )
$doorblock waittill trigger
local.player = parm.other
wait 20
if (local.player = parm.other){

local.player stufftext "kill"
local.player stufftext "iprint Do not doorblock!"
wait 2
$doorblock remove
wait .1
thread doorblock
}

end



doorblock is the name i gave my new script trigger (originally roofglitch) and the parts in red are things i added that i thought would make this possible. As you can see i was wrong. Do i need to make one trigger that activates another and if so, how?

Posted: Wed Nov 22, 2006 1:50 am
by ViPER
hmmm there are several ways to do that and i sure mines not the best but as this is close to the last trigger we did try this variation.


thread after prespawn

Code: Select all

badspot: 
local.spot1 = spawn trigger_multiple targetname "badplace"
local.spot1.origin = ( x y z ) //your coords here 
local.spot1 setsize ( -100 -100 -100 ) ( 100 100 100 ) //setsize here 
local.spot1 waittill trigger 
local.spot1 setthread badboy 
local.spot1 message "This is a bad spot!" 
local.spot1 delay 0 
end 

badboy: 
local.count = 0
local.badboy = parm.other 
local.badplace = $badplace

while(local.badplace istouching local.badboy && local.badboy != NULL && local.count < 11)
  {
  local.count++
  wait 1
  if(local.count == 10)	
  local.badboy kill 
  }
end 
is set for ten - if you cahnge the set kill time then change the while statement too.

Posted: Wed Nov 22, 2006 2:31 am
by BBmac
The message worked but nothing else did... it did not kill me or anything... Ill try with that exact model u set. But also... of course if they figure out that spot and the timelimit on it, all they will do is move off and then move back on to it in abot 3 secs time which gives them a whole new camp time. So... is there a script to keep this from happening?

Posted: Wed Nov 22, 2006 5:05 am
by ViPER
hmmm works in sh - try taking out the message line once its working and also try

local.badboy hurt 1000

Posted: Wed Nov 22, 2006 11:25 am
by BBmac
This is what i keep getting in console... (message still works by the way)

Code: Select all

^~^~^ ScriptVM::HandleScriptException: Cannot cast 'array' to listener

while(local.badplace istouching local.badboy && local.badboy != NULL && local.count < 11)  (global/block.scr, 20)
while(local.badplace ^

Posted: Wed Nov 22, 2006 11:37 am
by ViPER
try to put it in your map script instead of a global. Did you say your using AA ? - because it worked is SH.

Posted: Wed Nov 22, 2006 1:55 pm
by BBmac
I use SH.... Ill try to spawn it in with a tower mod...


reply: 1:10 pm

No... still doesnt work :(

Posted: Wed Nov 22, 2006 6:57 pm
by BBmac
can you post a different code or something? or maybe another script someone made?

Posted: Wed Nov 22, 2006 7:45 pm
by ViPER
well then it works- your doing something wrong. what map is it for? post your script here.

thread badspot after prespawn uin your map script

Posted: Wed Nov 22, 2006 8:38 pm
by BBmac
Im using the malta map... this is for spearhead demo so thats what im testing it on... but here is code im using...

thread badspot
level waittill prespawn

badspot:
local.spot1 = spawn trigger_multiple targetname "badplace"
local.spot1.origin = ( 1746 2679 -975 )
local.spot1 setsize ( -100 -100 -100 ) ( 100 100 100 )
local.spot1 waittill trigger
local.spot1 setthread badboy
local.spot1 message "This is a bad spot!"
local.spot1 delay 0
end

badboy:
local.count = 0
local.badboy = parm.other
local.badplace = $badplace

while(local.badplace istouching local.badboy && local.badboy != NULL && local.count < 11)
{
local.count++
wait 1
if(local.count == 10)
local.badboy kill
}
end

only thing i changed are coordinates... Its something to do with the while statement thats keeping this from happenning i think... something in it just isnt working... I have looked through all kind of scripting tuts but i dont know what to look for because of little things like, not knowing the defenition of "NULL" and what exactly "local.count" does. So do you see any error in the code?

Posted: Wed Nov 22, 2006 8:53 pm
by Wertmanzzz
Em a bit stupid answer maybe but you could say, instead of local.badplace istouching local.badboy, use local.badboy istouching local.badplace, or, instead of local.badplace use $badplace.
If this works then I'm laughinh :P

Edit: and it could also be that, because of the trigger being local, it doesn't works (don't think so, but maybe)

Posted: Wed Nov 22, 2006 9:09 pm
by ViPER
ok this is backwards - thread should be after prespawn

thread badspot
level waittill prespawn

should be (in Malta map scr) like this -

Code: Select all

level waittill prespawn 
thread badspot 
and this should be after end of main

find the end of the main thread and put this -

Code: Select all

badspot: 
local.spot1 = spawn trigger_multiple targetname "badplace" 
local.spot1.origin = ( 1746 2679 -975 ) 
local.spot1 setsize ( -100 -100 -100 ) ( 100 100 100 ) 
local.spot1 waittill trigger 
local.spot1 setthread badboy 
local.spot1 message "This is a bad spot!" 
local.spot1 delay 0 
end 

badboy: 
local.count = 0 
local.badboy = parm.other 
local.badplace = $badplace 

while(local.badplace istouching local.badboy && local.badboy != NULL && local.count < 11) 
{ 
local.count++ 
wait 1 
if(local.count == 10) 
local.badboy kill 
} 
end 

If the player leaves the server while in your trigger wierd things can happen - NULL is checking to see if the player is still on the server.

local.count keeps track of how long the player is in the trigger. each second the while loop adds 1 to count - and when it reaches 10 it kills.

Posted: Wed Nov 22, 2006 10:30 pm
by BBmac
ok... i thought that about the local.count. Thx for telling me about the Null. I also saw on another script where someone had a time on it where if the player returned to the area for the set ammount of time it would continue to hurt them. Is the string local.time "entry here" a valid string to use?