Headshot
#1

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);
		}
	}
Reply
#2

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)
Reply
#3

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

Update your includes.
Reply
#5

Which ones?
Reply
#6

All of them.
Reply
#7

Look what it says here:

https://sampwiki.blast.hk/wiki/Body_Parts
Reply
#8

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;

Reply
#9

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


Forum Jump:


Users browsing this thread: 1 Guest(s)