SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 29/12/2019, 03:12 PM   #1
mems
Big Clucker
 
Join Date: Oct 2019
Posts: 142
Reputation: 0
Default after player dies from shots, it shows "Splat" instead of the weapon shot at the player

hello there,

after trying to download a OnPlayerTakeDamage filterscript, i've decided to edit a little bit the code so it can look much better, but as the title says, when for example: i shoot the player 3 times with a Desert Deagle (without armor) the player dies. but i've edited the onplayertakedamage to show textdraws next to the player's feet.. if it sounds strange to you, this is what i mean: https://imgur.com/eaeTA5g i guess you should understand now xD

anyways back to the point. when i shoot the player 3 times with deagle (without armor), he dies, but the message on the textdraw shows "Splat" instead of the weapon i shoot at the player


pawn Code:
forward OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart);
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
    new s[36];
    new weaponname[32];
    new issuername[MAX_PLAYER_NAME];
    new pname[MAX_PLAYER_NAME];
    GetPlayerName(issuerid, issuername, sizeof(issuername));
    GetPlayerName(playerid, pname, sizeof(pname));
    GetWeaponName(weaponid, weaponname, sizeof(weaponname));
    switch(weaponid)
    {
        case 0:
        {
            format(s, 36, "%s - (Fist) -%.0f", issuername, amount); //The one who got damaged
            TextDrawSetString(TakeDamage[playerid], s);
            TextDrawShowForPlayer(playerid, TakeDamage[playerid]);
            format(s, 36, "%s - (Fist) +%.0f", pname, amount); //The one who damaged it
            TextDrawSetString(GiveDamage[issuerid], s);
            TextDrawShowForPlayer(issuerid, GiveDamage[issuerid]);
            PlayerPlaySound(issuerid,17802,0.0,0.0,0.0);
        }
        case 1 .. 42:
        {
            format(s, 36, "%s - (%s) -%.0f", issuername, weaponname, amount); //The one who got damaged
            TextDrawSetString(TakeDamage[playerid], s);
            TextDrawShowForPlayer(playerid, TakeDamage[playerid]);
            format(s, 36, "%s - (%s) +%.0f", pname, weaponname, amount); //The one who damaged it
            TextDrawSetString(GiveDamage[issuerid], s);
            TextDrawShowForPlayer(issuerid, GiveDamage[issuerid]);
            PlayerPlaySound(issuerid,17802,0.0,0.0,0.0);
        }
        case 54:
        {
            format(s, 36, "%s -%.0f", weaponname, amount);
            TextDrawSetString(TakeDamage[playerid], s);
            TextDrawShowForPlayer(playerid, TakeDamage[playerid]);
            PlayerPlaySound(issuerid, 17802,0.0,0.0,0.0);
        }
    }
    SetTimerEx("DestruirTextoDraw", 3000, false, "i", playerid);
    SetTimerEx("DestruirTextoDraw", 3000, false, "i", issuerid);
    return 1;
}
code here, cheers

EDIT: if you need more evidence apart from the onplayertakedamage, feel free to ask.

Last edited by mems; 29/12/2019 at 07:28 PM.
mems is offline   Reply With Quote
Old 30/12/2019, 04:09 AM   #2
coool
Gangsta
 
coool's Avatar
 
Join Date: Feb 2013
Location: Republic of Pakistan
Posts: 625
Reputation: 54
Default Re: after player dies from shots, it shows "Splat" instead of the weapon shot at the player

For splat: issuerid should be 'INVALID_PLAYER_ID'. Check if issuerid is invalid, if it is then don't change the textdraw
__________________
coool is offline   Reply With Quote
Old 30/12/2019, 09:11 AM   #3
mems
Big Clucker
 
Join Date: Oct 2019
Posts: 142
Reputation: 0
Default Re: after player dies from shots, it shows "Splat" instead of the weapon shot at the player

Quote:
Originally Posted by coool View Post
For splat: issuerid should be 'INVALID_PLAYER_ID'. Check if issuerid is invalid, if it is then don't change the textdraw
damn dude, didn't think that it was an easy fix.. i tried lots of ways for this man.. thanks, +rep is the least i can do for ya
mems is offline   Reply With Quote
Old 30/12/2019, 11:00 AM   #4
mems
Big Clucker
 
Join Date: Oct 2019
Posts: 142
Reputation: 0
Default Re: after player dies from shots, it shows "Splat" instead of the weapon shot at the player

