Set time to dark / light

What it does?
This Script allows you to change the dark / light effect of the level.

Commands:
/time 1Changes the effect to dark
/time 2Changes the effect to light

This script doesn’t works in online mode, it just changes the effect of the client not of the server, if someone is so nice and can post here how to fix it, would it be really helpful^^

[CODE]if (playerchats && startswith(/time,#c)) {
tokenize #c;
this.answer = strtofloat(#t(1));
// dark
if (this.answer == 1 && server.effect == 0.75) {
setplayerprop #c,Its already light!;
}
if (this.answer == 1 && server.effect == 0) {
while(server.effect<0.75){
setplayerprop #c,Changing Time…;
sleep 0.1;
server.effect = server.effect+0.005;
setplayerprop #c,Time changed!;
}
} // dark end

// light
if (this.answer == 2 && server.effect == 0) {
setplayerprop #c,Its already light!;
}
if (this.answer == 2 && server.effect == 0.75) {
while(server.effect>0){
setplayerprop #c,Changing Time…;
sleep 0.1;
server.effect = server.effect-0.005;
setplayerprop #c,Time changed!;
}
}
// light end
}
[/CODE]

if (timeout) { seteffect 0,0,0,server.effect; } timeout = 0.05;

I’m not a good code writer or anything, but I think you need something that gives each player something in their inventory that tells the client to read the server variable, so when someone updates it then it will change for everyone.

Do what Dylan suggests. Just assume everything is client side when working with gs1.

As far as I’m aware, GS1 only handles true serverside objects over a completely global scope via strings. Thus you’ll need a slightly new approach. I could easily write you a solution in a minute but you won’t learn so here’s what you’ll need.

setstring server.effect,0.5;//sets the server string, server.effect to 0.5
this.effectVal = strtofloat(#s(server.effect));//converts the server string to a number(float)

Also what the others are saying is true, you’ll need to make this script a weapon so the player carries it everywhere.

Oh i understand. so i need to remove the flag server.effect and make it to string. and this string = this.effect right?

___Merged doublepost__________________

Can someone post the script ? I tried to rescript it but I couldn’t.

:shrug:

if (playerenters){
  if (!isweapon){
    toweapons -day_night;
  }

  timeout = 0.05;
}

if (timeout){//constantly loop checking for updates
  if (strtofloat(#s(server.dayNight)) == 1)
    seteffect 0, 0, 0, 0.5;
  else
    seteffect 0, 0, 0, 0;

  timeout = 0.01;
}

if (playerchats){
  if (strequals(#g,Admin)){
    if (strequals(#c,/daytime))
      setstring server.dayNight,0;

    else if (strequals(#c,/nighttime))
      setstring server.dayNight,1;
  }

  timeout = 0.05;
}

If you’re not gonna use the brackets then don’t use that carriage return.

Bite me! Everyone has their own convention and that’s how I role.