![]() |
Needs help with keydown
To start out this post...I suck at scripting!!!
I was making the starting movement for a race and I couldn't make it so that the player stops using walk.gani and uses idle.gani when the player isn't moving. Right now the player just moves all the time. Here's the script, could you help me out(i added the onwall incase that may be of any good use)?: if (playertouchsme) { toweapons System; disabledefmovement; timeout=0.05;} if (timeout) { if (keydown(0)){ playerdir = 0; playery-=0.5; setani walkslow,; } if (keydown(1)){ playerdir = 1; playerx-=0.5; setani walkslow,; } if (keydown(2)){ playerdir = 2; playery+=0.5; setani walkslow,; timeout=0.05; } if (keydown(3)){ playerdir = 3; playerx+=0.5; setani walkslow,; } timeout=0.05; //left detection if (onwall(playerx+0.5,playery+1.5)) {playerx+=0.5} if (onwall(playerx+0.5,playery+2)){playerx+=0.5} //right detection if (onwall(playerx+2,playery+1.5)) {playerx-=0.5} if (onwall(playerx+2,playery+2)) {playerx-=0.5} //down detection if (onwall(playerx+0.5,playery+2.5)) {playery-=0.5} if (onwall(playerx+1,playery+2.5)) {playery-=0.5} if (onwall(playerx+1.5,playery+2.5)) {playery-=0.5} //up detection if (onwall(playerx+0.5,playery+1)) {playery+=0.5} if (onwall(playerx+1,playery+1)) {playery+=0.5} if (onwall(playerx+1.5,playery+1)) {playery+=0.5} |
Ok whats it supposed to do if u post the ganis ill look at it offline and see the problem
|
for (i=0; i<4; i++) {
if (keydown(i) { setani walkslow,; break; } else setani idle,; } I dunno if that would work, but it should. *is pretty sure there is a very obvious mistake in there* |
It's not working =(
I checked it in the editor and it says for the part, ---- for (i=0; i<4; i++) { if (keydown(i) { setani walkslow,; break; } else setani idle,; } ---- "Error: Expected format: if (flag) command;" <edited> for (i=0; i<4; i++)) { if (keydown(i) { setani walkslow,; break; } else setani idle,; } //he forgot the extra ) after the for part |
Quote:
I'll help, but I want off ignore ;) timeout=.50; if (playertouchsme) { toweapons System; disabledefmovement; timeout=0.05;} if (timeout) { if (keydown(0)){ playerdir = 0; playery-=0.5; setani walkslow,; } if (keydown(1)){ playerdir = 1; playerx-=0.5; setani walkslow,; } if (keydown(2)){ playerdir = 2; playery+=0.5; setani walkslow,; timeout=0.05; } if (keydown(3)){ playerdir = 3; playerx+=0.5; setani walkslow,; } timeout=0.05; //left detection if (onwall(playerx+0.5,playery+1.5)) {playerx+=0.5} if (onwall(playerx+0.5,playery+2)){playerx+=0.5} //right detection if (onwall(playerx+2,playery+1.5)) {playerx-=0.5} if (onwall(playerx+2,playery+2)) {playerx-=0.5} //down detection if (onwall(playerx+0.5,playery+2.5)) {playery-=0.5} if (onwall(playerx+1,playery+2.5)) {playery-=0.5} if (onwall(playerx+1.5,playery+2.5)) {playery-=0.5} //up detection if (onwall(playerx+0.5,playery+1)) {playery+=0.5} if (onwall(playerx+1,playery+1)) {playery+=0.5} if (onwall(playerx+1.5,playery+1)) {playery+=0.5} You've been cursed with darklink wub. What I done was added "timeout=.50" at top, hehehehe. It should work >.< |
I already had a timeout set:timeout = 0.05
I've used some stuff Loriel's given me. I just need to find out where to use it and what else to add. |
the problem with loriel's is after the if (keydown(0)
theres only one ")" and there needs to be 2 if (keydown(0)) i think |
Quote:
|
hummmm
if you intend to have your player world non p2p you can't have different races, you could try using replaceani and screw keydown and all that, replaceani needs a p2p server though
|
use while true...
|
Quote:
|
| All times are GMT +2. The time now is 10:03 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.