Server Variable

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

Ceciaman
Posts: 45
Joined: 13 Feb 2009, 11:35

Server Variable

Postby Ceciaman » 09 Jan 2021, 23:21

Hi,
when i try to move value from "Mazzetto1" or "Mazzetto2" into Player Cards, sometime the value returned is null why?.

Variable on server:
Pz1=0;
Pz2=0;
Mazzetto1="AAAA";
Mazzetto2="BBBB";

Carte1="CCCC";
Carte2="DDDD";
Carte3="EEEE";
Carte4="FFFF";

When a player have no card (es: Carte1="") the Server must take the value of Mazzetto not null:

Carte1="";

Became;

Mazzetto1="";
Carte1="AAAA";

if Mazzetto1 is Null then:

Mazzetto2="";
Carte1="BBBB";

Sometime the server not execute this.
How can i solve it?








SERVERSIDE JAVASCRIPT

Code: Select all

function vaiavolo(params,sender){

   var mioturno=room.getVariable("turno").value;   

      var mazz;
     var mazzetto;
     var Pz;
    var carte;
   

   
      if(room.getVariable("Pz1").value==0){
         mazzetto=room.getVariable("Mazzetto1").value;
      }else{
         mazzetto=room.getVariable("Mazzetto2").value;
      }   
   
      if(mioturno==0){
         carte =new SFSRoomVariable("Carte1",mazzetto);
      }
      if(mioturno==1){
         carte =new SFSRoomVariable("Carte2",mazzetto);
      }
      if(mioturno==2){
         carte =new SFSRoomVariable("Carte3",mazzetto);
      }
      if(mioturno==3){
         carte =new SFSRoomVariable("Carte4",mazzetto);
      }


   
       if(room.getVariable("Pz1").value==0){
         mazz =new SFSRoomVariable("Mazzetto1","");
      }else{
         mazz =new SFSRoomVariable("Mazzetto2","");
      }   

   if(mioturno==0){

         Pz =new SFSRoomVariable("Pz1",1);
      }
      if(mioturno==1){

         Pz =new SFSRoomVariable("Pz2",1);
      }
      if(mioturno==2){
   
         Pz =new SFSRoomVariable("Pz1",1);
      }
      if(mioturno==3){
   
         Pz =new SFSRoomVariable("Pz2",1);
      }
   
       Arrays=[mazz,carte,Pz];

      getApi().setRoomVariables(null, room, Arrays,false,false,false,true);
      
       stepCount=-2;
       status=5;   
      var resObj = new SFSObject();
       resObj.putInt("turno",mioturno);
      send("vaiavolo", resObj, room.getUserList());
}
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Server Variable

Postby Lapo » 11 Jan 2021, 09:42

Hi,
we need a reproducible case to be able to help. In other words, we need a code example that reproduces the issue you're trying to solve.
Otherwise it's very difficult to just look at the code (without the rest of the game state) and guess what might be wrong.

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 42 guests