Drunk Player Walking
#1

Hello, i want to do that when a player is drunk he walks with DRUNK anim.

My problem is to detect when player is moving ( W A S D), i mean that he can't run/walk, when he tries to do everything the script forces him DRUNK walk animation.

Anyone can help me? I'm trying to do this but it's bugging everything.
Reply
#2

This is all you need, apply it when the player drinks.
https://sampwiki.blast.hk/wiki/SetPlayerDrunkLevel
Reply
#3

Quote:
Originally Posted by TakeiT
Посмотреть сообщение
This is all you need, apply it when the player drinks.
https://sampwiki.blast.hk/wiki/SetPlayerDrunkLevel
Nope, because SetPlayerDrunkLevel just makes your visual move.
I would like that when the player moves (W - A - S - D) the drunk walk style animation applies on him,
but not only when pressing ALT, but also when running / sprinting.

Please help me.
Reply
#4

http://lmgtfy.com/?q=samp+drunk+animation
Reply
#5

I already have got the drunk animation.
Why don't you read?
I am looking a way to let the player moves when he's drunk, so when he wants to stop walking there's no anim on him.
Reply
#6

Sorry, I clearly didn't read that properly.

You need to detect the W/A/S/D keys (or arrow keys) with GetPlayerKeys under OnPlayerUpdate. If they press W or S - apply anim. If they release W/S - stop anim.
Reply
#7

Quote:
Originally Posted by MP2
Посмотреть сообщение
Sorry, I clearly didn't read that properly.

You need to detect the W/A/S/D keys (or arrow keys) with GetPlayerKeys under OnPlayerUpdate. If they press W or S - apply anim. If they release W/S - stop anim.
Tried to, but it bugs my player...
Reply
#8

Can you elaborate please? How do you mean it bugs your player?
Reply
#9

That's what i did.. seems not working. The bug was mine mistake sorry

Код:
CheckWalk(playerid) {
	new keys, updown, leftright;
	
	GetPlayerKeys(playerid, keys, updown, leftright);
	
	if(LegShooted[playerid] == 1) {
	    if ((keys == KEY_UP) || (keys == KEY_DOWN) || (keys == KEY_LEFT) || (keys == KEY_RIGHT))
		{
			ApplyAnimation(playerid,"PED","WALK_old",4.1,1,1,1,1,1);
		}
	}
	else if(Giocatore[playerid][pDrunk] == 1) {
		if ((keys && updown & KEY_UP) || (keys && updown & KEY_DOWN) || (keys && leftright & KEY_LEFT) || (keys && leftright & KEY_RIGHT))
		{
			ApplyAnimation(playerid,"PED","WALK_drunk",4.1,1,1,1,1,1);
		}
	}
}

public OnPlayerUpdate(playerid) {
   CheckWalk(playerid);

}
Reply
#10

The 'keys' variable doesn't store U/D/L/R. That's what the 'updown' and 'leftright' variables are for.

pawn Код:
if(leftright == KEY_LEFT || leftright == KEY_RIGHT)
{
    // They are holding left or right
}
Or alternatively...
pawn Код:
if(leftright) // Not false (0)
{
    // They are holding left or right
}
Also, you want to check if they just STARTED to hold a key, you don't want to keep applying the animation. So to do this, you need to get their old key state (save it in variables).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)