Onplayerdeath ??????
#1

hello everyone i made a cmd under onplayerdeath that when a player is killed his death increases and when he gets killed by an admin that admins 5 score is increased but it wont work please help me

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    gPlayerInfo[playerid][Deaths]++;

	if(IsPlayerConnected(killerid))
	{
		gPlayerInfo[killerid][Kills]++;
	}
	if(gPlayerInfo[killerid][Level] >= 1)
	{
	   new score;
	   score = GetPlayerScore(killerid);
	   SetPlayerScore(killerid, score+5);
	}
	return 1;
}
Reply
#2

Check in OnPlayerDeath callback is player logged as admin. If yes, add admin +5 score, otherwise add another value which you want.

It's gonna be simple use of if statement.
Reply
#3

man i provided the code above but that dont worked read the code in my previous statement
Reply
#4

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    gPlayerInfo[playerid][Deaths]++;
    if(killerid != INVALID_PLAYER_ID) gPlayerInfo[killerid][Kills]++;
    if(gPlayerInfo[killerid][Level] > 0) SetPlayerScore(killerid, GetPlayerScore(killerid) + 5);
    return 1;
}
Reply
#5

Quote:
Originally Posted by CBCandyBoy
Посмотреть сообщение
man i provided the code above but that dont worked read the code in my previous statement
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    gPlayerInfo[playerid][Deaths]++;

    if(IsPlayerConnected(killerid))
    {
        gPlayerInfo[killerid][Kills]++;
    }
    if(gPlayerInfo[killerid][Level] >= 1)
    {
       new score;
       score = GetPlayerScore(killerid);
       SetPlayerScore(killerid, score+5);
    }
    return 1;
}
So, this line checks is player have some admin level?
pawn Код:
if(gPlayerInfo[killerid][Level] >= 1)
If you would describe it in the first post, then it would be a lot easier.

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(killerid != INVALID_PLAYER_ID)
    {
        gPlayerInfo[playerid][Deaths]++;
        gPlayerInfo[killerid][Kills]++;
       
        if(gPlayerInfo[killerid][Level] >= 1)
        {
           SetPlayerScore(killerid, GetPlayerScore(killerid)+5); // For admin score value.
        }
    }
    return 1;
}
Reply
#6

testings
Reply
#7

Which one doesn't work? If player level is equal to 0, then that means player is player, yes? Or -1 is player, give a little bit more details about your admin level system.
Reply
#8

actually i made a cmd for /getinfo in that it tells players deaths but it is not telling

the cmd is

