OnPlayerUpdate
#1

Quote:

if(IsPlayerInWater(playerid)) return SetPlayerHealth(playerid,0.0);

How can i make that a Message come like "Player X has jumped into infected Water and died."?
Reply
#2

You can use GameTextForPlayer(..., or you can create a global bool variable, and do this for instance:

pawn Код:
new bool:is_message_Sent[ MAX_PLAYERS ];

public OnPlayerUpdate( playerid ) {

         if(IsPlayerInWater(playerid)) {

                   SetPlayerHealth(playerid,0.0);
                   if( is_message_Sent[ playerid ] == false ) {

                             SendClientMessage( playerid, 0xFFFFFFFF, "You died." );
                             is_message_Sent[ playerid ] = true;

                             return true;
                   }  
          }
}

public OnPlayerSpawn( playerid ) {

          is_message_Sent[ playerid ] = false;
          return true;
}
Try this if you don't want GameText-s.
Reply
#3

Inside the if statement about if he is in water, get player's name, format a message, send it to all, kill the player and return true.
Reply
#4

Код:
   if(IsPlayerInWater(playerid)) return SetPlayerHealth(playerid,0.0);
    format(str,144,"«| %s Has Jumped Into Infected Water And Died. |»",PlayerName[playerid]);
    SendClientMessageToAll(COLOR_CYAN,str);
Then the Message spammed the full Chat, lol.
Reply
#5

It's probably because IsPlayerInWater keeps returning true.

You will want to do something like this:

Код:
   if(IsPlayerInWater(playerid) && GetPlayerHealth(playerid) > 0.0) {
      SetPlayerHealth(playerid, 0.0);
      format(str,144,"«| %s Has Jumped Into Infected Water And Died. |»",PlayerName[playerid]);
      SendClientMessageToAll(COLOR_CYAN, str);
   }
If that doesn't work you can get really dirty with it and make an array killedInWater[MAX_PLAYERS], and then manually change it to 1 or 0 to ensure the message doesn't show up again, but life is too short for that.
Reply
#6

warning 202: number of arguments does not match definition

On the Line: if(IsPlayerInWater(playerid) && GetPlayerHealth(playerid) > 0.0) {
Reply
#7

new Float:health;
GetPlayerHealth(playerid, health);
if(IsPlayerInWater(playerid) && health > 0.0)
Reply
#8

Thanks, all works now.
Reply
#9

I have a Problem, when a Player the 2 Time or 3 Time, goto Water and die, the Message "Has Jumped Into Infected Water And Died" spammed.

Код:
         if(IsPlayerInWater(playerid))  {
      SetPlayerHealth(playerid, 0.0);
      format(str,144,"«| %s Has Jumped Into Infected Water And Died.|»",PlayerName[playerid]);
      SendClientMessageToAll(COLOR_CYAN, str);
How to fix that?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)