ApplyAnimation problem
#1

So, i've did:
pawn Код:
dcmd_punch(playerid,params[])
{
    #pragma unused params
    return ApplyAnimation(playerid, "BIKEd", "BIKEd_hit", 4.0, 0, 0, 0, 0, 0);
}
And nothing happens, I want to apply the animation: "BIKEd_hit. Any help would be helpful .

EDIT: Second problem
SOLVED
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        if(newkeys == KEY_FIRE)
        {
            new Float:health;
            new Float:x, Float:y, Float:z;
            GetPlayerPos(playerid, x, y, z);
            new string[128];
            new pName[MAX_PLAYER_NAME];
            GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
            for(new i=0; i<MAX_PLAYERS; i++)
            {
                if(IsPlayerInRangeOfPoint(i, 1.0, x, y, z))
                {
                    new pHealth = GetPlayerHealth(i, health);
                    SetPlayerHealth(i, pHealth-10);
                    format(string, sizeof(string), "You have been punched by %s", pName);
                    PlayerPlaySound(i, 1130, 0.0, 0.0, 0.0);
                    PlayerPlaySound(playerid, 1130, 0.0, 0.0, 0.0);
                    SendClientMessage(i, 0xFFFF00AA, string);
                }
            }
        }
    }
    return 1;
}
When I click while in a vehicle, it takes away all my HP, and spawns me.
Reply
#2

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        if(newkeys == KEY_FIRE)
        {
            new Float:health;
            new Float:x, Float:y, Float:z;
            GetPlayerPos(playerid, x, y, z);
            new string[128];
            new pName[MAX_PLAYER_NAME];
            GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
            for(new i=0; i<MAX_PLAYERS; i++)
            {
                if(IsPlayerInRangeOfPoint(i, 1.0, x, y, z))
                {
                    new pHealth = GetPlayerHealth(i, health);
                    SetPlayerHealth(i, pHealth-10);
                    format(string, sizeof(string), "You have been punched by %s", pName);
                    PlayerPlaySound(i, 1130, 0.0, 0.0, 0.0);
                    PlayerPlaySound(playerid, 1130, 0.0, 0.0, 0.0);
                    SendClientMessage(i, 0xFFFF00AA, string);
                }
                else
                {
                      SendClientMessage(i, 0xFFFF00AA, "You are not near a vehicle");
                }
            }
        }
    }
    return 1;
}
Shouldn't you have like an "else" so if they are not close nothing happens and you won't lose health?
Reply
#3

That doesn't work, if statement itself, if there is no else, it will just do the thing, and if there is no one in the range, it will do nothing. So no need for else, and it doesn't work.
Reply
#4

Ah ok, I was just experimenting. I could probably try to solve the animation but I am not familiar with dcmd so if I do try, I would use strcmp.
Reply
#5

pawn Код:
for( new i; i < MAX_PLAYERS; i++ )
{
    if( i == playerid ) continue; // Skip if the playerid equals i
   
    if( IsPlayerInRangeOfPoint( i, 1.0, x, y, z ) )
    {
        new
            Float: playerHealth // Health / Armour are floats!
        ;
       
        GetPlayerHealth( i, playerHealth );
        SetPlayerHealth( i, playerHealth - 10.0 );
       
        format( string, sizeof( string ), "You have been punched by %s", pName );
        SendClientMessage( i, 0xFFFF00AA, string );
       
        PlayerPlaySound( i, 1130, 0.0, 0.0, 0.0 );
        PlayerPlaySound( playerid, 1130, 0.0, 0.0, 0.0 );
       
        break; // Can't punch more than one person.
    }
}
Untested.

EDIT

You may also want to use:

pawn Код:
if( newkeys & KEY_FIRE )
So that other keys ( W / S / A / D ) can be pressed while pressing KEY_FIRE.
Reply
#6

JamesC, thanks, althrough it had 5 errors, but I fixed them on my own. Will put you in the credits for the FS.
Now, I need to get the anim problem solved.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)