PDA

View Full Version : Blackout script, Sets screen black on Spawn, OnPlayerUpdate.


Dokins
16/02/2015, 03:33 PM
if(LoggedIn[playerid] == 1 && GetPlayerHealth(playerid, health) <= 40 && KnockedOut[playerid] == 0)
{
KnockedOut[playerid] = 1;
ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0,1);
TextDrawShowForPlayer(playerid,BFText);
new string[128];
format(string, sizeof(string), "* %s has lost consciousness due to their injuries *", GetNameEx(playerid));
ProxDetector(30.0, playerid, string, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE);
}


This is the detection I use, but when I spawn it processes all of that and doesn't apply the animation, could anyone assist me?

Thanks.

sw3das
16/02/2015, 04:30 PM
Have you tried to preload that animation ?
OnPlayerSpawn( playerid )
{
ApplyAnimation( playerid, "CRACK", "NULL", 0, 0, 0, 0, 0, 0 );
}

Dokins
16/02/2015, 04:32 PM
Already reload it, also. It doesn't explain when I login that I'm instantly blackscreened.

sw3das
16/02/2015, 04:38 PM
OnPlayerSpawn( playerid )
{
ApplyAnimation( playerid, "CRACK", "NULL", 0, 0, 0, 0, 0, 0 );
}

OnPlayerUpdate( playerid )
{
new Float:health;
GetPlayerHealth( playerid, health );

if( LoggedIn[playerid] == 1 && health <= 40 && KnockedOut[playerid] == 0)
{
KnockedOut[playerid] = 1;
ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0,1);
TextDrawShowForPlayer(playerid,BFText);

new string[128];
format(string, sizeof(string), "* %s has lost consciousness due to their injuries *", GetNameEx(playerid));
ProxDetector(30.0, playerid, string, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE);
}
}

GetPlayerHealth( playerid, &health ) shouldn't be used in 'if' statement ;)

Dokins
16/02/2015, 04:43 PM
I'll give that a try, thanks!

EDIT: WORKS, THANK YOU!