put it into PHP please and style the code
PHP Code:
function onActionServerSide(cmd){
if (cmd == "Strobe"){
show;
triggerClient("gui",this.name,"Strobe");
}
if (cmd == "StrobeOff"){
echo(temp.test);
triggerClient("gui",this.name,"StrobeOff");
hide;
}
}
//#CLIENTSIDE
function onPlayerChats() {
if (player.chat == "/strobeoff"){
hide;
temp.test = "Testing Script";
triggerserver("gui",this,name,"StrobeOff",temp.test);
}
if (player.chat == "/strobe"){
show;
settimer(0.1);
triggerserver("gui",this.name,"Strobe");
}
}
function onActionClientSide(cmd) {
if (cmd == "Strobe"){
onTimeout();
}
if (cmd == "StrobeOff"){
hide;
)
}
function onTimeout(){
this.zoom = 60;
this.alpha = 0.05;
this.red = 0.8;
this.blue = 0;
this.green = 1;
sleep(0.1);
this.red = 0;
this.blue = 0;
this.green = 0;
setTimer(0.1);
}
1. temp.test is not defined on the serversde part, therefore nothing can be echo'd (most likely a 0 will apear)
2. the way you use show and hide is gs1, so make sure to use gs2 by changing it to show() and hide()
3. on the onActionClientSide() part, you are having one invalid ')' and one '}' missing
4. in case this is a weapon, you cant just change this.zoom/alpha/red/blue...., nothing would change
in case this is a level npc, you can't just use triggerserver() to get to the serverside part (same for triggerclient()). you would need to use triggerAction() to access the server-/clientside part of the script
5. the only real use you seem to have for the serverside part is that you are displaying the npc to other players, yet they wouldnt see the effect. let me make a fixed version for you
this is a level npc - not a weapon
PHP Code:
function onCreated() {
//create a blocking shape for the npc so triggerAction() will work
this.setshape(1,32,32);
}
function onPlayerChats() {
if (player.chat == "/strobe") createEffect();
else if (player.chat == "/strobeOff") disableEffect();
}
function createEffect() {
//attr[] is always synced to serverside and clientside, so i will use this to store the information for everyone
this.attr[1] = "enabled";
//trigger the action for the clientside part, having the effect serverside will just lag the server
triggerAction(this.x, this.y, "StrobeToggle", NULL);
}
function disableEffect() {
this.attr[1] = "disabled";
triggerAction(this.x, this.y, "StrobeToggle", NULL);
}
//#CLIENTSIDE
function onPlayerEnters() {
this.setshape(1,32,32);
//we are having the checks in the onTimeOut() function
//like i mentioned, attributes are synced to client- and serverside, so stored information will be seen by everyone
onTimeOut();
}
function onActionStrobeToggle() {
onTimeOut();
}
function onTimeout(){
//if the effect is stoped, discontinue the loop
if (this.attr[1] == "disabled") return;
//else we can just continue everything
this.zoom = 60;
this.alpha = 0.05;
this.red = 0.8;
this.blue = 0;
this.green = 1;
sleep(0.1);
this.red = 0;
this.blue = 0;
this.green = 0;
setTimer(0.1);
}
ps: you dont seem to have any image set or whatever, you should change that