SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 09/05/2020, 06:25 PM   #1
DaZzY
Little Clucker
 
Join Date: Aug 2011
Posts: 30
Reputation: 12
Question A little problem when player death

Hi i have a problem when player die he get +1 score i dont know why because on my script onplayerdeath i think thats correct

Quote:
public OnPlayerDeath(playerid, killerid, reason){

SendDeathMessage(killerid, playerid, reason);

if(killerid != INVALID_PLAYER_ID)
{
SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
}


GivePlayerMoney(killerid, 2500);
GivePlayerMoney(playerid, -1000);


return 1;
}
When player die on car its like he Killing himself take look at image

[IMG][/IMG]

Can any one know the solution ?
DaZzY is offline   Reply With Quote
Old 09/05/2020, 06:56 PM   #2
DandoRYx
Little Clucker
 
DandoRYx's Avatar
 
Join Date: Apr 2020
Posts: 17
Reputation: 2
Default Re: A little problem when player death

pawn Code:
public OnPlayerDeath(playerid, killerid, reason
{
    if(killerid != INVALID_PLAYER_ID)
    {
        SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
        SendDeathMessage(killerid,playerid,reason);
        GivePlayerMoney(killerid, 2500);
    }
    else
    {
        SendDeathMessage(INVALID_PLAYER_ID,playerid,reason);
    }
    GivePlayerMoney(playerid, -1000);
    return 1;
}
__________________
Car Shooter - Deathmatch / Capture The Flag
samp.worldskillers.eu:27655

DandoRYx is offline   Reply With Quote
Old 09/05/2020, 07:29 PM   #3
DaZzY
Little Clucker
 
Join Date: Aug 2011
Posts: 30
Reputation: 12
Default Re: A little problem when player death

The boths of codes are correct i use yours but problem is Always here
DaZzY is offline   Reply With Quote
Old 09/05/2020, 07:31 PM   #4
DandoRYx
Little Clucker
 
DandoRYx's Avatar
 
Join Date: Apr 2020
Posts: 17
Reputation: 2
Default Re: A little problem when player death

Maybe try this, I added killerid != playerid
pawn Code:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(killerid != INVALID_PLAYER_ID && killerid != playerid)
    {
        SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
        SendDeathMessage(killerid,playerid,reason);
        GivePlayerMoney(killerid, 2500);
    }
    else
    {
        SendDeathMessage(INVALID_PLAYER_ID,playerid,reason);
    }
    GivePlayerMoney(playerid, -1000);
    return 1;
}
__________________
Car Shooter - Deathmatch / Capture The Flag
samp.worldskillers.eu:27655

DandoRYx is offline   Reply With Quote
Old 09/05/2020, 07:33 PM   #5
princejeet1510
Big Clucker
 
princejeet1510's Avatar
 
Join Date: Mar 2016
Location: Trying to figure it out.
Posts: 119
Reputation: 4
Default Re: A little problem when player death

maybe setting a condition like: if(playerid == killerid) will solve your problem?
__________________
princejeet1510 is offline   Reply With Quote
Old 09/05/2020, 07:45 PM   #6
DaZzY
Little Clucker
 
Join Date: Aug 2011
Posts: 30
Reputation: 12
Default Re: A little problem when player death

Quote:
Maybe try this, I added killerid != playerid
pawn Code:
public OnPlayerDeath(playerid, killerid, reason)
{
if(killerid != INVALID_PLAYER_ID && killerid != playerid)
{
SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
SendDeathMessage(killerid,playerid,reason);
GivePlayerMoney(killerid, 2500);
}
else
{
SendDeathMessage(INVALID_PLAYER_ID,playerid,reason );
}
GivePlayerMoney(playerid, -1000);
return 1;
}
Thats work thanks +1rep
DaZzY is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem Death player Kevin51 Scripting Help 36 16/11/2017 11:00 PM
Player death problem HassanShah Scripting Help 6 04/08/2016 12:54 PM
[ HELP ] Problem with the Player Death. SpikY_ Scripting Help 11 12/06/2015 08:36 AM
Another problem with on player death CoDeZ Scripting Help 3 22/07/2012 08:00 PM


All times are GMT. The time now is 11:29 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.