well... something again caught up now.. i saw your idea and made a
pawn Code:
if(issuerid == INVALID_PLAYER_ID)
and inserted the 'case 54' code since weaponid 54 is splat, and yeah, when i shot the player to death, it didn't show 'Splat %.0f', but when i wanted to hit myself by jumping over a high floor, it didn't show the damage.. here's the reedited code:

pawn Code:
forward OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart);
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
    new s[36];
    new weaponname[32];
    new issuername[MAX_PLAYER_NAME];
    new pname[MAX_PLAYER_NAME];
    GetPlayerName(issuerid, issuername, sizeof(issuername));
    GetPlayerName(playerid, pname, sizeof(pname));
    GetWeaponName(weaponid, weaponname, sizeof(weaponname));
    switch(weaponid)
    {
        case 0:
        {
            format(s, 36, "%s - (Fist) -%.0f", issuername, amount); //The one who got damaged
            TextDrawSetString(TakeDamage[playerid], s);
            TextDrawShowForPlayer(playerid, TakeDamage[playerid]);
            format(s, 36, "%s - (Fist) +%.0f", pname, amount); //The one who damaged it
            TextDrawSetString(GiveDamage[issuerid], s);
            TextDrawShowForPlayer(issuerid, GiveDamage[issuerid]);
            PlayerPlaySound(issuerid,17802,0.0,0.0,0.0);
        }
        case 1 .. 47:
        {
            format(s, 36, "%s - (%s) -%.0f", issuername, weaponname, amount); //The one who got damaged
            TextDrawSetString(TakeDamage[playerid], s);
            TextDrawShowForPlayer(playerid, TakeDamage[playerid]);
            format(s, 36, "%s - (%s) +%.0f", pname, weaponname, amount); //The one who damaged it
            TextDrawSetString(GiveDamage[issuerid], s);
            TextDrawShowForPlayer(issuerid, GiveDamage[issuerid]);
            PlayerPlaySound(issuerid,17802,0.0,0.0,0.0);
        }
    }
    if(issuerid == INVALID_PLAYER_ID)
    {
        format(s, 36, "%s -%.0f", weaponname, amount);
        TextDrawSetString(TakeDamage[issuerid], s);
        TextDrawShowForPlayer(issuerid, TakeDamage[issuerid]);
        PlayerPlaySound(issuerid, 17802,0.0,0.0,0.0);
    }
    SetTimerEx("DestruirTextoDraw", 3000, false, "i", playerid);
    SetTimerEx("DestruirTextoDraw", 3000, false, "i", issuerid);
    return 1;
}
mems is offline   Reply With Quote
Old 30/12/2019, 11:38 AM   #5
Mugala
High-roller
 
Mugala's Avatar
 
Join Date: Nov 2012
Location: Georgia, Tbilisi
Posts: 1,162
Reputation: 73
Default Re: after player dies from shots, it shows "Splat" instead of the weapon shot at the player

for first, create 2 logic, when if(issuerid != INVALID_PLAYER_ID)
and else case.

in normal case, switch(weaponid) and add case 0: and default:
in else case, use your current code.
__________________
Coding in 8 languages including Pawn, C#, C++ and SQL.
Available for hiring.

If you have a coding question or need an assistance in a code, just PM me.
If you want me to create something for you, here is a Discord Mugala#5651

Currently helping Community members in a coding.
Mugala is offline   Reply With Quote
Old 30/12/2019, 11:40 AM   #6
mems
Big Clucker
 
Join Date: Oct 2019
Posts: 142
Reputation: 0
Default Re: after player dies from shots, it shows "Splat" instead of the weapon shot at the player

you mean on if(issuer != invalid_player_id) i should put the splat thing or put the case 0 and from 1 to 47 ones ?
mems is offline   Reply With Quote
Old 30/12/2019, 11:44 AM   #7
Mugala
High-roller
 
Mugala's Avatar
 
Join Date: Nov 2012
Location: Georgia, Tbilisi
Posts: 1,162
Reputation: 73
Default Re: after player dies from shots, it shows "Splat" instead of the weapon shot at the player

