Random Animation
#1

Is there anyone to make it so any player that is spawned in will do an animation of my choice? I'm new to scripting and looking to learn. Basically, I want this:

Random player does the animation: CS_DEAD_GUY at any random time or w/e. I will rep you for the help!
Reply
#2

If you're using foreach, you can use the Iter_Random function to get a random player ID. Example:
pawn Код:
ApplyAnimation(Iter_Random(Player), "WUZI", "CS_Dead_Guy", 4.1, 1, 0, 0, 0, 1, 1);
Reply
#3

Hi, thanks for the reply. I did that but now I get these errors:.
Quote:

C:\Users\Aoky\Desktop\Stuff\Server\pawno\include\Y SI\..\YSI_Data\..\YSI_Internal\..\YSI_Core\y_utils .inc(254) : warning 202: number of arguments does not match definition
C:\Users\Aoky\Desktop\Stuff\Server\pawno\include\Y SI\..\YSI_Data\..\YSI_Internal\..\YSI_Core\y_utils .inc(267) : error 025: function heading differs from prototype
C:\Users\Aoky\Desktop\dildo.pwn(6 : warning 209: function "ScriptInit_OnGameModeInit" should return a value
C:\Users\Aoky\Desktop\dildo.pwn(395) : error 021: symbol already defined: "ApplyAnimation"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


2 Errors.

Reply
#4

Is there anyway to do this without foreach?
Reply
#5

Quote:
Originally Posted by aoky
Посмотреть сообщение
Is there anyway to do this without foreach?
It's possible without foreach, however is less optimized. This might work, I haven't tested it though.
pawn Код:
new RandomPlayer = INVALID_PLAYER_ID, TempIndex;
while(RandomPlayer == INVALID_PLAYER_ID)
{
    TempIndex = random(GetPlayerPoolSize() + 1);
    if(TempIndex != INVALID_PLAYER_ID)
        RandomPlayer = TempIndex;
}
This continues the code block until a random player has been selected.
Reply
#6

So I do this:
Quote:

new RandomPlayer = INVALID_PLAYER_ID, TempIndex;
while(RandomPlayer == INVALID_PLAYER_ID)
{
TempIndex = random(GetPlayerPoolSize() + 1);
if(TempIndex != INVALID_PLAYER_ID)
RandomPlayer = TempIndex;
ApplyAnimation(playerid, "WUZI", "CS_Dead_Guy", 4.1, 1, 0, 0, 0, 1, 1);
}

Reply
#7

Not nessacarily like that, you could do something like this:
pawn Код:
new RandomPlayer = INVALID_PLAYER_ID, TempIndex;
while(RandomPlayer == INVALID_PLAYER_ID)
{
    TempIndex = random(GetPlayerPoolSize() + 1);
    if(TempIndex != INVALID_PLAYER_ID)
        RandomPlayer = TempIndex;
}

ApplyAnimation(RandomPlayer, "WUZI", "CS_Dead_Guy", 4.1, 1, 0, 0, 0, 1, 1);
Alternatively, you could just do this with foreach if you want more optimization:
pawn Код:
ApplyAnimation(Iter_Random(Player), "WUZI", "CS_Dead_Guy", 4.1, 1, 0, 0, 0, 1, 1);
Reply
#8

Hey, thanks.
Quote:

C:\Users\Aoky\Desktop\dildo.pwn(411) : error 010: invalid function or declaration
C:\Users\Aoky\Desktop\dildo.pwn(414) : error 010: invalid function or declaration
C:\Users\Aoky\Desktop\dildo.pwn(41 : warning 203: symbol is never used: "RandomPlayer"
C:\Users\Aoky\Desktop\dildo.pwn(41 : warning 203: symbol is never used: "TempIndex"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


2 Errors.

I get 2 errors now.
Reply
#9

What's line 411?
Reply
#10

while(RandomPlayer == INVALID_PLAYER_ID)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)