09.11.2009, 04:28
Hello, I need your guys help on this, its been a while since I have scripted for SA:MP as I will make errors lol. Here is the code of what I have so far.. It looked right to me but it has problems in the game. I got it working like once but after I die and spawn again it doesn't work anymore can anyone help me solve this problem? If you have a better code for it please post it I am in need of a godmode on spawn! Thanks for all the support
Код:
new GodModeActive[MAX_PLAYERS];
public OnPlayerSpawn(playerid)
{
GodModeActive[playerid]=1;
PrepareGodMode();
return 1;
}
//---------------------------------------------------------
forward PrepareGodMode();
public PrepareGodMode()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(GodModeActive[i] != 0)
{
SendClientMessage(i, COLOR_YELLOW, "You have god mode for 20 seconds.");
}
}
}
SetTimer("StartGodMode", 1000, 0);
return 1;
}
forward StartGodMode();
public StartGodMode()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(GodModeActive[i] != 0)
{
SetPlayerHealth(i,1000.0);
}
}
}
SetTimer("GodModeEnded", 20000, 0);
return 1;
}
forward GodModeEnded();
public GodModeEnded()
{
new string[256];
new name[MAX_PLAYER_NAME];
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(GodModeActive[i] != 0)
{
if(IsPlayerConnected(i))
{
GetPlayerName(i, name, sizeof(name));
SetPlayerHealth(i,100.0);
format(string,sizeof(string), "** %s godmode has ended.",name);
SendClientMessage(i, COLOR_WHITE, string);
}
GodModeActive[i] = 0;
}
}
}
return 1;
}
}

