View Single Post
  #2  
Old 05-29-2010, 09:10 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Try changing this
PHP Code:
setani(client.mode,null); 
to this
PHP Code:
if (client.mode != "idle" || (client.mode == "idle" && ! this.hasChangedIdle)) {
  
this.hasChangedIdle = (client.mode == "idle");
  
setAni(client.modenull);

This will only change the GANI to "idle" if the player has changed their player mode since the last loop.



Also, a security note:
PHP Code:
function onActionServerside() { 
  if (
params[0]=="setspeed"clientr.speed=params[1]; 

There is no point in using clientr variables if you allow the client to send the speed they want. Triggers are pretty easy to send, and there used to be a tool around for sending fake ones (not sure if it still works). You should always validate data the client sends. Something like speed should probably be set on login.

PHP Code:
// NPC made by Dusty 
function onPlayerLogin(pl) {
  
pl.clientr.speed 1;
}
//#CLIENTSIDE 
function onCreated() { 
  
this.chairtiles={ 
    
0x2A9,0x2AA
    
0x2B9,0x2BA
    
0xF37,0xF38,0xF39
    
0xF47,0xF48,0xF49
    
0x676,0x677,0x678
    
0x686,0x687,0x688 
  
}; 

  
disabledefmovement(); 

  
onTimeout(); 


function 
onTimeout() { 
  
client.mode="idle"//<=== The problem? 
  
for (k=0;k<4;k++) { 
    if (
keydown(k)) { 
      
client.mode="walk"
      
player.dir=k
      
temp.blocked=checkwall(); 
      if (
blocked[0]==0) { 
        
player.x+=vecx(k)*clientr.speed
        
player.y+=vecy(k)*clientr.speed
      } else if (
blocked[1]==&& blocked[2]==0) {  
        
player.x-=vecx((k+1)%2)*(1/16); 
        
player.y-=vecy((k+1)%2)*(1/16); 
      } else if (
blocked[1]==&& blocked[2]==1) { 
        
player.x+=vecx((k+1)%2)*(1/16); 
        
player.y+=vecy((k+1)%2)*(1/16); 
      } 
    } 
  } 
  if (
onwater(player.x+1.5,player.y+2)) client.mode="swim"
  if (
tiles[player.x+1.5,player.y+1.75in this.chairtilesclient.mode="sit"
  
  if (
client.mode != "idle" || (client.mode == "idle" && ! this.hasChangedIdle)) { 
    
this.hasChangedIdle = (client.mode == "idle"); 
    
setAni(client.modenull); 
  }
   
  
temp.speedmod = (client.stats2[10]/16); 
   
  if(
client.mode="swim"){ 
  
temp.speed 3/16  temp.speedmod temp.speedmodwater
  
triggerserver("gui",name,"setspeed",speed);} 
  else{ 
  
temp.speed 6/16 temp.speedmod temp.speedmodland
  
triggerserver("gui",name,"setspeed",speed);} 
   
   
   
  
timeout=0.05


function 
checkwall() { 
  
temp.blocked=new[2]; 
  for (
w=0;w<1.5;w++) { 
    for (
i=0;i<(clientr.speed>0?clientr.speed:1/16);i+=1/16) { 
      
temp.checkx=((player.x+0.5+abs(vecx(k))-vecx((k+1)%2)*w)+vecx(k)*(1+i))+((k in {0,2})?1/16:0); 
      
temp.checky=((player.y+2-abs(vecx(k))-vecy((k+1)%2)*w)+vecy(k)*(1+i))+((k in {1,3})?1/16:0); 
      
blocked[w]=onwall2(checkx,checky,((k in {0,2})?15/16:1/16),((k in {1,3})?15/16:1/16)); 
      if (
blocked[0]+blocked[1]>0) { 
        
player.x+=(vecx(k)*i); 
        
player.y+=(vecy(k)*i); 
         
        break; 
      } 
    } 
  } 
  return {
blocked[0]+blocked[1],blocked[0],blocked[1]}; 

__________________
Reply With Quote