Anti Teamkill = ?
#1

How do I make player loose money and score when he teamkill. This is my Teams code.
pawn Код:
public OnPlayerSpawn(playerid)
{
    if(gTeam[playerid] == TEAM_ARMY) {
        SetPlayerInterior(playerid, 0);
        SPP(playerid, 1553.3546, -1675.4446, 16.1953);
        GPW(playerid, 26, 100);
        GPW(playerid, 29, 500);
        GPW(playerid, 30, 300);
        SetPlayerTeam(playerid, 0);
        SetPlayerColor(playerid, COLOR_BLUE);
        }
    if(gTeam[playerid] == TEAM_LSPD) {
        SetPlayerInterior(playerid, 0);
        SPP(playerid, 116.6943, 1933.8201, 18.9704);
        GPW(playerid, 27, 100);
        GPW(playerid, 31, 300);
        GPW(playerid, 35, 2);
        SetPlayerTeam(playerid, 1);
        SetPlayerColor(playerid, COLOR_GREY);
        } // etc etc
pawn Код:
SetPlayerTeamFromClass(playerid, classid)
{
    if(classid == 0)
    {
        gTeam[playerid] = TEAM_ARMY;
        GameTextForPlayer(playerid,"Los Santos Police Department",999999,6);
    }
    else if(classid == 1)
    {
        gTeam[playerid] = TEAM_LSPD;
        GameTextForPlayer(playerid,"Army",999999,6);
    }
and so
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    //This is actually OnPlayerKill
    SetPlayerDrunkLevel(playerid, 0);
    SCM(killerid,COLOR_GREEN, "You have killed someone, you got +$1000 and 1 Score!");// You can replace "someone" with string
    GPM(killerid,1000);
    SetPlayerScore(killerid,GetPlayerScore(killerid)+1);
   
    // This is actually OnPlayerDeath
    SCM(playerid,COLOR_BRIGHTRED, "You died, you lost $500");
    GPM(playerid,-500);
    PlayerInfo[playerid][AdminLevel] = 0;
    if(killerid == INVALID_PLAYER_ID)
    {
        SendDeathMessage(INVALID_PLAYER_ID,playerid,reason);
    }
    else
    {
        SendDeathMessage(killerid,playerid,reason);
    }
    SCM(playerid, COLOR_YELLOW, "You got PWNED");
}
as you can see, i've set to get 1 score for killing an enemy, how can I make loose score for killing teammate, because SetPlayerTeam is bugged sometimes ?
Reply
#2

GivePlayerMoney(killerid, -1000);//Takes 1k
from teamkiller
SetPlayerScore(killerid, GetPlayerScore(killerid) - 1);//Takes 1 Score from teamkiller
Reply
#3

Yea, but how can I make he looses money for teamkill, like If(PlayerTeamKill(playerid); even tho it doesnt exsist, something like that
Reply
#4

Quote:
Originally Posted by <Weponz>
Посмотреть сообщение
Код:
GivePlayerMoney(killerid, -1000);//Takes 1k from teamkiller
Put That Under You Team Killer Code..He Will Lose 1000 Change It..
Reply
#5

pawn Код:
if( gTeam[ playerid ] == gTeam[ killerid ] ) //teamkill

You could also make your own callback, but whats the point?

pawn Код:
forward OnPlayerTeamKill(playerid);
public OnPlayerTeamKill(playerid)
{
        //do stuff for teamkillers
        return true;
}
pawn Код:
if( gTeam[ playerid ] == gTeam[ killerid ] )
        return OnPlayerTeamKill( killerid );
Reply
#6

so, something like
pawn Код:
forward OnPlayerTeamKill(playerid);
public OnPlayerTeamKill(playerid)
{
        GivePlayerMoney(playerid, -1000);
        SCM(playerid, COLOR_BRIGHTRED, "You have teamkilled, you lost 1000 dollars and 2 score");
        SetPlayerScore(playerid,GetPlayerScore(playerid)-2);
        return true;
}
will work ?
Reply
#7

if(gTeam[killerid] == gTeam[playerid]) return GivePlayerMoney(killerid, -1000);
Reply
#8

Quote:
Originally Posted by Gh0sT_
Посмотреть сообщение
if(gTeam[killerid] == gTeam[playerid]) return GivePlayerMoney(killerid, -1000);
With that aren't you saying like if the killerid is the playerid he lose money? i'd make it something like:

pawn Код:
if(gTeam[killerid] == TEAM_LSPD || gTeam[playerid] == TEAM_LSPD) return GivePlayerMoney(killerid, -1000);
else if if(gTeam[killerid] == TEAM_ARMY || gTeam[playerid] == TEAM_ARMY) return GivePlayerMoney(killerid, -1000);
But i may be wrong
Reply
#9

Nevermind, i just did what LarzI said:
if( gTeam[ playerid ] == gTeam[ killerid ] ) //teamkill
and it works, thanks LarzI and others
Reply
#10

Quote:
Originally Posted by Naxix
Посмотреть сообщение
With that aren't you saying like if the killerid is the playerid he lose money? i'd make it something like:

pawn Код:
if(gTeam[killerid] == TEAM_LSPD || gTeam[playerid] == TEAM_LSPD) return GivePlayerMoney(killerid, -1000);
else if if(gTeam[killerid] == TEAM_ARMY || gTeam[playerid] == TEAM_ARMY) return GivePlayerMoney(killerid, -1000);
But i may be wrong
na, my added scripter just checks, are killerid team = playerid team
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)