This just gets all the server injured
#1

Well I made a code to make you injured on death (mainly for RP) instead of going to hospital.. But.. it seems to be injuring all the server if only one dies

pawn Код:
// THIS IS THE TIMER!
public AfterDeath()
{

   for(new i=0;i<MAX_PLAYERS;i++)
    {
        SetPlayerPos(i, DeathPosX[i], DeathPosY[i], DeathPosZ[i]);
        ApplyAnimation(i,"CRACK","crckdeth1",4.1,1,1,1,1,1,1);
        GameTextForPlayer(i, "~r~Injured~n~~w~Please Call the EMS /service EMS", 5000, 3);
        new Float:HISCHP;
        GetPlayerHealth(i, HISCHP);
        SetPlayerHealth(i, HISCHP-5);
        if(HISCHP < 12.0)
        {
          PlayerInfo[i][pHospital] = 1;
          KillTimer(death_timer[i]);
          SetPlayerSpawn(i);
        }

    }
   return 1;
}
This is how i call it
pawn Код:
if(newstate == PLAYER_STATE_WASTED) //PLAYER DIES
    {
        if(PlayerInfo[playerid][pJailed] == 0)
        {

 
                           new Float:DX;
               new Float:DY;
               new Float:DZ;
               GetPlayerPos(playerid, DX, DY, DZ);
               DeathPosX[playerid] = DX;
                           DeathPosY[playerid] = DY;
                           DeathPosZ[playerid] = DZ;

             death_timer[playerid] = SetTimer("AfterDeath", 7000, 1);


           
        }
    }
Reply
#2

Obviously your going to have this problem if your looping through all players and running this code on them if they are dead or not.

You need to remove the loop and make it

pawn Код:
public AfterDeath(playerid)
{
       SetPlayerPos(playerid, DeathPosX[playerid], DeathPosY[playerid], DeathPosZ[playerid]);
        ApplyAnimation(playerid,"CRACK","crckdeth1",4.1,1,1,1,1,1,1);
}
Reply
#3

use SetTimerEx and remake ur public to public AfterDeath(playerid) and without loop.
Reply
#4

Here you go, just copy and paste:

http://paste.laravel.com/tKV

You looped all player IDs, therefore all players take effect.
Reply
#5

Quote:
Originally Posted by Lorenc_
Посмотреть сообщение
Here you go, just copy and paste:

http://paste.laravel.com/tKV

You looped all player IDs, therefore all players take effect.
Very unexpected to see you answering back in my posts Lorenc...

Thanks anyways
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)