OnPlayerDeath (+Rep)
#1

My Code isn't working and I have no idea why. Help me out

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new st[128],str[128],name[MAX_PLAYER_NAME], Killername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    GetPlayerName(killerid,Killername,sizeof(Killername));
    PlayerInfo[playerid][pArm] = 0;
    PlayerInfo[playerid][pHP] = 0;
    SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
    GivePlayerCash(killerid, 2500);
    PlayerInfo[killerid][pKills]+= 1;
    PlayerInfo[killerid][pStreak]+= 1;
    PlayerInfo[playerid][pStreak] = 0;
    PlayerInfo[playerid][pDeaths] += 1;
    Delete3DTextLabel(Killer[playerid]);
    SendDeathMessage(killerid,playerid,reason);
    SetPlayerWantedLevel(playerid,0);
    LooseWeapons(playerid);
    {
        if(gTeam[killerid] == gTeam[playerid]) {
            GameTextForPlayer(killerid, "~r~DON'T TEAMKILL!",5000,5);
            PlayerInfo[killerid][pTeamKill]+= 1;
            GivePlayerCash(killerid, -5000);
            GivePlayerCash(playerid, 5000);
            }
        if(PlayerInfo[killerid][pTeamKill] == 2) {
            SendClientMessage(killerid,COLOR_YELLOW,"Don't Team Kill! (Warning 1/3).");
            }
        if(PlayerInfo[killerid][pTeamKill] == 3) {
            SendClientMessage(killerid,COLOR_YELLOW,"You're being jailed for 2 minutes for constant team killing. ");
            TogglePlayerControllable(killerid, 0);
            Punishment(killerid, 120);
            }
        if(PlayerInfo[killerid][pTeamKill] == 4) {
            format(st, sizeof(st), "SERVER: %s Is Kicked For Team Killing.", Killername);
            SendClientMessageToAll(COLOR_LIGHTRED, st);
            PlayerInfo[killerid][pTeamKill] = 0;
            Kick(killerid);
            }
            if(InDual[playerid] == 1)
            {
            InDual[playerid] = 0;
            InDual[killerid] = 0;
            format(st, sizeof(st), "%s Beat %s In A Duel And Won $%d", Killername, name, DualRoomprice);
            SendClientMessageToAll(COLOR_YELLOW, st);
            GivePlayerCash(killerid, (DualRoomprice*2));
            SpawnPlayer(killerid);
            SendDeathMessage(killerid, playerid, reason);
            }
            if(PlayerInfo[playerid][pStreak] >= 50) {
            format(st,sizeof(st),"~P~ %s Has Killed %s",Killername,name);
            GameTextForAll(st,5500,5);
            GivePlayerCash(killerid, 20000);
            }
            if(PlayerInfo[killerid][pStreak] == 5) {
                format(st,sizeof(st),"~W~%s HAS A KILL STREAK OF 5!",Killername);
                PlayerInfo[killerid][pArm] = 0;
                PlayerInfo[killerid][pHP] = 0;
                SetPlayerWantedLevel(killerid,1);
                GameTextForAll(st,5000,4);
                GivePlayerCash(killerid, 50000);
            }
            if(PlayerInfo[killerid][pStreak] == 10) {
                format(st,sizeof(st),"~W~%s HAS A KILL STREAK OF 10!!",Killername);
                SetPlayerWantedLevel(killerid,2);
                GameTextForAll(st,5000,4);
            }
            if(PlayerInfo[killerid][pStreak] == 15) {
                format(st,sizeof(st),"~W~%s HAS A KILL STREAK OF 15!!!",Killername);
                PlayerInfo[killerid][pArm] = 0;
                PlayerInfo[killerid][pHP] = 0;
                SetPlayerWantedLevel(killerid,3);
                GameTextForAll(st,5000,4);
            }
            if(PlayerInfo[killerid][pStreak] == 20) {
                format(st,sizeof(st),"~W~%s HAS A KILL STREAK OF 20!!!!",Killername);
                GivePlayerCash(killerid, 100000);
                SetPlayerWantedLevel(killerid,4);
                GameTextForAll(st,5000,4);
            }
            if(PlayerInfo[killerid][pStreak] == 25) {
                format(st,sizeof(st),"~W~%s HAS A KILL STREAK OF 25!!!!!",Killername);
                PlayerInfo[killerid][pArm] = 0;
                PlayerInfo[killerid][pHP] = 0;
                SetPlayerWantedLevel(killerid,5);
                GameTextForAll(st,5000,4);
            }
            if(PlayerInfo[killerid][pStreak] == 30) {
                format(st,sizeof(st),"~R~%s HAS A KILL STREAK OF 30!!!!!!",Killername[killerid]);
                GameTextForAll(st,5000,4);
            }
            if(PlayerInfo[killerid][pStreak] == 35) {
                format(st,sizeof(st),"~R~%s HAS A KILL STREAK OF 35!!!!!!",Killername[killerid]);
                PlayerInfo[killerid][pArm] = 0;
                PlayerInfo[killerid][pHP] = 0;
                GivePlayerCash(killerid, 150000);
                SetPlayerWantedLevel(killerid,6);
                GameTextForAll(st,5000,4);
            }
            if(PlayerInfo[killerid][pStreak] == 40) {
                format(st,sizeof(st),"~R~%s HAS A KILL STREAK OF 40!!!!!!",Killername[killerid]);
                GameTextForAll(st,5000,4);
            }
            if(PlayerInfo[killerid][pStreak] == 45) {
                format(st,sizeof(st),"~R~%s HAS A KILL STREAK OF 45!!!!!!",Killername[killerid]);
                SendClientMessage(killerid,COLOR_YELLOW,"Buy better guns! (/shop) be prepared for the 50 kill streak!");
                PlayerInfo[killerid][pArm] = 0;
                PlayerInfo[killerid][pHP] = 0;
                GivePlayerCash(killerid, 1000000);
                PlayerInfo[killerid][pWantedLevel]++;
                GameTextForAll(st,5000,4);
            }
            for(new i=0;i<MAX_PLAYERS;i++)
            if(PlayerInfo[killerid][pStreak] == 50) {
                new Float:X,Float:Y,Float:Z;
                GetPlayerPos(killerid, X,Y,Z);
                SetPlayerPos(i,X+1,Y+1,Z+1);
                format(st,sizeof(st),"~G~%s HAS A KILL STREAK OF 50. KILL THEM",Killername);
                SendClientMessageToAll(COLOR_YELLOW,st);
                format(st,sizeof(st),"~R~ !!!!! KILL %s !!!!!",Killername);
                GameTextForAll(st,5500,5);
                SetPlayerChatBubble(killerid, "** K I L L   M E!! **", COLOR_RED, 100.0, 10000);
                if(gTeam[i]==gTeam[killerid])
                {
                    format(str,sizeof(str),"%s Is on a kill streak! Protect him",Killername);
                    SendClientMessage(i, COLOR_LIGHTBLUE, str);
            }
            if(PlayerInfo[killerid][pStreak]>= 50) {
                new streak = PlayerInfo[killerid][pStreak];
                format(st,sizeof(st),"~R~%s HAS A KILL STREAK OF %d",Killername,streak);
                GameTextForAll(st,5000,4);
            }
            if(PlayerInfo[killerid][pStreak] == 100) {
                new streak = PlayerInfo[killerid][pStreak];
                GivePlayerCash(killerid, 2500000);
                format(st,sizeof(st),"~R~%s HAS A KILL STREAK OF %d",Killername,streak);
                PlayerInfo[killerid][pArm] = 0;
                PlayerInfo[killerid][pHP] = 0;
                GameTextForAll(st,5000,4);



                        }
                    }

                if(joiningevent[playerid] == 1){
        participants--;
        joiningevent[playerid] = 0;
        if(participants == 1){
            foreach(Player, i){
                if(joiningevent[i] == 1){
                    new string[128], player_Name[MAX_PLAYER_NAME];
                    GetPlayerName(i, player_Name, sizeof(player_Name));
                    GivePlayerCash(i, 100000);
                    joiningevent[i] = 0;
                    participants = 0;
                    SetPlayerHealth(i,0.0);
                    SetPlayerInterior(i,0);
                    if(lastman == 1){
                    format(string, sizeof(string), "%s Earned $100,000 For Winning Last Man Standing!", player_Name);
                    SendClientMessageToAll(COLOR_LIGHTBLUE, string);
                    lastman =0;
                    }
                    if(derby == 1){
                    format(string, sizeof(string), "%s Earned $100,000 For Winning The Destruction Derby!", player_Name);
                    SendClientMessageToAll(COLOR_LIGHTBLUE, string);
                    derby = 0;
                    }
                    if(joiningevent[i] == 0){
                    SendClientMessageToAll(COLOR_LIGHTBLUE, "The Event Has Come To An End");
                    }
                }
            }
        }
            }
        }
    return 1;
}
and yes it compiles. just nothing works
Reply
#2

What doesn't works? State your problem.
Reply
#3

ok, nothing works :P at all. although after an events finished it does set your interior back to 0
Reply
#4

pawn Код:
LooseWeapons(playerid);
{
That's wrong.
Reply
#5

i will move that bracket to the bottom then try again?
Reply
#6

LooseWeapons? It's more like ResetPlayerWeapon unless you're using another inc. for that.
Reply
#7

tried that and still, nothing works.

Looseweapons is a funtion that drops the players weapons around the pos that he/she died
Reply
#8

anyone?
Reply
#9

https://sampwiki.blast.hk/wiki/OnPlayerDeath

Check this.

Quote:

Important Note: You MUST check whether killerid equals INVALID_PLAYER_ID before using it in an array, as it will cause the script to stop. See example above.

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)