Alright, so i found a script dusty made to build off of for my custom movement script. I've been trying to get it so that when you press S, the custom sword script runs (not shown in the example). That part, I pretty much know how to do. but the problem is that the client.mode="idle"; is pretty much taking priority over everything, and i cant seem to figure out a way around this. i need it so when you press S and the attack gani begins, the script waits until the gani ends (perhaps with a timer) before it starts looping that part of the script again. the closest i got this to working was a torn-apart, messy script that almost did everything i wanted it to, except the "for (k=0;k<4;k++) {
if (keydown(k)) { " part was always returning 4. or however that works. So i figured i'd get a fresh start with this question rather than trying to deal with the headache of a script i ended up with last time. Though if you guys think it would be better if i posted the other script instead, i could do that.
PHP Code:
// NPC made by Dusty
function onActionServerside() {
if (params[0]=="setspeed") clientr.speed=params[1];
}
//#CLIENTSIDE
function onCreated() {
this.chairtiles={
0x2A9,0x2AA,
0x2B9,0x2BA,
0xF37,0xF38,0xF39,
0xF47,0xF48,0xF49,
0x676,0x677,0x678,
0x686,0x687,0x688
};
triggerserver("gui",name,"setspeed",speed);
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]==1 && blocked[2]==0) {
player.x-=vecx((k+1)%2)*(1/16);
player.y-=vecy((k+1)%2)*(1/16);
} else if (blocked[1]==0 && 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.75] in this.chairtiles) client.mode="sit";
setani(client.mode,null);
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]};
}