SA-MP Forums Archive
OnPlayerDeath Problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: OnPlayerDeath Problem (/showthread.php?tid=262068)



OnPlayerDeath Problem - Cypress - 16.06.2011

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.


Re: OnPlayerDeath Problem - Lorenc_ - 16.06.2011

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");



Re: OnPlayerDeath Problem - Cypress - 16.06.2011

EDIT

K it got fixed


Re: OnPlayerDeath Problem - Lorenc_ - 16.06.2011

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.


Re: OnPlayerDeath Problem - Cypress - 16.06.2011

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


Re: OnPlayerDeath Problem - WooTFTW - 16.06.2011

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.


Re: OnPlayerDeath Problem - Lorenc_ - 17.06.2011

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.