OnPlayerDeath
#1

Hi SA-MP Community,
I have a problem. When I kill a player it also kills me and all my weapons also go. On my re-spawn the weapons are vanished.
Help me
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{

        if(killerid == INVALID_PLAYER_ID) {
        SendDeathMessage(INVALID_PLAYER_ID,playerid,reason);
        } else {
        if(gTeam[killerid] != gTeam[playerid]) {
            // Valid kill
            SendDeathMessage(killerid,playerid,reason);
            SetPlayerScore(killerid,GetPlayerScore(killerid)+1);
        } else {
            // Team kill
            SendDeathMessage(killerid,playerid,reason);
            SetPlayerHealth(killerid,-250);
            SendClientMessage(killerid,COLOR_BRIGHTRED,"You have killed your team mate and lost 25 HP due to depression of the tragic loss.");
            SendClientMessage(playerid,COLOR_BRIGHTRED,"You were killed by your own team mate! Maybe it was a mistake.");
        }
    }
        for(new i=0; i<19; i++) TextDrawHideForPlayer(playerid,HealthBar[i]);
        new szString[128];
        new string[128];
        new pname[24];
        kills[killerid]++;
        format(szString,sizeof(szString),"Kills :%d",kills[killerid]);
        SendClientMessageToAll(playerid, string);
        TextDrawSetString(Kill_Streak[killerid],szString);
        SetPlayerScore(killerid,GetPlayerScore(killerid) +1);
        KSC1[playerid] = 0;
        NC[playerid] = 0;
        {
            if(GetPlayerScore(killerid) == 3)
            {
                GetPlayerName(killerid, pname, sizeof(pname));
                format(string, sizeof(string), "%s has killed 3 players in a row!", pname);
                SetPlayerScore(killerid, 1);
                GivePlayerMoney(killerid, 300);
                SendClientMessageToAll(COLOR_YELLOW, string);
                SendClientMessage(killerid,COLOR_BLUE,"You got +1 score and +$300 for killing 3 in a row");
                label3[playerid] = Create3DTextLabel("Got 3 kills", 0xE10000FF, 30.0, 40.0, 50.0, 40.0, 0);
                Attach3DTextLabelToPlayer(label3[playerid], playerid, 0.0, 0.0, 0.7);
                return 1;
            }
            if(GetPlayerScore(killerid) == 5)
            {
                GetPlayerName(killerid, pname, sizeof(pname));
                format(string, sizeof(string), "%s has killed 5 players in a row!", pname);
                SendClientMessageToAll(COLOR_YELLOW, string);
                GivePlayerMoney(killerid,500);
                SetPlayerScore(killerid,2);
                SendClientMessage(killerid,COLOR_BLUE,"You earned +2 score and +$500 for killing 5 in a row!");
                label5[playerid] = Create3DTextLabel("Got 5 kills", 0xE10000FF, 30.0, 40.0, 50.0, 40.0, 0);
                Attach3DTextLabelToPlayer(label5[playerid], playerid, 0.0, 0.0, 0.7);
                return 1;
            }
            if(GetPlayerScore(killerid) == 10)
            {
                GetPlayerName(killerid, pname, sizeof(pname));
                format(string, sizeof(string), "%s has killed 10 players in a row!", pname);
                SendClientMessageToAll(COLOR_YELLOW, string);
                GivePlayerMoney(killerid,1000);
                SetPlayerScore(killerid,5);
                SendClientMessage(killerid,COLOR_BLUE,"You earned +5 score and +$1000 for killing 10 in a row!");
                label7[playerid] = Create3DTextLabel("Got 10 kills", 0xE10000FF, 30.0, 40.0, 50.0, 40.0, 0);
                Attach3DTextLabelToPlayer(label7[playerid], playerid, 0.0, 0.0, 0.7);
                return 1;
            }
            if(GetPlayerScore(killerid) == 15)
            {
                GetPlayerName(killerid, pname, sizeof(pname));
                format(string, sizeof(string), "%s has killed 15 players in a row!", pname);
                SendClientMessageToAll(COLOR_YELLOW, string);
                GivePlayerMoney(killerid,1500);
                SetPlayerScore(killerid,8);
                SendClientMessage(killerid,COLOR_BLUE,"You earned +8 score and +$1500 for killing 15 in a row!");
                label13[playerid] = Create3DTextLabel("Got 13 kills", 0xE10000FF, 30.0, 40.0, 50.0, 40.0, 0);
                Attach3DTextLabelToPlayer(label13[playerid], playerid, 0.0, 0.0, 0.7);
                return 1;
            }
            if(GetPlayerScore(killerid) == 25)
            {
                GetPlayerName(killerid, pname, sizeof(pname));
                format(string, sizeof(string), "%s has killed 25 players in a row!", pname);
                SendClientMessageToAll(COLOR_YELLOW, string);
                GivePlayerMoney(killerid,2500);
                SetPlayerScore(killerid,15);
                SendClientMessage(killerid,COLOR_BLUE,"You earned +15 score and +$2500 for killing 25 in a row!");
                label20[playerid] = Create3DTextLabel("Got 25 kills", 0xE10000FF, 30.0, 40.0, 50.0, 40.0, 0);
                Attach3DTextLabelToPlayer(label20[playerid], playerid, 0.0, 0.0, 0.7);
                return 1;
            }
            if(GetPlayerScore(killerid) == 30)
            {
                GetPlayerName(killerid, pname, sizeof(pname));
                format(string, sizeof(string), "%s has killed 30 players in a row!", pname);
                SendClientMessageToAll(COLOR_YELLOW, string);
                GivePlayerMoney(killerid,3000);
                SetPlayerScore(killerid,18);
                SendClientMessage(killerid,COLOR_BLUE,"You earned +18 score and +$3000 for killing 30 in a row!");
                label30[playerid] = Create3DTextLabel("Got 30 kills", 0xE10000FF, 30.0, 40.0, 50.0, 40.0, 0);
                Attach3DTextLabelToPlayer(label30[playerid], playerid, 0.0, 0.0, 0.7);
                SendClientMessage(playerid,0xE10000FF,"You can use /rocket and you will get 2 rackets from rocket launcher");
                return 1;
            }
        }
//===================KILLERID SECTION=====================//
        SetPlayerScore(killerid,GetPlayerScore(killerid)+1);
        GivePlayerMoney(killerid, 500);
        SendClientMessage(killerid,COLOR_GREEN ,"You won ~b~+1 score for killing");
        SendClientMessage(killerid, COLOR_WHITE, "You won ~g~500$ for killing him");
    //===========PLAYERID SECTION=================//
        GivePlayerMoney(playerid, -500);
        SendClientMessage(playerid, COLOR_WHITE, "You lost ~r~-500$ for getting ~r~killed");
        ShowPlayerDialog(playerid, 500, DIALOG_STYLE_LIST, "Classes", "Assault\nSniper\nPilot\nEngineer\nFlameThrower\nDemolition", "Select", "Cancel");
        return 0;
    }
Reply
#2

Код:
SetPlayerHealth(killerid,-250);
Maybe something wrong with your teams?
or then it just doesnt detect it as teamkill and does it anyway, try changing that line to
Код:
SendClientMessage(playerid, 0xFFFFFF,"You killed your friend");
and see if it comes now when you kill an enemy
Reply
#3

i think i saw the problem.
the problem might be here

pawn Код:
SetPlayerHealth(killerid,-250);
i don't know but that might be the problem
Reply
#4

Thnx. It Worked. But what about the weapons?
Reply
#5

Anyways where you actually save the weapons?
Reply
#6

wat do u mean?
Reply
#7

How about get there weapons and restore them back OnPlayerSpawn by SetPVarInt?
i don't know if it works
Reply
#8

oh yeah! anyway can u help me. coz i dont have much time. if not i can do it myself. thnx.
Reply
#9

If im correct, there is an tutorial, search for it (I might remember wrong thought)
Reply
#10

i have to g2g maybe i can help you tomorrow?, after i finish converting my windows movie maker project to avi i need to sleep so maybe tomorrow?, if i cannot help you then sorry
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)