Problem with OnPlayerUpdate
#1

(Sorry my english)

Hello, i use a code for when a players health is lower than 20 he gets animation Crack and the server says a message to him.

This message says every seconds and its flood.

Код:
public OnPlayerUpdate(playerid)
{
	new Float:fHealth;

	GetPlayerHealth(playerid, fHealth);

	if(fHealth < 20)
	{
	  // Player health has changed since the last update -> server, so obviously thats the thing updated.
	  // Lets do further checks see if he's lost or gained health, anti-health cheat? ;)

	  if(fHealth < 20)
	  {
		  ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0); // Dieing of Crack
	    SendClientMessage(playerid, COLOR_RED, "(ATENCIУN) Estбs muy herido, caes al suelo desplomado.");
	    SendClientMessage(playerid, COLOR_YELLOW, "(INFORMACIУN) Se ha llamado a los servicios de emergencia.");
      new name[MAX_PLAYER_NAME], string[48];
      GetPlayerName(playerid, name, sizeof(name));
	    format(string, sizeof(string), "(CIUDADANO HERIDO) El ciudadano (%s) estб gravemente herido",name);
		  SendFactionMessage(12, COLOR_LSPD, string);
		  SendFactionMessage(0, COLOR_LSPD, string);
		  SendFactionMessage(8, COLOR_LSPD, string);
		  SendFactionMessage(11, COLOR_LSPD, string);
		  SendFactionMessage(4, COLOR_LSPD, string);
	  }
	  else
	  {
	    //
	  }
	}
	return 0;
}
Please help me thanks
Reply
#2

make a new global variable for every player, then set it to true in your onplayerupdate script, and there do a check if it is true or false... don;t forget to reset it when player leaves.
Reply
#3

Sorry i dont understand... im spanish...

Can you give me a code please?
Reply
#4

pawn Код:
new globalvariable[MAX_PLAYERS];

public OnPlayerConnect(playerid){
    globalvariable[playerid] = 1;
    return 1;
}
public OnPlayerDisconnect(playerid){
    globalvariable[playerid] = 1;
    return 1;
}
public OnPlayerSpawn(playerid){
    globalvariable[playerid] = 1;
    SetTimerEx("ResetVar",1000,0,"i",playerid);
    return 1;
}
public OnPlayerDeath(playerid,killerid,reason){
    globalvariable[playerid] = 1;
    return 1;
}

forward ResetVar(playerid);
public ResetVar(playerid){
    globalvariable[playerid] = 0;
    return 1;
}

public OnPlayerUpdate(playerid)
{

    if(!globalvar[playerid])
    {
      new Float:fHealth;
      GetPlayerHealth(playerid, fHealth);
      if(fHealth < 20)
      {
          globalvar[playerid] = 1;
          ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0); // Dieing of Crack
        SendClientMessage(playerid, COLOR_RED, "(ATENCIУN) Estбs muy herido, caes al suelo desplomado.");
        SendClientMessage(playerid, COLOR_YELLOW, "(INFORMACIУN) Se ha llamado a los servicios de emergencia.");
      new name[MAX_PLAYER_NAME], string[48];
      GetPlayerName(playerid, name, sizeof(name));
        format(string, sizeof(string), "(CIUDADANO HERIDO) El ciudadano (%s) estб gravemente herido",name);
          SendFactionMessage(12, COLOR_LSPD, string);
          SendFactionMessage(0, COLOR_LSPD, string);
          SendFactionMessage(8, COLOR_LSPD, string);
          SendFactionMessage(11, COLOR_LSPD, string);
          SendFactionMessage(4, COLOR_LSPD, string);
      }
      else
      {
        //
      }
    }
    return 0;
}
Reply
#5

Thanks, testing...
Reply
#6

You have a error in your code using globalvar in OnPlayerUpdate, is globalvariable... but thanks it works fine
Reply
#7

men.... high bug, any player loss health.... lol??

any fix?
Reply
#8

help me please, any player loss health and all see AFK, but not AFK :S
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)