okay, here is a whole code.
PHP Code:
forward OnPlayerTakeDamage(playeridissueridFloatamountweaponidbodypart);
public 
OnPlayerTakeDamage(playeridissueridFloatamountweaponidbodypart)
{
    new 
s[36];
    new 
weaponname[32];
    new 
pname[MAX_PLAYER_NAME];
    
GetPlayerName(playeridpnamesizeof(pname));
    
GetWeaponName(weaponidweaponnamesizeof(weaponname));
    if(
issuerid != INVALID_PLAYER_ID)
    {
        new 
issuername[MAX_PLAYER_NAME];
        
GetPlayerName(issueridissuernamesizeof(issuername));
        switch(
weaponid)
        {
            case 
0:
            {
                
format(s36"%s - (Fist) -%.0f"issuernameamount); //The one who got damaged
                
TextDrawSetString(TakeDamage[playerid], s);
                
TextDrawShowForPlayer(playeridTakeDamage[playerid]);
                
format(s36"%s - (Fist) +%.0f"pnameamount); //The one who damaged it
                
TextDrawSetString(GiveDamage[issuerid], s);
                
TextDrawShowForPlayer(issueridGiveDamage[issuerid]);
                
PlayerPlaySound(issuerid,17802,0.0,0.0,0.0);
            }
            default:
            {
                
format(s36"%s - (%s) -%.0f"issuernameweaponnameamount); //The one who got damaged
                
TextDrawSetString(TakeDamage[playerid], s);
                
TextDrawShowForPlayer(playeridTakeDamage[playerid]);
                
format(s36"%s - (%s) +%.0f"pnameweaponnameamount); //The one who damaged it
                
TextDrawSetString(GiveDamage[issuerid], s);
                
TextDrawShowForPlayer(issueridGiveDamage[issuerid]);
                
PlayerPlaySound(issuerid,17802,0.0,0.0,0.0);
            }
        }
        
SetTimerEx("DestruirTextoDraw"3000false"i"issuerid);
    }
    else
    {
        
format(s36"%s -%.0f"weaponnameamount);
        
TextDrawSetString(TakeDamage[issuerid], s);
        
TextDrawShowForPlayer(issueridTakeDamage[issuerid]);
        
PlayerPlaySound(issuerid17802,0.0,0.0,0.0);
    }
    
SetTimerEx("DestruirTextoDraw"3000false"i"playerid);
    return 
1;

__________________
Coding in 8 languages including Pawn, C#, C++ and SQL.
Available for hiring.

If you have a coding question or need an assistance in a code, just PM me.
If you want me to create something for you, here is a Discord Mugala#5651

Currently helping Community members in a coding.
Mugala is offline   Reply With Quote
Old 30/12/2019, 11:49 AM   #8
mems
Big Clucker
 
Join Date: Oct 2019
Posts: 142
Reputation: 0
Default Re: after player dies from shots, it shows "Splat" instead of the weapon shot at the player

nope, still doesn't show the message when trying to commit suicide
mems is offline   Reply With Quote
Old 30/12/2019, 11:53 AM   #9
Mugala
High-roller
 
Mugala's Avatar
 
Join Date: Nov 2012
Location: Georgia, Tbilisi
Posts: 1,162
Reputation: 73
Default Re: after player dies from shots, it shows "Splat" instead of the weapon shot at the player

use printf and debug the given parameters.
__________________
Coding in 8 languages including Pawn, C#, C++ and SQL.
Available for hiring.

If you have a coding question or need an assistance in a code, just PM me.
If you want me to create something for you, here is a Discord Mugala#5651

Currently helping Community members in a coding.
Mugala is offline   Reply With Quote
Old 30/12/2019, 12:00 PM   #10
mems
Big Clucker
 
Join Date: Oct 2019
Posts: 142
Reputation: 0
Default Re: after player dies from shots, it shows "Splat" instead of the weapon shot at the player

i'm afraid i don't know how to use printf in this situation...
mems 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
[Tutorial] Creating a "Death Camera" spectating screen when a player dies. iGetty Tutorials 14 25/06/2015 09:21 AM
When player kill another player get MSG"You killed [NAME]" -I got problems with that script bustern Scripting Help 9 15/09/2013 05:40 PM
Player not connected-Invalid Player id and You can't goto to yourself. "Goto command" KurtAngle Scripting Help 4 28/08/2013 06:14 AM
Player "dies" but do not respawn. Lincoln.C Scripting Help 5 11/11/2011 06:22 PM
Is player talks, use OnePlayAnim(playerid,"PED","IDLE_CHAT",4.0,0,0,0,0,0); Ihsan_Cingisiz Help Archive 5 30/05/2010 03:26 PM


All times are GMT. The time now is 12:41 AM.


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