Radiation Levels
#1

I was wondering if someone could help me out by making a code for radiation levels and when they get to 100, you start to lose health.
Reply
#2

Sure first add this at top :
pawn Код:
radlevel[MAX_PLAYERS]; // Setting a var to store radiation level
forward radcheck(); // forwarding timer
then on OnGameModeInit
pawn Код:
SetTimer("radcheck", 5000, false); // Set a timer of 5000 miliseconds (5 seconds)
then add this where ever you want to increase player's radiation level
pawn Код:
radlevel[playerid] +5; // the 5 is the value u want to increase change it if you want
then add this at bottom or somewhere
pawn Код:
public radcheck()
{
    for(new i = 0; i < MAX_PLAYERS; i++) //looping through player
    {
        if(IsPlayerConnected(i)) //checking if player is connected
        {
              if(radlevel[i] > 100) //checking if player has 100 radiation level
              {
               new Float:health;
               GetPlayerHealth(i,health);
               SetPlayerHealth(i,health-5) // reducing health!! at the rate of 5 HP per 5 seconds
               }
       }
    }
}
Reply
#3

Quote:
Originally Posted by superrobot48
Посмотреть сообщение
Sure first add this at top :
pawn Код:
radlevel[MAX_PLAYERS]; // Setting a var to store radiation level
forward radcheck(); // forwarding timer
then on OnGameModeInit
pawn Код:
SetTimer("radcheck", 5000, false); // Set a timer of 5000 miliseconds (5 seconds)
then add this where ever you want to increase player's radiation level
pawn Код:
radlevel[playerid] +5; // the 5 is the value u want to increase change it if you want
then add this at bottom or somewhere
pawn Код:
public radcheck()
{
    for(new i = 0; i < MAX_PLAYERS; i++) //looping through player
    {
        if(IsPlayerConnected(i)) //checking if player is connected
        {
              if(radlevel[i] > 100) //checking if player has 100 radiation level
              {
               new Float:health;
               GetPlayerHealth(i,health);
               SetPlayerHealth(i,health-5) // reducing health!! at the rate of 5 HP per 5 seconds
               }
       }
    }
}
This is
Reply
#4

Thank you so much. This will help alot.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)