View Full Version : Is this Script Correct?
Inferno
May 17th, 2008, 12:16 PM
Basically i wrote this script out and tested it online but it didnt seem to sync and it seemed to cause problems with lag... can anyone tell me if i did something wrong with it.
(btw its meant to change the map from day to twilight to night and back)
(Script continuous day_night_biped_crush
(object_create_anew bone_crusher)
(object_teleport bone_crusher day_flag)
(sleep 10000)
(object_create_anew switcher_day)
(object_teleport bone_crusher twilight_flag)
(sleep 5000)
(object_create_anew switcher_twilight)
(object_teleport bone_crusher night_flag)
(sleep 10000)
(object_create_anew switcher_night)
(object_teleport bone_crusher twilight_flag)
(sleep 5000)
(object_create_anew switcher_twilight)
)
(Script continuous day_night_syncing
(if (= (unit_get_health switcher_day) 0)
(switch_bsp 0))
(if (= (unit_get_health switcher_twilight) 0)
(switch_bsp 1))
(if (= (unit_get_health switcher_night) 0)
(switch_bsp 2))
)
The1[Aaron]
May 18th, 2008, 11:17 PM
Basically i wrote this script out and tested it online but it didnt seem to sync and it seemed to cause problems with lag... can anyone tell me if i did something wrong with it.
(btw its meant to change the map from day to twilight to night and back)
(Script continuous day_night_biped_crush
(object_create_anew bone_crusher)
(object_teleport bone_crusher day_flag)
(sleep 10000)
(object_create_anew switcher_day)
(object_teleport bone_crusher twilight_flag)
(sleep 5000)
(object_create_anew switcher_twilight)
(object_teleport bone_crusher night_flag)
(sleep 10000)
(object_create_anew switcher_night)
(object_teleport bone_crusher twilight_flag)
(sleep 5000)
(object_create_anew switcher_twilight)
)
(Script continuous day_night_syncing
(if (= (unit_get_health switcher_day) 0)
(switch_bsp 0))
(if (= (unit_get_health switcher_twilight) 0)
(switch_bsp 1))
(if (= (unit_get_health switcher_night) 0)
(switch_bsp 2))
)
hmmmm that script looks really nice but i can help out a bit even though i don't have the hs_doc or any of my scripts with me full stop :P
ok first thing you need to know is unless its just the server running the biped crush script it will not sync at all.
so what you need to do is ... dam i need to atleast have a copy of the hs_doc.txt file here to look at... but i an give you a basic idea of what you need to do to make it sync you would start off with this in the script document
(Global Boolean Is_Server 0)
(Global Boolean Is_Client 1)
;what you want to do at this point is have a random unused vehicle somewhere in your map
;clients don't see the vehicle's health and it return's a 0 so when the un equal to zero is proven true it is infact false and the client won't progress with the first part of the response of the script but the server however will use the first response. so if we use the script (If Boolean response1 response2)
its just like saying
(if Boolean If_true If_false)
and the scripts
(begin
(script 1)
(script ect)
) is the response when you want to take more than one action in a response otherwise true and false statements can end like this
(if Boolean (sv_say "meh") (sv_say " doubble meh... your a client... woops clients can send a server message so this is going to show up as big red text saying clients can't send a server message") )
its as simple as english once you have a grasp of the basics :P
(script startup Server_test
(if (!= 0 (unit_get_health ServerVehicle))
(begin
(set Is_Server 1)
(set Is_Client 0)
(sv_say "You are the server") ;you don't really need this its just for knowing
)
(Begin
;this is just a filler to be correct with the script :P
)
)
)
;that script just establishes that you are a server or you are a client.
the next thing you want to do is tell the server to move another vehicle and kill another biped so we will. for those who don't know. biped's and vehicles work the exact same way on clients. they don't. but however. client can create there own vehicles and bipeds. you just can't do anything with the vehicles. and bipeds just get in the way.
(script continuous televehicle
(if Is_Server
(begin
(object_teleport Vehicle_time Day_flag)
(sleep 10000)
(object_teleport Vehicle_time Twilight_flag)
(sleep 5000)
(object_teleport Vehicle_time Night_flag)
(sleep 10000)
(object_teleport Vehicle_time Twilight_flag)
(sleep 9998)
)
)
)
;if you notice i took away 2 game ticks from the last sleep. i did that to compensate for the fact that it takes exactly 1 game tick to run through each script beginning. but you don't have to unless the script is rather fiddely like the one's i use to use
;The next thing we want to do is pick up on the fact that bipeds are dying :P
(script continuous Time_Change
(if ( = 0 (unit_get_health DayBiped))
(begin
(object_create_anew TwilightBiped)
(object_create_anew NightBiped)
(switch_bsp 1)
)
)
(if ( = 0 (unit_get_health TwilightBiped))
(begin
(object_create_anew DayBiped)
(object_create_anew NightBiped)
(switch_bsp 2)
)
)
(if ( = 0 (unit_get_health NightBiped))
(begin
(object_create_anew TwilightBiped)
(object_create_anew DayBiped)
(switch_bsp 3)
)
)
)
;and that last script has to run on both server and client otherwise it could cause problems like a cheating server in daytime all the time? :P
and i know that i said the health of a vehicle and biped don't sync but hear me out. when a game starts on a client. the server has its own biped and because it created that biped it won't create a second one. on the other hand the client dosn't recognie the server created biped and creates its own biped right ontop of the server's biped. what this does is gives the client and server a chance to sync up just a little in the sense that... i can't see the server biped there... oh wait i see my client biped there... yep... its dead.... time of day change time :P
and assuming that i explained everything correctly and it was easily understood you should end up with a script that should end up looking like this without the helpfull comments
(Global Boolean Is_Server 0)
(Global Boolean Is_Client 1)
(script startup Server_test
(if (!= 0 (unit_get_health ServerVehicle))
(begin
(set Is_Server 1)
(set Is_Client 0)
(sv_say "You are the server")
)
(Begin
;this is just a filler to be correct with the script :P
)
)
)
(script continuous televehicle
(if Is_Server
(begin
(object_teleport Vehicle_time Day_flag)
(sleep 10000)
(object_teleport Vehicle_time Twilight_flag)
(sleep 5000)
(object_teleport Vehicle_time Night_flag)
(sleep 10000)
(object_teleport Vehicle_time Twilight_flag)
(sleep 9998)
)
)
)
(script continuous Time_Change
(if ( = 0 (unit_get_health DayBiped))
(begin
(object_create_anew TwilightBiped)
(object_create_anew NightBiped)
(switch_bsp 1)
)
)
(if ( = 0 (unit_get_health TwilightBiped))
(begin
(object_create_anew DayBiped)
(object_create_anew NightBiped)
(switch_bsp 2)
)
)
(if ( = 0 (unit_get_health NightBiped))
(begin
(object_create_anew TwilightBiped)
(object_create_anew DayBiped)
(switch_bsp 3)
)
)
)
kenney001
May 19th, 2008, 12:21 AM
all those damn useless "begin" commands are driving me crazy. They are absolutely unneeded and pointless, and make it hard to read. Its a huge pet peeve of mine.
The1[Aaron]
May 19th, 2008, 02:16 AM
... u tool.... seriously.... you can't have more than one action in an if statement for either true or false... i do know what I'm doing. im not just some noob i actually have about 3 years experience behind me...
if you go from this
(script continuous televehicle
(if Is_Server
(begin
(object_teleport Vehicle_time Day_flag)
(sleep 10000)
(object_teleport Vehicle_time Twilight_flag)
(sleep 5000)
(object_teleport Vehicle_time Night_flag)
(sleep 10000)
(object_teleport Vehicle_time Twilight_flag)
(sleep 9998)
)
)
)
to this
(script continuous televehicle
(if Is_Server
(object_teleport Vehicle_time Day_flag)
(sleep 10000)
(object_teleport Vehicle_time Twilight_flag)
(sleep 5000)
(object_teleport Vehicle_time Night_flag)
(sleep 10000)
(object_teleport Vehicle_time Twilight_flag)
(sleep 9998)
)
)
you know what... ill just let you find out the hard way... much more entertaining 5 minutes later some1 asking for help about something that i just explained >_>...
seriously you can't even do this
(script continuous televehicle
(if Is_Server
(
(object_teleport Vehicle_time Day_flag)
(sleep 10000)
(object_teleport Vehicle_time Twilight_flag)
(sleep 5000)
(object_teleport Vehicle_time Night_flag)
(sleep 10000)
(object_teleport Vehicle_time Twilight_flag)
(sleep 9998)
)
)
)
even that wouldn't work >_>
ok i had 1 useless begin... that was more for explination than anything else
lol ill even quote myself in my post...
;what you want to do at this point is have a random unused vehicle somewhere in your map
;clients don't see the vehicle's health and it return's a 0 so when the un equal to zero is proven true it is infact false and the client won't progress with the first part of the response of the script but the server however will use the first response. so if we use the script (If Boolean response1 response2)
its just like saying
(if Boolean If_true If_false)
and the scripts
(begin
(script 1)
(script ect)
) is the response when you want to take more than one action in a response otherwise true and false statements can end like this
(if Boolean (sv_say "meh") (sv_say " doubble meh... your a client... woops clients can send a server message so this is going to show up as big red text saying clients can't send a server message") )
its as simple as english once you have a grasp of the basics :P
Inferno
May 19th, 2008, 02:45 PM
Wow thx for that reply lol. I sorta see how you fixed it but its still don't understand all of it. Ima fix my Script and test it probably this week and see if it works.
Thx again. :)
The1[Aaron]
May 19th, 2008, 05:26 PM
no problem. let me know how it turns out. i havn't messed with scripts for ages and i don't have the documentation to help me make sure my commands are correct but let me know how it turns out :P
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.