New Scripting Project

Post your scripting questions / solutions here

Moderator: Moderators

BBmac
Sergeant
Posts: 54
Joined: Sat Oct 28, 2006 6:05 am

New Scripting Project

Post 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?
User avatar
ViPER
General
Posts: 1058
Joined: Fri Jan 14, 2005 5:48 pm
Location: California
Contact:

Post by ViPER »

don't forget the search feature - heres one we did recentley -

/forum/viewtopic.php?p=96636&highlight=#96636
BBmac
Sergeant
Posts: 54
Joined: Sat Oct 28, 2006 6:05 am

Post 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?
User avatar
ViPER
General
Posts: 1058
Joined: Fri Jan 14, 2005 5:48 pm
Location: California
Contact:

Post 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.
BBmac
Sergeant
Posts: 54
Joined: Sat Oct 28, 2006 6:05 am

Post 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?
User avatar
ViPER
General
Posts: 1058
Joined: Fri Jan 14, 2005 5:48 pm
Location: California
Contact:

Post by ViPER »

hmmm works in sh - try taking out the message line once its working and also try

local.badboy hurt 1000
BBmac
Sergeant
Posts: 54
Joined: Sat Oct 28, 2006 6:05 am

Post 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 ^
User avatar
ViPER
General
Posts: 1058
Joined: Fri Jan 14, 2005 5:48 pm
Location: California
Contact:

Post 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.
BBmac
Sergeant
Posts: 54
Joined: Sat Oct 28, 2006 6:05 am

Post by BBmac »

I use SH.... Ill try to spawn it in with a tower mod...


reply: 1:10 pm

No... still doesnt work :(
BBmac
Sergeant
Posts: 54
Joined: Sat Oct 28, 2006 6:05 am

Post by BBmac »

can you post a different code or something? or maybe another script someone made?
User avatar
ViPER
General
Posts: 1058
Joined: Fri Jan 14, 2005 5:48 pm
Location: California
Contact:

Post 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
BBmac
Sergeant
Posts: 54
Joined: Sat Oct 28, 2006 6:05 am

Post 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?
Wertmanzzz
Lance Corporal
Posts: 21
Joined: Sun Feb 12, 2006 2:09 pm
Location: The Netherlands

Post 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)
User avatar
ViPER
General
Posts: 1058
Joined: Fri Jan 14, 2005 5:48 pm
Location: California
Contact:

Post 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.
BBmac
Sergeant
Posts: 54
Joined: Sat Oct 28, 2006 6:05 am

Post 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?
Post Reply