Radiation Levels - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Radiation Levels (
/showthread.php?tid=514600)
Radiation Levels -
Blindraven14 - 22.05.2014
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.
Re: Radiation Levels -
superrobot48 - 22.05.2014
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
}
}
}
}
Re: Radiation Levels -
gekas - 22.05.2014
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
Re: Radiation Levels -
Blindraven14 - 23.05.2014
Thank you so much. This will help alot.