OnPlayerDeath Problem
#1

Hello everyone i have an problem with OnPlayerDeath

I have add to it when player die show mee a Print, textdraw , death message.
when someone else kill mee they works
When i use /kill SetPlayerHealth 0 and /slap It wont show mee nothing
whats wrong here ? Thanks
Reply
#2

Show us your codes.
Reply
#3

PHP код:
public OnPlayerDeath(playeridkilleridreason)
{
    for(new 
i;i<=MAX_PLAYERS;i++)
    {
        if(
Tdamage[i][playerid]>=20.0)
        {
            
assist[i]++;
            
GivePlayerXP(playerid,5);
        }
    }
    if(
team[playerid] == TEAM_ZOMBIE)
    {
        switch(
GetPlayerWeapon(playerid))
        {
            case 
45:
            {
                new 
reasonillegalweapons[128];
                new 
Admin[24] = "Anti-cheat";
                
format(reasonillegalweapons,sizeof(reasonillegalweapons),"Weapon hack %i",GetPlayerWeapon(playerid));
                
BanPlayer(playerid,reasonillegalweapons,Admin);
            }
            case 
9:
            {
                if(
GetDistanceBetweenPlayers(playerid,killerid) >= 10.0)
                {
                    
printf("%s has been kicked for fake killing - On Player Death"PlayerName(playerid));
                    
//Kick(playerid);
                
}
            }
            case 
1,2,3,4,5,6,7,8,10,11,12,13,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34:
            {
                
pInfo[playerid][pFakeKills] += 1;
            }
        }
        if(
pInfo[playerid][pLadders] >= 5)
        {
            
SendClientMessage(playerid,COLOR_RED,"You have been banned for fake killing");

            
pInfo[playerid][pBanned] = 1;

            new 
Admin[24] = "Anti-cheat-FakeKills";
            new 
reasonFake[128] = "Fake Killing - On Player Death - FakeKills";
            
BanPlayer(playerid,reasonFake,Admin);
        }

    }

    if(
pInfo[playerid][pDeaths] >= 10000000 && pInfo[playerid][pKills] == 0)
    {
        new 
Admin[24] = "Anti-cheat";
        new 
reason3[128] = "Fake Killing - On Player Death";
        
BanPlayer(playerid,reason3,Admin);

        
pInfo[killerid][pKills] -= 20;
        
pInfo[playerid][Killstreak] = 0;
        
pInfo[killerid][pCoins] -= 4;

        switch(
Map[XPType])
        {
            case 
1:
            {
                
pInfo[killerid][pXP] -= 300;
            }
            case 
2:
            {
                
pInfo[killerid][pXP] -= 500;
            }
            case 
3:
            {
                
pInfo[killerid][pXP] -= 700;
            }
            case 
4:
            {
                
pInfo[killerid][pXP] -= 900;
            }
            case 
5:
            {
                
pInfo[killerid][pXP] -= 1100;
            }
            case 
6:
            {
                
pInfo[killerid][pXP] -= 1300;
            }
            case 
7:
            {
                
pInfo[killerid][pXP] -= 1500;
            }
            case 
8:
            {
                
pInfo[killerid][pXP] -= 1700;
            }
            case 
9:
            {
                
pInfo[killerid][pXP] -= 1900;
            }
            case 
10:
            {
                
pInfo[killerid][pXP] -= 2100;
            }
        }
    }

    if(
pInfo[playerid][pLogged] == 1)
    {
        new 
string[256],gunname[32];
        
SendDeathMessage(killeridplayeridreason);
        
playersAliveCount--;

        
pInfo[playerid][pDeaths]++;
        
pInfo[playerid][Killstreak] = 0;

        if(
IsBeingSpeced[playerid] == 1)//If the player being spectated, dies, then turn off the spec mode for the spectator.
        
{
            foreach(
Player,i)
            {
                if(
spectatorid[i] == playerid)
                {
                    
TogglePlayerSpectating(i,false);// This justifies what's above, if it's not off then you'll be either spectating your connect screen, or somewhere in blueberry (I don't know why)
                    
if(team[i] == TEAM_HUMAN)
                    {
                        
HumanSetup(i);
                        
SpawnPlayer(i);
                    }
                    else if(
team[i] == TEAM_ZOMBIE)
                    {
                        
ZombieSetup(i);
                        
SpawnPlayer(i);
                    }
                }
            }
        }

        if(
pInfo[playerid][IsPlayerInfected] == 1)
        {
            
ZombieSetup(playerid);
            
CurePlayer(playerid);
        }

        if(
team[playerid] == TEAM_HUMAN)
        {
            
ZombieSetup(playerid);
        }

        
pInfo[killerid][pKills]++;
        
pInfo[killerid][Killstreak]++;
        
pInfo[playerid][pDeaths]++;
        
pInfo[killerid][pKillsIn1Map]++;
        
pInfo[playerid][Killstreak] = 0;

        switch(
Map[XPType])
        {
            case 
1:
            {
            switch(
random(2))
            {
                case 
0GivePlayerXP(killerid,10);
                 case 
1GivePlayerXP(killerid,20);
            }
            }
            case 
2:
            {
            switch(
random(2))
            {
                case 
0GivePlayerXP(killerid,20);
                case 
1GivePlayerXP(killerid,30);
            }
            }
            case 
3:
            {
            switch(
random(2))
            {
                case 
0GivePlayerXP(killerid,30);
                case 
1GivePlayerXP(killerid,40);
            }
            }
            case 
4:
            {
            switch(
random(2))
            {
                case 
0GivePlayerXP(killerid,40);
                 case 
1GivePlayerXP(killerid,50);
            }
            }
            case 
5:
            {
            switch(
random(2))
            {
                 case 
0GivePlayerXP(killerid,50);
                case 
1GivePlayerXP(killerid,60);
            }
            }
            case 
6:
            {
            switch(
random(2))
            {
                  case 
0GivePlayerXP(killerid,60);
                case 
1GivePlayerXP(killerid,70);
            }
            }
            case 
7:
            {
            switch(
random(2))
            {
                case 
0GivePlayerXP(killerid,70);
                 case 
1GivePlayerXP(killerid,80);
            }
            }
            case 
8:
            {
            switch(
random(2))
            {
                case 
0GivePlayerXP(killerid,80);
                 case 
1GivePlayerXP(killerid,90);
            }
            }
            case 
9:
            {
            switch(
random(2))
            {
                case 
0GivePlayerXP(killerid,90);
                 case 
1GivePlayerXP(killerid,100);
            }
            }
            case 
10:
            {
            switch(
random(2))
            {
                case 
0GivePlayerXP(killerid,100);
                 case 
1GivePlayerXP(killerid,110);
            }
            }
        }

        if(
pInfo[killerid][pVipLevel] >= 1)
        {
            switch(
Map[XPType])
            {
                case 
1:
                {
                    switch(
random(2))
                    {
                        case 
0GivePlayerXP(killerid,15),GameTextForPlayer(killerid,"~n~~n~~n~~n~~n~~w~+15 X 2 XP",3500,5);
                        case 
1GivePlayerXP(killerid,25),GameTextForPlayer(killerid,"~n~~n~~n~~n~~n~~w~+25 X 2 XP",3500,5);
                    }
                }

                case 
2:
                {
                    switch(
random(2))
                    {
                        case 
0GivePlayerXP(killerid,25),GameTextForPlayer(killerid,"~n~~n~~n~~n~~n~~w~+25 X 3 XP",3500,5);
                        case 
1GivePlayerXP(killerid,35),GameTextForPlayer(killerid,"~n~~n~~n~~n~~n~~w~+35 X 3 XP",3500,5);
                    }
                }

                case 
3:
                {
                    switch(
random(2))
                    {
                        case 
0GivePlayerXP(killerid,35),GameTextForPlayer(killerid,"~n~~n~~n~~n~~n~~w~+35 X 3 XP",3500,5);
                        case 
1GivePlayerXP(killerid,45),GameTextForPlayer(killerid,"~n~~n~~n~~n~~n~~w~+45 X 3 XP",3500,5);
                    }
                }
                case 
4:
                {
                    switch(
random(2))
                    {
                        case 
0GivePlayerXP(killerid,45),GameTextForPlayer(killerid,"~n~~n~~n~~n~~n~~w~+45 X 3 XP",3500,5);
                        case 
1GivePlayerXP(killerid,55),GameTextForPlayer(killerid,"~n~~n~~n~~n~~n~~w~+55 X 3 XP",3500,5);
                    }
                }
                case 
5:
                {
                    switch(
random(2))
                    {
                        case 
0GivePlayerXP(killerid,55),GameTextForPlayer(killerid,"~n~~n~~n~~n~~n~~w~+55 X 3 XP",3500,5);
                        case 
1GivePlayerXP(killerid,65),GameTextForPlayer(killerid,"~n~~n~~n~~n~~n~~w~+65 X 3 XP",3500,5);
                    }
                }
                case 
6:
                {
                    switch(
random(2))
                    {
                        case 
0GivePlayerXP(killerid,65),GameTextForPlayer(killerid,"~n~~n~~n~~n~~n~~w~+65 X 3 XP",3500,5);
                        case 
1GivePlayerXP(killerid,75),GameTextForPlayer(killerid,"~n~~n~~n~~n~~n~~w~+75 X 3 XP",3500,5);
                    }
                }
                case 
7:
                {
                    switch(
random(2))
                    {
                        case 
0GivePlayerXP(killerid,75),GameTextForPlayer(killerid,"~n~~n~~n~~n~~n~~w~+75 X 3 XP",3500,5);
                        case 
1GivePlayerXP(killerid,85),GameTextForPlayer(killerid,"~n~~n~~n~~n~~n~~w~+85 X 3 XP",3500,5);
                    }
                }
                case 
8:
                {
                    switch(
random(2))
                    {
                        case 
0GivePlayerXP(killerid,85),GameTextForPlayer(killerid,"~n~~n~~n~~n~~n~~w~+85 X 3 XP",3500,5);
                        case 
1GivePlayerXP(killerid,95),GameTextForPlayer(killerid,"~n~~n~~n~~n~~n~~w~+95 X 3 XP",3500,5);
                    }
                }
                case 
9:
                {
                    switch(
random(2))
                    {
                        case 
0GivePlayerXP(killerid,95),GameTextForPlayer(killerid,"~n~~n~~n~~n~~n~~w~+95 X 3 XP",3500,5);
                        case 
1GivePlayerXP(killerid,105),GameTextForPlayer(killerid,"~n~~n~~n~~n~~n~~w~+105 X 3 XP",3500,5);
                    }
                }
                case 
10:
                {
                    switch(
random(2))
                    {
                        case 
0GivePlayerXP(killerid,105),GameTextForPlayer(killerid,"~n~~n~~n~~n~~n~~w~+105 X 3 XP",3500,5);
                        case 
1GivePlayerXP(killerid,115),GameTextForPlayer(killerid,"~n~~n~~n~~n~~n~~w~+115 X 3 XP",3500,5);
                    }
                }
            }
        }

        if(
team[killerid] == TEAM_ZOMBIE)
        {
            if(
reason == 9)
            {
                
ZombieSetup(playerid);
            }
        }


        
KillTimer(pInfo[playerid][IsPlayerInfectedTimer]);
        
GetWeaponName(reason,gunname,sizeof(gunname));
        
TextDrawShowForPlayer(killeridTextdrawiKilled[killerid]);
        
format(string,sizeof(string),"~w~YOU HAVE KILLED~r~ %s~w~ WITH A %s",PlayerName(playerid),gunname);
        
TextDrawSetString(iKilled[killerid],string);
        
TextDrawShowForPlayer(killeridiKilled[killerid]);
        
SetTimerEx("HideiKilled"30000"i"killerid);


        
           if(
killerid != INVALID_PLAYER_ID)
        {
            if(
IsPlayerConnected(killerid))
            {
                
TextDrawShowForPlayer(playeridTextdrawiKilled[playerid]);
                
format(string,sizeof(string),"~w~YOU HAVE BEEN KILLED BY ~r~ %s~w~ WITH %s",PlayerName(killerid),gunname);
                
TextDrawSetString(iKilled[playerid],string);
                
TextDrawShowForPlayer(playeridiKilled[playerid]);
                
SetTimerEx("HideiKilled"30000"i"playerid);

            }
            else
            {
                
format(string,sizeof(string),PlayerName(playerid),gunname);
                
TextDrawSetString(iKilled[killerid], "~w~YOU DIED...");
                
TextDrawShowForPlayer(playeridiKilled[playerid]);
                
SetTimerEx("HideiKilled"30000"i"playerid);
            }
        }

        if(
killerid != INVALID_PLAYER_ID)
        {
            if(!
PlayerShotPlayer[killerid][playerid])
            {
                new 
Admin[24] = "Anti-cheat";
                new 
reason3[128] = "Fake Killing";
                
BanPlayer(playerid,reason3,Admin);
            }
        }

        foreach(
Player,i)
        {
            
PlayerShotPlayer[i][playerid] = 0;
        }
        new 
Float:x,Float:y,Float:z;

        if(
team[playerid] == TEAM_ZOMBIE)
        {
        
GetPlayerPos(playerid,Float:x,Float:y,Float:z);
        
meatDrops[playerid] = CreatePickup(2804,19,Float:x,Float:y,Float:z,0);
        }
        if(
pInfo[playerid][pZombieClass] == BOOMERZOMBIE)
            {
                
GetPlayerPos(playerid,Float:x,Float:y,Float:z);
                
CreateExplosion(Float:x,Float:y,Float:z,0,6.0);

                foreach(
Player,i)
                {
                    
GetClosestPlayer(i);
                    if(
IsPlayerConnected(i))
                    {
                        switch(
GetPlayerSkin(i))
                        {
                            case 
NON_IMMUNE:
                            {
                                if(
IsPlayerInRangeOfPoint(i,7.0,Float:x,Float:y,Float:z))
                                {
                                    if(
pInfo[i][IsPlayerInfected] == 0)
                                    {
                                        if(
pInfo[i][pAdminDuty] == 0)
                                        {
                                            
InfectPlayerStandard(i);
                                        }
                                        else if(
pInfo[i][pAdminDuty] == 1)
                                        {
                                            
SendClientMessage(playerid,COLOR_RED,"That player can't be infected because is on admin duty!");
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

    new 
kstring[256];
     switch(
pInfo[killerid][Killstreak])
        {
            case 
5format(kstring,sizeof(kstring),""chat""COL_PINK" %s has achieved a 5 killstreak "COL_WHITE"(+50 XP) (1 Coin)",PlayerName(killerid)), SendClientMessageToAll(-1,kstring), pInfo[killerid][pXP] += 50,pInfo[killerid][pCoins] += 1;
            case 
10format(kstring,sizeof(kstring),""chat""COL_PINK" %s has achieved a 10 killstreak "COL_WHITE"(+80 XP) (2 Coins)",PlayerName(killerid)), SendClientMessageToAll(-1,kstring), pInfo[killerid][pXP] += 80,pInfo[killerid][pCoins] += 2;
            case 
15format(kstring,sizeof(kstring),""chat""COL_PINK" %s has achieved a 15 killstreak "COL_WHITE"(+100 XP) (3 Coins)",PlayerName(killerid)), SendClientMessageToAll(-1,kstring), pInfo[killerid][pXP] += 100,pInfo[killerid][pCoins] += 3;
            case 
20format(kstring,sizeof(kstring),""chat""COL_PINK" %s has achieved a 20 killstreak "COL_WHITE"(+150 XP) (4 Coins)",PlayerName(killerid)), SendClientMessageToAll(-1,kstring), pInfo[killerid][pXP] += 150,pInfo[killerid][pCoins] += 4;
            case 
25format(kstring,sizeof(kstring),""chat""COL_PINK" %s has achieved a 25 killstreak "COL_WHITE"(+200 XP) (5 Coins)",PlayerName(killerid)), SendClientMessageToAll(-1,kstring), pInfo[killerid][pXP] += 200,pInfo[killerid][pCoins] += 5;
            case 
30format(kstring,sizeof(kstring),""chat""COL_PINK" %s has achieved a 30 killstreak "COL_WHITE"(+250 XP) (6 Coins)",PlayerName(killerid)), SendClientMessageToAll(-1,kstring), pInfo[killerid][pXP] += 250,pInfo[killerid][pCoins] += 6;
            case 
35format(kstring,sizeof(kstring),""chat""COL_PINK" %s has achieved a 35 killstreak "COL_WHITE"(+350 XP) (7 Coins)",PlayerName(killerid)), SendClientMessageToAll(-1,kstring), pInfo[killerid][pXP] += 350,pInfo[killerid][pCoins] += 7;
            case 
40format(kstring,sizeof(kstring),""chat""COL_PINK" %s has achieved a 40 killstreak "COL_WHITE"(+500 XP) (8 Coins)",PlayerName(killerid)), SendClientMessageToAll(-1,kstring), pInfo[killerid][pXP] += 500,pInfo[killerid][pCoins] += 8;
            case 
45format(kstring,sizeof(kstring),""chat""COL_PINK" %s has achieved a 45 killstreak "COL_WHITE"(+600 XP) (9 Coins)",PlayerName(killerid)), SendClientMessageToAll(-1,kstring), pInfo[killerid][pXP] += 600,pInfo[killerid][pCoins] += 9;
            case 
50format(kstring,sizeof(kstring),""chat""COL_PINK" %s has achieved a 50 killstreak "COL_WHITE"(+800 XP) (10 Coins)",PlayerName(killerid)), SendClientMessageToAll(-1,kstring), pInfo[killerid][pXP] += 800,pInfo[killerid][pCoins] += 10;
            case 
55format(kstring,sizeof(kstring),""chat""COL_PINK" %s has achieved a 55 killstreak "COL_WHITE"(+950 XP) (11 Coins)",PlayerName(killerid)), SendClientMessageToAll(-1,kstring), pInfo[killerid][pXP] += 950,pInfo[killerid][pCoins] += 11;
            case 
60format(kstring,sizeof(kstring),""chat""COL_PINK" %s has achieved a 60 killstreak "COL_WHITE"(+1000 XP) (12 Coins)",PlayerName(killerid)), SendClientMessageToAll(-1,kstring), pInfo[killerid][pXP] += 1000,pInfo[killerid][pCoins] += 12;
            case 
65format(kstring,sizeof(kstring),""chat""COL_PINK" %s has achieved a 65 killstreak "COL_WHITE"(+1200 XP) (13 Coins)",PlayerName(killerid)), SendClientMessageToAll(-1,kstring), pInfo[killerid][pXP] += 1200,pInfo[killerid][pCoins] += 13;
            case 
70format(kstring,sizeof(kstring),""chat""COL_PINK" %s has achieved a 70 killstreak "COL_WHITE"(+1500 XP) (14 Coins)",PlayerName(killerid)), SendClientMessageToAll(-1,kstring), pInfo[killerid][pXP] += 1500,pInfo[killerid][pCoins] += 14;
            case 
75format(kstring,sizeof(kstring),""chat""COL_PINK" %s has achieved a 75 killstreak "COL_WHITE"(+1600 XP) (15 Coins)",PlayerName(killerid)), SendClientMessageToAll(-1,kstring), pInfo[killerid][pXP] += 1600,pInfo[killerid][pCoins] += 15;
            case 
80format(kstring,sizeof(kstring),""chat""COL_PINK" %s has achieved a 80 killstreak "COL_WHITE"(+1800 XP) (16 Coins)",PlayerName(killerid)), SendClientMessageToAll(-1,kstring), pInfo[killerid][pXP] += 1800,pInfo[killerid][pCoins] += 16;
            case 
85format(kstring,sizeof(kstring),""chat""COL_PINK" %s has achieved a 85 killstreak "COL_WHITE"(+1900 XP) (17 Coins)",PlayerName(killerid)), SendClientMessageToAll(-1,kstring), pInfo[killerid][pXP] += 1900,pInfo[killerid][pCoins] += 17;
            case 
90format(kstring,sizeof(kstring),""chat""COL_PINK" %s has achieved a 90 killstreak "COL_WHITE"(+2000 XP) (18 Coins)",PlayerName(killerid)), SendClientMessageToAll(-1,kstring), pInfo[killerid][pXP] += 2000,pInfo[killerid][pCoins] += 18;
            case 
95format(kstring,sizeof(kstring),""chat""COL_PINK" %s has achieved a 95 killstreak "COL_WHITE"(+5000 XP) (19 Coins)",PlayerName(killerid)), SendClientMessageToAll(-1,kstring), pInfo[killerid][pXP] += 5000,pInfo[killerid][pCoins] += 19;
            case 
100format(kstring,sizeof(kstring),""chat""COL_PINK" %s has achieved a 100 killstreak "COL_WHITE"(+5500 XP) (20 Coins)",PlayerName(killerid)), SendClientMessageToAll(-1,kstring), pInfo[killerid][pXP] += 5500,pInfo[killerid][pCoins] += 20;
            case 
105format(kstring,sizeof(kstring),""chat""COL_PINK" %s has achieved a 105 killstreak "COL_WHITE"(+6000 XP) (21 Coins)",PlayerName(killerid)), SendClientMessageToAll(-1,kstring), pInfo[killerid][pXP] += 6000,pInfo[killerid][pCoins] += 21;
            case 
110format(kstring,sizeof(kstring),""chat""COL_PINK" %s has achieved a 110 killstreak "COL_WHITE"(+6500 XP) (22 Coins)",PlayerName(killerid)), SendClientMessageToAll(-1,kstring), pInfo[killerid][pXP] += 6500,pInfo[killerid][pCoins] += 22;
            case 
115format(kstring,sizeof(kstring),""chat""COL_PINK" %s has achieved a 115 killstreak "COL_WHITE"(+7000 XP) (23 Coins)",PlayerName(killerid)), SendClientMessageToAll(-1,kstring), pInfo[killerid][pXP] += 7000,pInfo[killerid][pCoins] += 23;
            case 
120format(kstring,sizeof(kstring),""chat""COL_PINK" %s has achieved a 120 killstreak "COL_WHITE"(+7500 XP) (24 Coins)",PlayerName(killerid)), SendClientMessageToAll(-1,kstring), pInfo[killerid][pXP] += 7500,pInfo[killerid][pCoins] += 24;
        }

    
hideTextdrawsAfterConnect(playerid);
     
CheckToLevelOrRankUp(killerid);
    return 
1;

Reply
#4

AnyOne ?
Reply
#5

You have to damage them to make the system recognize that you damaged someone or killed him so it can say anything but when you set his health to 0 the system doesnt recognize who did this unless you added what you added textdraws,print and death message under the command slap or sethealth
Reply
#6

I want to create something when I got killed by someone else get message you billed by ....
And
When he got died by nothing he get message you died
But you died not work
Reply
#7

Try this OnPlayerDeath :
PHP код:
if(killerid == INVALID_PLAYER_ID)
{
SendClientMessage(playerid, -1"You died.");

Reply
#8

For the /death, I would make a variable "HasUseDeath[MAX_PLAYERS]",

And when player's using it, it's 1.

And under OnPlayerDeath, i would use :

PHP код:
if(HasUsedDeath 1)
{
    
//your code

Reply
#9

Ok but i want to do when i got killed my myself it show the message death
I have try to use i if(killerid == INVALID_PLAYER_ID) and not work but i want because more of players die by fall and i want to show me the textdraw
thanks
Reply
#10

AnyOne ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)