PDA

View Full Version : Anti-teamkil bug


JokerK
19/05/2014, 11:10 AM
When i kill player other team, anti-teamkill also set my HP to 0
This is my code set team

public SetPlayerTeamFromClass(playerid, classid)
{
if(classid == 0)
{
gTeam[playerid] = TEAM_TRIAF;
GameTextForPlayer(playerid,"~r~ Mafia Group",3000,5); // This will show up an Text , when you select your class
SetPlayerColor(playerid, COLOR_RED);
}
else if(classid == 1)
{
gTeam[playerid] = TEAM_COP;
GameTextForPlayer(playerid,"~b~Cop",3000,5);
SetPlayerColor(playerid, COLOR_BLUE);
}
else if(classid == 2)
{
gTeam[playerid] = TEAM_FBI;
GameTextForPlayer(playerid,"~b~FBI",3000,5); // This will show up an Text , when you select your class

SetPlayerColor(playerid,COLOR_BLUE); // Teamcolor
}
else if(classid == 3)
{
gTeam[playerid] = TEAM_BALLAS;
GameTextForPlayer(playerid,"~p~Ballas",3000,5);
SetPlayerColor(playerid, COLOR_PINK);
}
else if(classid == 4)
{
gTeam[playerid] = TEAM_GROVE;
GameTextForPlayer(playerid,"~g~Grove Street",3000,5); // This will show up an Text , when you select your class
SetPlayerColor(playerid, COLOR_GREEN); // Teamcolor
}
else if(classid == 5)
{
gTeam[playerid] = TEAM_AZC;
GameTextForPlayer(playerid,"~b~Varios Los Aztecas",3000,5);
SetPlayerColor(playerid, COLOR_AQUA);
}
else if(classid == 6)
{
gTeam[playerid] = TEAM_VAGOS;
GameTextForPlayer(playerid,"~y~Vagos",3000,5);
SetPlayerColor(playerid, COLOR_YELLOW);
}
}
And this is my code anti-teamkill

if(gTeam[killerid] == gTeam[playerid])
{
SetPlayerHealth(killerid, 0);
GameTextForPlayer(killerid,"~r~You has been killed by server for Team-killing!",4000,3);
}
return 1;
}

JokerK
19/05/2014, 11:33 AM
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
if(issuerid == INVALID_PLAYER_ID) return 1; // Skip if Damaged player is invalid

new
Text3D:bar3D,
damageStr[HEALTH_LENGTH];

valstr(damageStr, floatround(amount));
bar3D = Create3DTextLabel(damageStr, COLOR_RED, 0.0, 0.0, 0.0, HEALTH_DRAW, 0);
Attach3DTextLabelToPlayer(bar3D, playerid, 0.0, 0.0, HEALTH_OFFSET);
SetTimerEx("UpdateDamageBar", TIME_FIRST, 0, "iiffii", playerid, _:bar3D, amount, HEALTH_OFFSET, 16, COLOR_RED);
return 1;
}
if(IsPlayerConnected(issuerid) && gTeam[issuerid] == gTeam[playerid])
{
new Float:PHP,
Float:IHP;
GetPlayerHealth(playerid, PHP);
GetPlayerHealth(issuerid, IHP);

SetPlayerHealth(playerid, PHP + amount);
SetPlayerHealth(issuerid, IHP - amount);
GameTextForPlayer(issuerid,"~r~Team-killing!",2000,3);
}
return 1;
}
}
C:\Documents and Settings\net\Desktop\TDM server\TDM server\TDM server\samp03z_svr_R1_win32\gamemodes\TDM.pwn(1023 ) : error 010: invalid function or declaration
C:\Documents and Settings\net\Desktop\TDM server\TDM server\TDM server\samp03z_svr_R1_win32\gamemodes\TDM.pwn(1027 ) : error 021: symbol already defined: "GetPlayerHealth"
C:\Documents and Settings\net\Desktop\TDM server\TDM server\TDM server\samp03z_svr_R1_win32\gamemodes\TDM.pwn(1030 ) : error 021: symbol already defined: "SetPlayerHealth"
C:\Documents and Settings\net\Desktop\TDM server\TDM server\TDM server\samp03z_svr_R1_win32\gamemodes\TDM.pwn(1034 ) : error 010: invalid function or declaration
C:\Documents and Settings\net\Desktop\TDM server\TDM server\TDM server\samp03z_svr_R1_win32\gamemodes\TDM.pwn(1057 ) : warning 203: symbol is never used: "IHP"
C:\Documents and Settings\net\Desktop\TDM server\TDM server\TDM server\samp03z_svr_R1_win32\gamemodes\TDM.pwn(1057 ) : warning 203: symbol is never used: "PHP"

JokerK
19/05/2014, 11:51 PM
bump