Код:
public OnPlayerDeath(playerid, killerid, reason)
{
if(indm[playerid] == 1 && indm[killerid] == 1)
{
SetPlayerScore(killerid,GetPlayerScore(killerid)-1);
SendClientMessage(killerid,red,"Dont kill your own men!");
SetPlayerHealth(killerid,0);
return 1;
}
if(indm[playerid] == 2 && indm[killerid] == 2)
{
SetPlayerScore(killerid,GetPlayerScore(killerid)-1);
SendClientMessage(killerid,red,"Dont kill your own men!");
SetPlayerHealth(killerid,0);
return 1;
}
if(indm[killerid] == 1)
{
SetPlayerScore(killerid,GetPlayerScore(killerid)+1);
}
if(indm[killerid] == 2)
{
SetPlayerScore(killerid,GetPlayerScore(killerid)+1);
}
return 1;
}
your code is ok. the only reason why the killerid score wont change, the code is decreasing score 1, then adding 1 again. x-1+1==x ^^
return 1; at each teamkill, coz theres no more reason to add 1 more score for the killer...
edit: ah, the "indm[playerid]==1&&indm[killerid]==1" and "indm[playerid]==2&&indm[killerid]==2" can be combined:
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
if(indm[killerid]==indm[playerid])
{
SetPlayerScore(killerid,GetPlayerScore(killerid)-1);
SendClientMessage(killerid,red,"Dont kill your own men!");
SetPlayerHealth(killerid,0);
return 1;
}
if(indm[killerid] == 1)
{
SetPlayerScore(killerid,GetPlayerScore(killerid)+1);
}
if(indm[killerid] == 2)
{
SetPlayerScore(killerid,GetPlayerScore(killerid)+1);
}
return 1;
}
hm. theres still more place to optimize ^^
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
if(indm[killerid]==indm[playerid])
{
SetPlayerScore(killerid,GetPlayerScore(killerid)-1);
SendClientMessage(killerid,red,"Dont kill your own men!");
SetPlayerHealth(killerid,0);
return 1;
}
if(indm[killerid]>0)
{
SetPlayerScore(killerid,GetPlayerScore(killerid)+1);
}
return 1;
}
hope it works...