flyxdvd Posted May 6, 2015 Report Share Posted May 6, 2015 Hello again, While figuring the addactions i found out a way to give people with the decent GUID to get an addaction tru the Epoch.Atlis mission. init.sqf //Mission pbo event = false; publicVariable "event"; waitUntil {!(isNull (findDisplay 46))}; if ((getPlayerUID player) in ["MY ID"]) then { systemChat "Adding event"; removeAllActions player; waitUntil {!isNull player}; while {true} do { waitUntil {sleep 1.5; alive player}; player addaction ["Start Event", "start.sqf","",5,false,true,"",""]; waitUntil {sleep 1.5; !alive player}; }; }; it calls another script in the altis.mission wich basicly sets a public variable to true, start.sqf //mission pbo systemChat "Starting event"; event = true; publicVariable "event"; Then in my @epochHive it should see this if im not wrong thats its set to True and run this if (isServer) then { if (event)then { [] execVM "x\addons\custom\serverside\test.sqf"; }; }; This file is called test.sqf and i got an init.sqf calling this file in the addon. Now my question is When i set event = false; publicVariable "event"; to true at the start of the server it runs the code in @epochHive but when i try to set it to true with the addaction running a script setting it true it doesnt seem to work. Im probably just missing something small i guess. I hope you guys understand what i mean otherwise ask! ill try to explain it better haha. Only yesterday i learned about AddpublicEventHandelers and Public variables so its still a bit fresh greetz FlyX Link to comment Share on other sites More sharing options...
0 Silens Posted May 6, 2015 Report Share Posted May 6, 2015 Your server side script in epochHive only runs once when the server starts, so it will only run or not run based on whatever you have "event=" set to in the mission init.sqf since init.sqf is loaded by both the server and client. Anything else you do with "event" after that doesn't matter because the script is no longer running. To use public variables you need an addPublicVariableEventHandler on the server (or clients depending on where you want it to go off) and use publicVariableServer, it will only send the variable to the server, publicVariable will send the variable to everyone. My suggestions, remove event = false; publicVariable "event"; from your mission init.sqf In your start.sqf systemChat "Starting event"; event = true; publicVariableServer "event"; In your @epochHive script: "event" addPublicVariableEventHandler { [] execVM "x\addons\custom\serverside\test.sqf"; }; (You don't need to use isServer on @epochHive scripts, they only run on the server) This way, when your addaction runs start.sqf, "event" will be sent to the server and the server will then run [] execVM "x\addons\custom\serverside\test.sqf"; Link to comment Share on other sites More sharing options...
0 flyxdvd Posted May 7, 2015 Author Report Share Posted May 7, 2015 Your server side script in epochHive only runs once when the server starts, so it will only run or not run based on whatever you have "event=" set to in the mission init.sqf since init.sqf is loaded by both the server and client. Anything else you do with "event" after that doesn't matter because the script is no longer running. To use public variables you need an addPublicVariableEventHandler on the server (or clients depending on where you want it to go off) and use publicVariableServer, it will only send the variable to the server, publicVariable will send the variable to everyone. My suggestions, remove event = false; publicVariable "event"; from your mission init.sqf In your start.sqf systemChat "Starting event"; event = true; publicVariableServer "event"; In your @epochHive script: "event" addPublicVariableEventHandler { [] execVM "x\addons\custom\serverside\test.sqf"; }; (You don't need to use isServer on @epochHive scripts, they only run on the server) This way, when your addaction runs start.sqf, "event" will be sent to the server and the server will then run [] execVM "x\addons\custom\serverside\test.sqf"; Thank you sir! gonna test this right now. And also thanks for the isServer no need. Didnt know that mainly did it because well just to be sure hehe Link to comment Share on other sites More sharing options...
0 flyxdvd Posted May 7, 2015 Author Report Share Posted May 7, 2015 Just confirming again. Solution of @Silens works. Thanks agian. Flyx Link to comment Share on other sites More sharing options...
Question
flyxdvd
Hello again,
While figuring the addactions i found out a way to give people with the decent GUID to get an addaction tru the Epoch.Atlis mission.
init.sqf //Mission pbo
it calls another script in the altis.mission
wich basicly sets a public variable to true,
start.sqf //mission pbo
Then in my @epochHive
it should see this if im not wrong thats its set to True
and run this
This file is called test.sqf
and i got an init.sqf calling this file in the addon.
Now my question is
When i set
to true at the start of the server it runs the code in @epochHive
but when i try to set it to true with the addaction running a script setting it true it doesnt seem to work.
Im probably just missing something small i guess. I hope you guys understand what i mean otherwise ask! ill try to explain it better haha.
Only yesterday i learned about AddpublicEventHandelers and Public variables so its still a bit fresh
greetz FlyX
Link to comment
Share on other sites
3 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now