SA-MP Forums Archive
Headshot - 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)
+--- Thread: Headshot (/showthread.php?tid=616045)



Headshot - MrCallum - 30.08.2016

I've made this but it crashes my pawno?

It is under : public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)

Код:
	if(issuerid != INVALID_PLAYER_ID)
	{
		switch(bodypart)
		{
			new iTargetID;
			new szMessage[47];
			case BODY_PART_HEAD: SetPlayerHealth(playerid, 0);
			format(szMessage, sizeof(szMessage), "[(!)]%s has killed you by a headshot!",  GetPlayerNameEx(playerid));
			SendClientMessageEx(iTargetID, COLOR_LIGHTBLUE, szMessage);
			format(szMessage, sizeof(szMessage), "[(!)]You killed %s with a headshot!", GetPlayerNameEx(iTargetID));
			SendClientMessageEx(playerid, COLOR_LIGHTBLUE, szMessage);
		}
	}



Re: Headshot - Stinged - 30.08.2016

That's not how switch works: https://sampwiki.blast.hk/wiki/Control_Structures#switch

pawn Код:
if(issuerid != INVALID_PLAYER_ID && bodypart == BODY_PART_HEAD)
{
    new szMessage[60];
    SetPlayerHealth(playerid, 0);
    format(szMessage, sizeof(szMessage), "[(!)]%s has killed you by a headshot!",  GetPlayerNameEx(issuerid));
    SendClientMessageEx(playerid, COLOR_LIGHTBLUE, szMessage);
    format(szMessage, sizeof(szMessage), "[(!)]You killed %s with a headshot!", GetPlayerNameEx(playerid));
    SendClientMessageEx(issuerid, COLOR_LIGHTBLUE, szMessage);
}
I also fixed your message size (too small) and your playerids.
You were mixing between them and for some reason you were use a new variable (which was equal to 0)


Re: Headshot - MrCallum - 30.08.2016

I get
Код:
error 017: undefined symbol "bodypart"



Re: Headshot - SickAttack - 30.08.2016

Update your includes.


Re: Headshot - MrCallum - 30.08.2016

Which ones?


Re: Headshot - SickAttack - 30.08.2016

All of them.


Re: Headshot - MrCallum - 30.08.2016

Look what it says here:

https://sampwiki.blast.hk/wiki/Body_Parts


Re: Headshot - Juvanii - 30.08.2016

In case you want to do it using switch/case:
PHP код:
public OnPlayerTakeDamage(playeridissueridFloatamountweaponidbodypart)
{
    new 
string[128];
    if(
issuerid == INVALID_PLAYER_ID) return 1;
    switch(
bodypart)
    {
        case 
9:
        {
            
SetPlayerHealth(playerid0);
            
format(stringsizeof(string), "[(!)]%s has killed you by a headshot!"GetPlayerNameEx(issuerid));
            
SendClientMessage(playeridCOLOR_LIGHTBLUEstring);
            
format(stringsizeof(string), "[(!)]You killed %s with a headshot!"GetPlayerNameEx(playerid));
            
SendClientMessage(issueridCOLOR_LIGHTBLUEstring);
        }
    }
    return 
1;




Re: Headshot - Shinja - 30.08.2016

Change your public line to
PHP код:
public OnPlayerTakeDamage(playeridissueridFloat:amountweaponidbodypart