pawn Код:
CMD:getinfo(playerid,params[])
{
    if(gPlayerInfo[playerid][Level] >= 1 || IsPlayerAdmin(playerid))
    {
        new target;
        if(sscanf(params, "u", target)) return
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Usage: /getinfo [PlayerID] ") &&
        SendClientMessage(playerid, COLOR_ORANGE, "Function: Will see Informations of specified player");
        new string[128];

        if(IsPlayerConnected(target) && target != INVALID_PLAYER_ID)
         {
            new TimesOn;
            new pIP[128];
            new Float:pHealth;
            new Float:pArmour;
            new year,month,day;
            new tmp2[256],file[256];
            new Float:x,Float:y,Float:z;
            new pRegister[4],RegDate[256];
            new pJailed[4],pFrozen[4];
            new pLogged[4];

            GetPlayerArmour(target,pArmour);
            GetPlayerHealth(target,pHealth);
            GetPlayerIp(target, pIP, sizeof(pIP));
            getdate(year, month, day);
            GetPlayerPos(target,x,y,z);

            new name[MAX_PLAYER_NAME];
            GetPlayerName(playerid, name, sizeof(name));
            format(file, sizeof(file), PlayerFile, name);

            if(gPlayerInfo[target][Jailed] == 1)   pJailed   = "Yes"; else pJailed   = "No";
            if(gPlayerInfo[target][Frozen] == 1)    pFrozen   = "Yes"; else pFrozen   = "No";
            if(gPlayerInfo[target][LoggedIn] == 1) pLogged   = "Yes"; else pLogged   = "No";
            if(fexist(file))                    pRegister = "Yes"; else pRegister = "No";

            tmp2 = dini_Get(file,"Last On:");

            RegDate = dini_Get(file,"Registered On:");
           
            GetPlayerName( target,name, sizeof(name));
            SendClientMessage(playerid, orange, " ");
            SendClientMessage(playerid, orange, "___________ |- Player Information -| ___________");
            format(string, sizeof(string),"Name: %s | ID: %d | Ip: %s | Health: %d | Armour: %d | Cash: %d", name, target,pIP,floatround(pHealth),floatround(pArmour),GetPlayerMoney(target));
            SendClientMessage(playerid,COLOR_LIGHTGREEN,string);
            format(string, sizeof(string),"Score: %d | Skin: %d | Ping: %d| Wanted Level: %d", GetPlayerScore(target),GetPlayerSkin(target),GetPlayerPing(target),GetPlayerWantedLevel(target));
            SendClientMessage(playerid,0x33F666FF,string);
            format(string, sizeof(string),"Interior: %d | Virtual World: %d | Pos: X: %0.1f, Y: %0.1f, Z: %0.1f |", GetPlayerInterior(target), GetPlayerVirtualWorld(target), Float:x,Float:y,Float:z);
            SendClientMessage(playerid,0x53D266FF,string);
            format(string, sizeof(string),"Kills: %d | Deaths: %d | Ratio: %0.2f | Admin Level: %d - %s |", gPlayerInfo[target][Kills],gPlayerInfo[target][Deaths],Float:gPlayerInfo[target][Kills]/Float:gPlayerInfo[target][Deaths],gPlayerInfo[target][Level],GetRankFromLevel(target));
            SendClientMessage(playerid,0x53D212FF,string);
            format(string, sizeof(string),"Registered: %s | Logged In: %s | In Jail: %s | Frozen: %s | On Server: %d",pRegister,pLogged,pJailed,pFrozen,TimesOn);
            SendClientMessage(playerid,0x53BB12FF,string);
            format(string, sizeof(string),"Last On Server: %s | Register Date: %s | Todays Date: %d/%d/%d",tmp2,RegDate,day,month,year);
            SendClientMessage(playerid,0x129E12FF,string);

            new slot, ammo, weap, Count, WeapName[24], WeapSTR[128], p; WeapSTR = "Weapons: ";
            for (slot = 0; slot < 14; slot++)
            {
            GetPlayerWeaponData(target, slot, weap, ammo);
            if( ammo != 0 && weap != 0)
            Count++;
            }
            if(Count < 1)
            return SendClientMessage(playerid,0x6BF686FF,"Player has no weapons");
            else
            {
                for (slot = 0; slot < 14; slot++)
                {
                    GetPlayerWeaponData(target, slot, weap, ammo);
                    if (ammo > 0 && weap > 0)
                    {
                        GetWeaponName(weap, WeapName, sizeof(WeapName) );
                        if (ammo == 65535 || ammo == 1)
                        format(WeapSTR,sizeof(WeapSTR),"%s%s (1)",WeapSTR, WeapName);
                        else format(WeapSTR,sizeof(WeapSTR),"%s%s (%d)",WeapSTR, WeapName, ammo);
                        p++;
                        if(p >= 5)
                        {
                        SendClientMessage(playerid, 0x6BF686FF, WeapSTR); format(WeapSTR, sizeof(WeapSTR), "Weapons: "); p = 0;
                        }
                        else format(WeapSTR, sizeof(WeapSTR), "%s,  ", WeapSTR);
                    }
                }
                if(p <= 4 && p > 0)
                {
                    string[strlen(string)-3] = '.';
                    SendClientMessage(playerid, 0x6BF686FF, WeapSTR);
                }
            }
            return 1;
        }
        else return ErrorMessages(playerid, 2);
    }
    else return  ErrorMessages(playerid, 7);
}
Reply
#9

What value of deaths, do you receive from that message? If it's 0, try to kill yourself (suicide), but it can't be in if statement of:

pawn Код:
if(killerid != INVALID_PLAYER_ID)
it must be underneath or at the top of OnPlayerDeath callback.
Reply
#10

i tried to sucide that dont work so how to try just test will that work if anyone kills me
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)