13.03.2013, 18:39
(
Last edited by Djole1337; 15/03/2013 at 12:25 PM.
)
Yep. Here's an example:
pawn Code:
// Creating global player var. We'll use it later to check if player has god mode activated.
new
bool: GodMode[MAX_PLAYERS char];
// Our timer
static
GodTimer;
pawn Code:
// Simple god command
CMD:god(playerid, params[])
{
if (!IsPlayerAdmin(playerid)) // Fixed typo
return SendClientMessage(playerid, -1, "Nope.");
GodMode{playerid} = !GodMode{playerid};
SendClientMessage(playerid, -1, GodMode{playerid} ? ("God Mode activated!") : ("God Mode disabled!"));
return 1;
}
pawn Code:
// Now we're gonna create 2 secs timer to check if player has god mode activated and fix their health.
// 2 secs timer is ok so don't worry, it's not gonna lag.
forward GodModeCheck();
public GodModeCheck()
{
foreach(new i : Player)
{
if (GodMode{i} == true)
{
SetPlayerHealth(i, 100); // No need for 1k
}
}
return 1;
}
// Now we're gonna place under OnGameModeInit()
public OnGameModeInit()
{
GodTimer = SetTimer("GodModeCheck", 1000, true); // 1 sec timer.
return 1;
}
public OnGameModeExit()
{
KillTimer(GodTimer);
return 1;
}