OnPlayerDeath Problem
#1

pawn Код:
if(killerid == INVALID_PLAYER_ID && GetPVarInt(playerid, "gInDuel") == 1)
    {
        new gBet = GetPVarInt(playerid, "gDuelBet");

        GivePlayerMoneyEx(playerid, -gBet);
        GivePlayerMoneyEx(killerid,  gBet);

        new str[220];
        format(str, sizeof(str), " %s  committed suicide during a duel with %s.", PlayerName(playerid), PlayerName(GetPVarInt(playerid, "gInviterID")));
        SendClientMessageToAll(red, str);

        new duelerid = GetPVarInt(playerid, "gInviterID");

        RemoveFromDuel(duelerid);
        RemoveFromDuel(playerid);
        SpawnPlayer(duelerid);
    }
I have a duel filterscript and it works fine. When player kill other player or when player do suicide etc. But when i try to input the duel filterscript into my gamemode this part of function doesn't work. Can anyone tell me if there is a mistake somewhere coz in filterscript this part works normally. I even tried to remove everything from OnPlayerDeath and left only this function but nothing helped.
Reply
#2

Have you tried using printf to double check if the actual if statement is working or the whole callback?

Just do simple lines between each code
like:

pawn Код:
printf("Passed debug 1");
GivePlayerMoney(killerid, 5000); // If its onplayerdeath
printf("Passed debug 2");
Reply
#3

EDIT

K it got fixed
Reply
#4

Thats pretty strange, over the past I had this problem well constantly all the time.

Try remove those 2 codes

pawn Код:
GivePlayerMoneyEx(playerid, -gBet);
        printf("Passed debug 3");
        GivePlayerMoneyEx(killerid,  gBet);
        printf("Passed debug 4");
and then see if it executes the string and removes the player from the duel. You might want to add that code at the bottom of the statement.
Reply
#5

Ye it worked now. So what i have to do? give money at the end so the function won't stop?
Reply
#6

If the killerid is INVALID_PLAYER_ID, how can you give him the money?
That's why it's not working.
You will need to store Oponent's ID into PVar.
and then
GivePlayerMoney(GetPVarInt(playerid, "Oponent"), gBet);

I hope you get the idea.
Reply
#7

Quote:
Originally Posted by Cypress
Посмотреть сообщение
Ye it worked now. So what i have to do? give money at the end so the function won't stop?
Well yes, you need to try debugging, where ever it stops add that line of code to the bottom. Confusing but a working FIX.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)