Quote:
Originally Posted by Sew_Sumi
Very simple code man... Many examples of it in the server package.
This was whipped up from scratch. Made it as a Filterscript.
PHP код:
#include <a_samp>
new Team1Kills, Team2Kills, RoundTime, RoundStatus; // First 2 variables were what ItsCody was talking about. The latter 2 are ones for the time of the round, and one to check the status of it.
public OnPlayerDeath(playerid, killerid)
{
if(RoundStatus==0) return 1; // We don't want to count crap outside of the rounds
if(killerid == INVALID_PLAYER_ID) return 1; //If it was falling damage we don't want it either. (Could be exploited though by denying enemy of kills)
if(GetPlayerTeam(killerid)==GetPlayerTeam(playerid)) return 1; //No TK counting as a "kill". (Could also be exploited by someone TKing to save their team from the kill)
if(GetPlayerTeam(killerid)==1)
{
Team1Kills++;
}
if(GetPlayerTeam(killerid)==2)
{
Team2Kills++;
}
return 1;
}
forward Tick();
public Tick()
{
if(RoundTime<0) return 1; //If rounds are disabled via the command, we don't need to check anything.
RoundTime++;
if(RoundTime<10 && RoundStatus!=0) //If round just finished, and will be starting again
{
SendClientMessageToAll(-1, "Round will restart shortly.");
RoundStatus=0;
}
if(RoundTime>10 && RoundStatus==0) //If round is to begin
{
RoundStatus=1;
SendClientMessageToAll(-1, "Round started.");
Team1Kills = 0;
Team2Kills = 0;
}
if(RoundTime>620 && RoundStatus==1) //If round should be finishing. 600 = 10 minutes.
{
RoundTime = 0; // Change this to -1 or less to make the rounds not auto restart.
new string[30];
format(string, sizeof(string), "Team 1 :%i | Team 2 :%i", Team1Kills, Team2Kills);
SendClientMessageToAll(-1,string);
if(Team1Kills>Team2Kills) return SendClientMessageToAll(-1, "Team 1 won the round.");
if(Team1Kills<Team2Kills) return SendClientMessageToAll(-1, "Team 2 won the round.");
if(Team1Kills==Team2Kills) return SendClientMessageToAll(-1, "Teams drew.");
}
return 1;
}
public OnFilterScriptInit()
{
SetTimer("Tick", 1000, true);
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext, "/beginround", true) == 0)
{
SendClientMessage(playerid, -1, "Rounds enabled.");
RoundTime=0;
RoundStatus=1;
return 1;
}
if(strcmp(cmdtext, "/stopround", true) == 0)
{
SendClientMessage(playerid, -1, "Rounds disabled.");
RoundTime=-5;
return 1;
}
return 0;
}
|
thank you,
but I'm having a problem, because in my toc I add
Red team:
Код:
SetPlayerColor (playerid, Color_Red);
SetPlayerTeam (playerid, 501);
and the Green team
Код:
SetPlayerColor (playerid, 0x00FF00FF);
SetPlayerTeam (playerid, 502);
The green team can not make team killing
The red team can not make teamkilling,
the problem is that if I add in TDM1
in team Red
Код:
if(GetPlayerTeam(killerid)==1)
{
Team1Kills++;
}
and, in team green
Код:
if(GetPlayerTeam(killerid)==2)
{
Team2Kills++;
}
this will make confusion with my 10 TDM, who possessed the same value
TEAM DEATH MATCH 2
team Red
Код:
if(GetPlayerTeam(killerid)==1)
{
Team1Kills++;
}
and, team green
Код:
if(GetPlayerTeam(killerid)==2)
{
Team2Kills++;
}