04.04.2015, 13:30
With the first one, start off by setting a repeating timer under OnGameModeInit, using:
https://sampwiki.blast.hk/wiki/SetTimer
Then in the public, loop through all players
https://sampwiki.blast.hk/wiki/Keywords:Statements#for
Or just use foreach
And check if their health is below etc. 50
https://sampwiki.blast.hk/wiki/GetPlayerHealth
And then set their drunk level.
https://sampwiki.blast.hk/wiki/SetPlayerDrunkLevel
https://sampwiki.blast.hk/wiki/SetTimer
Код:
SetTimer("1SecTimer", 1000, true); /* 1SecTimer - The public we're gonna call 1000 - The time it will take before we call the public in milliseconds, we'll set it to 1 second true - Should it repeat, in this case we want to check his health each second, so true, it should repeat */
https://sampwiki.blast.hk/wiki/Keywords:Statements#for
Код:
for(new i = 0; i < MAX_PLAYERS; i ++) // Calls the code underneath 500 times as "i" { if(IsPlayerConnected(i)) // Check if that number is connected { } }
And check if their health is below etc. 50
https://sampwiki.blast.hk/wiki/GetPlayerHealth
Код:
new Float: HP // Declare "HP" as a float (a number that can hold decimals, like 21.1582) ; GetPlayerHealth(i, HP); // Stores the players health in the HP float if(HP < 50) // If the HP float is set to something lower than 50 { }
https://sampwiki.blast.hk/wiki/SetPlayerDrunkLevel
Код:
if(HP < 50) { SetPlayerDrunkLevel(i, 2000); }