New Scripting Project
Moderator: Moderators
New Scripting Project
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?
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?
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?
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
is set for ten - if you cahnge the set kill time then change the while statement too.
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 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?
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 ^
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?
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?
-
Wertmanzzz
- Lance Corporal
- Posts: 21
- Joined: Sun Feb 12, 2006 2:09 pm
- Location: The Netherlands
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
Edit: and it could also be that, because of the trigger being local, it doesn't works (don't think so, but maybe)
If this works then I'm laughinh
Edit: and it could also be that, because of the trigger being local, it doesn't works (don't think so, but maybe)
ok this is backwards - thread should be after prespawn
thread badspot
level waittill prespawn
should be (in Malta map scr) like this -
and this should be after end of main
find the end of the main thread and put this -
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.
thread badspot
level waittill prespawn
should be (in Malta map scr) like this -
Code: Select all
level waittill prespawn
thread badspot
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.
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?
