OnPlayerDeath - Updating Data
#1

I have all valid variables in place and set up... But I can't seem to get the data for Deaths and Kills to add 1 ontop of the current number set on that variable.

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	new PlayerName[MAX_PLAYER_NAME], KillerName[MAX_PLAYER_NAME], string[128];
        GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
	GetPlayerName(killerid, KillerName, sizeof(KillerName));
        format(string, sizeof(string), "%s has been killed by %s!", PlayerName, KillerName);
        SendClientMessageToAll(0xFFFFFFFF, string);
	pInfo[playerid][pDeaths] += 1;
	pInfo[killerid][pKills] += 1;
   	return 1;
}
Reply
#2

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new PlayerName[MAX_PLAYER_NAME], KillerName[MAX_PLAYER_NAME], string[128];
    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
    GetPlayerName(killerid, KillerName, sizeof(KillerName));
    format(string, sizeof(string), "%s has been killed by %s!", PlayerName, KillerName);
    SendClientMessageToAll(0xFFFFFFFF, string);
    pInfo[playerid][pDeaths]++;
    pInfo[killerid][pKills]++;
    return 1;
}
++ = Increases by 1.

EDIT: Why don't you use THIS instead of:
pawn Код:
new PlayerName[MAX_PLAYER_NAME], KillerName[MAX_PLAYER_NAME], string[128];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
GetPlayerName(killerid, KillerName, sizeof(KillerName));
format(string, sizeof(string), "%s has been killed by %s!", PlayerName, KillerName);
SendClientMessageToAll(0xFFFFFFFF, string);
Reply
#3

Quote:
Originally Posted by RedJohn
Посмотреть сообщение
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new PlayerName[MAX_PLAYER_NAME], KillerName[MAX_PLAYER_NAME], string[128];
    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
    GetPlayerName(killerid, KillerName, sizeof(KillerName));
    format(string, sizeof(string), "%s has been killed by %s!", PlayerName, KillerName);
    SendClientMessageToAll(0xFFFFFFFF, string);
    pInfo[playerid][pDeaths]++;
    pInfo[killerid][pKills]++;
    return 1;
}
++ = Increases by 1.

EDIT: Why don't you use THIS instead of:
pawn Код:
new PlayerName[MAX_PLAYER_NAME], KillerName[MAX_PLAYER_NAME], string[128];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
GetPlayerName(killerid, KillerName, sizeof(KillerName));
format(string, sizeof(string), "%s has been killed by %s!", PlayerName, KillerName);
SendClientMessageToAll(0xFFFFFFFF, string);
At first I didn't want to use this, but now I come to think of it... It'd be better since the chat won't get spammed out lol.

Thanks dude.
Reply
#4

And in future, simplify your server as much as you can. If you have too many un-optimized code your server will become laggy for those with low PCs. Keep that in mind.
Reply
#5

I have updated it but for some reason it's not updating the deaths or kills, still... It also removes $100 from the player who dies rather than the $50 set and doesn't add $100 to the killer.

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	
    SendDeathMessage(killerid, playerid, reason);

	if(killerid != INVALID_PLAYER_ID) // Killer Shit
    {
        pInfo[killerid][pKills]++;
		pInfo[killerid][pScore]++;
		pInfo[killerid][pMoney] += 100;
		SetPlayerScore(killerid, pInfo[killerid][pScore]);
    }
	//Dead Shit
	pInfo[playerid][pDeaths]++;
	pInfo[playerid][pMoney] -= 50;

   	return 1;
}
Reply
#6

pawn Код:
if(killerid != INVALID_PLAYER_ID) // Killer Shit
    {
                pInfo[killerid][pKills]++;
        pInfo[killerid][pScore]++;
        pInfo[killerid][pMoney] = pInfo[killerid][pMoney]+100;
        SetPlayerScore(killerid, pInfo[killerid][pScore]);
    }
    //Dead Shit
    pInfo[playerid][pDeaths]++;
    pInfo[playerid][pMoney] = pInfo[playerid][pMoney]-50;

    return 1;
}
Reply
#7

Quote:
Originally Posted by Amel_PAtomAXx
Посмотреть сообщение
pawn Код:
if(killerid != INVALID_PLAYER_ID) // Killer Shit
    {
                pInfo[killerid][pKills]++;
        pInfo[killerid][pScore]++;
        pInfo[killerid][pMoney] = pInfo[killerid][pMoney]+100;
        SetPlayerScore(killerid, pInfo[killerid][pScore]);
    }
    //Dead Shit
    pInfo[playerid][pDeaths]++;
    pInfo[playerid][pMoney] = pInfo[playerid][pMoney]-50;

    return 1;
}
Actually correct way is:
pawn Код:
pInfo[playerid][pMoney] = GetPlayerMoney(playerid) - 50;
Reply
#8

Okay, but for some reason the pInfo[playerid][pDeaths]++; doesn't seem to update the deaths, same with the score and kills.
Reply
#9

How can you tell that it doesn't update? How are you checking for this?
Reply
#10

Quote:
Originally Posted by RedJohn
Посмотреть сообщение
Actually correct way is:
pawn Код:
pInfo[playerid][pMoney] = GetPlayerMoney(playerid) - 50;
He's running own money system.
pawn Код:
pInfo[playerid][pMoney] = pInfo[playerid][pMoney] - 50;
GivePlayerMoney(playerid, pInfo[playerid][pMoney]);
This should work well...
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    SendDeathMessage(killerid, playerid, reason);
    if(killerid != INVALID_PLAYER_ID)
    {
        pInfo[killerid][pKills] = pInfo[killerid][pKills] + 1;
        pInfo[killerid][pScore] = pInfo[killerid][pScore] +1;
        pInfo[killerid][pMoney] = pInfo[killerid][pMoney] + 100;
        GivePlayerMoney(killerid, pInfo[killerid][pMoney]);
        SetPlayerScore(killerid, pInfo[killerid][pScore]);
    }
    else
    {
        pInfo[playerid][pDeaths] = pInfo[playerid][pDeaths] + 1;
        pInfo[playerid][pMoney] = pInfo[playerid][pMoney] - 50;
        GivePlayerMoney(playerid, pInfo[playerid][pMoney]);
    }
    return 1;
}
Let me now if something goes bad.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)