Modified version:
Add This at Top of your GM:
pawn Код:
new Target = -1;
new ColorCase;
new ColorBlip = -1;
That's what you have to add under the Callbacks:
pawn Код:
public OnGameModeInit()
{
SetTimer("ChooseNewHVT", 2000, 0);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
if(playerid == Target) ChooseNewHVT();
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
if(playerid == Target && killerid == INVALID_PLAYER_ID) ChooseNewHVT(), SetPlayerColor(playerid, GetPlayerTeamColor(playerid));
else
{
new string[128], PlayerName[MAX_PLAYER_NAME], KillerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, PlayerName, MAX_PLAYER_NAME);
GetPlayerName(killerid, KillerName, MAX_PLAYER_NAME);
format(string, 128, "[High Value Target] %s (ID:%d) has killed the High Value Target '%s (ID:%d)' !", KillerName, killerid, PlayerName, playerid);
SendClientMessageToAll(COLOR_BLUE, string);
MakePlayerHVT(playerid);
}
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp("/hvt", cmdtext, true))
{
new string[128], PlayerName[MAX_PLAYER_NAME];
GetPlayerName(Target, PlayerName, MAX_PLAYER_NAME);
format(string, 128, "[High Value Target] %s (ID:%d) is the High Value Target! Kill him!", PlayerName, Target);
SendClientMessage(playerid, COLOR_RED, string);
return 1;
}
return 0;
}
Add this at Bottom of your GM:
pawn Код:
forward ChooseNewHVT();
public ChooseNewHVT()
{
new playerid = GetRandomPlayer();
if(playerid == -1) return SetTimer("ChooseNewHVT", 2000, 0);
else return MakePlayerHVT(playerid);
}
forward ChangeColor(playerid);
public ChangeColor(playerid)
{
if(ColorCase == 0) SetPlayerColor(playerid, GetPlayerTeamColor(playerid)), ColorCase++;
else SetPlayerColor(playerid, WHITE), ColorCase = 0;
return 1;
}
stock GetPlayerTeamColor(playerid)
{
if(gTeam[playerid] == TEAM_USA) return GREEN;
else if(gTeam[playerid] == TEAM_CHINA) return YELLOW;
else if(gTeam[playerid] == TEAM_UP) return BLUE;
else if(gTeam[playerid] == TEAM_SAPLA) return RED;
else if(gTeam[playerid] == CLASS_MERC) return PURPLE;
else return WHITE;
}
stock MakePlayerHVT(playerid)
{
new string[128], PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, PlayerName, MAX_PLAYER_NAME);
format(string, 128, "[High Value Target] %s (ID:%d) is now the High Value Target! Kill him!", PlayerName, playerid);
SendClientMessageToAll(COLOR_RED, string);
Target = playerid;
if(ColorBlip != -1) KillTimer(ColorBlip);
ColorBlip = SetTimerEx("ChangeColor", 1000, 1, "d", playerid);
SetPlayerColor(playerid, WHITE);
return 1;
}
stock GetRandomPlayer() // By MadeMan, modified by me.
{
new ConnectedPlayers[MAX_PLAYERS];
new idx;
for(new i=0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
ConnectedPlayers[idx] = i;
idx++;
}
}
if(idx == 0) return -1;
else return ConnectedPlayers[random(idx)];
}
Try it, should work for your colors now.
For more questions, just ask. ^^
Regards,
Jeffry