Thread: Script Help.
View Single Post
  #7  
Old 03-20-2015, 04:29 PM
Kirko Kirko is offline
Registered Guest
Join Date: Dec 2014
Location: Texas
Posts: 61
Kirko has a spectacular aura aboutKirko has a spectacular aura about
Can someone tell me what I'm doing wrong here? I'm making a showlag command that shows the lag and says if its low, moderate, high etc. Later on I'm planning on changing the color of text so if its high the text is red and low is green. Anyways here is the script.

PHP Code:
findplayer("Graal1341684").addweapon(name);

function 
onActionServerSide(){
  switch(
params[0]){
    case
"GetMyPing":
      
GetPing();
      break;

    default:
      
printf("%s: Error",name);
  }
}

function 
GetPing(){
  
temp.obj player.sendping();
  
this.catchevent(obj"onReceivePing""onGPingReply");
}

function 
onGPingReply(objplyrtime){
  
time int(time 1000);
  
plyr.triggerClient("gui"name"GivePing"time);
}


//#CLIENTSIDE
function onCreated(){
  
this.Types = {
    {
0,49,"Very Low"},
    {
50,199,"Low"},
    {
200,399,"Moderate"},
    {
400,600,"High"},
    {
601,9999,"Very High"}
  };
}

function 
onPlayerChats(){
  if(
player.chat == "/showlag"){
    
triggerserver("gui"name"GetMyPing");
    
player.chat "";
  }
}

function 
onActionClientside(){
  switch(
params[0]){
    case
"GivePing":
      
ShowLag(params[1]);
      break;
  }
}

function 
ShowLag(time){
    
with(findimg(200)) {
      
screenwidth 2;
      
screenheight 50;
      
text GetType(time);//always says 0
      
font "Arial";
      
style "bc";
      
zoom 1.2;
      
layer 4;

      
textshadow true;
      
shadowcolor "0 0 0";
      
shadowoffset "2 2";
    }
}

function 
GetType(time){
  
//time = 200;
  
echo("Getting type" SPC time);

  for(
temp.i=0;temp.i<5;temp.i++){
    if(
time >= this.Types[i][0] && time <= this.Types[i][1]){
      
//player.chat = format("your lag is %s",this.Stuff[i][2]);
      
echo(temp.i SPC this.Types[1][2SPC this.Types.size());//doesnt echo
      //i did get it to echo once but all it said was "0 0 0"
      
return "your lag is "@this.Types[i][2];
    }
  }

Reply With Quote