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());
}