A Problem in OnPlayerDeath
#1

Ok guys im a scripter begginer i was working on OnPlayerDeath but when i tested with a friend it works but when i blow up in a car my samp server closes and our samp crashes does anyone know? i leave my things i done in playerdeath or if you guys give me a link to look it would help me alot
ima begginer so yea if you see the OnPlayerDeath you'll see just simple things

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	SendClientMessage(killerid,0xFF9900AA,"You killed %s, Well Done");
	SendClientMessage(killerid,0xFF9900AA,"You Got A Wanted lvl And Some Money From The Victim!");
	SendClientMessage(playerid,0x4B00B0AA,"You been killed by %s");
	SendClientMessage(playerid,0x4B00B0AA,"You Been Healed By The Hospital, You Medicals Fees Are 4000.");
	SendClientMessage(playerid,0x4B00B0AA,"You Lost Some Money When %s Was Shooting You");
	SetPlayerWantedLevel(killerid,4);
	SetPlayerColor(killerid,0xf73219ff);
	GivePlayerMoney(playerid,-22653);
	GivePlayerMoney(killerid,18232);
	SendDeathMessage(killerid, playerid, reason);
	return 1;
}
Reply
#2

Doesn't look like you have strings defined:


pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new string [128];
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));

    SendClientMessage(killerid,0xFF9900AA,"You killed %s, Well Done");
    SendClientMessage(killerid,0xFF9900AA,"You Got A Wanted lvl And Some Money From The Victim!");
    SendClientMessage(playerid,0x4B00B0AA,"You been killed by %s");
    SendClientMessage(playerid,0x4B00B0AA,"You Been Healed By The Hospital, You Medicals Fees Are 4000.");
    SendClientMessage(playerid,0x4B00B0AA,"You Lost Some Money When %s Was Shooting You");
    SetPlayerWantedLevel(killerid,4);
    SetPlayerColor(killerid,0xf73219ff);
    GivePlayerMoney(playerid,-22653);
    GivePlayerMoney(killerid,18232);
    SendDeathMessage(killerid, playerid, reason);
    return 1;
}
I don't why this would only happen in a car though.
Reply
#3

it keeps doing it but it does that when im in a car and blows up and when i fall from a building or helicopter.

and i want to ask if theres something like to tell you fell from a building or u died (no specific death type like "You died, you medicals bla blah" and then if its a player who killed you (i already did that) the code or if theres a tutorial can you guys post it? that would help me alot again thanks
Reply
#4

There might be something under onPlayerDeath in a FS loaded. Have you added any new FS's lately?
Reply
#5

you aren't even checking to see if killerid is a person before you send stuff to him.
pawn Код:
new pName[MAX_PLAYERS][MAX_PLAYER_NAME]
public OnPlayerConnect(playerid)
{
    GetPlayerName(playerid, pName[playerid], MAX_PLAYER_NAME);
}
public OnPlayerDeath(playerid, killerid, reason)
{
    if (killerid != INVALID_PLAYER_ID)
    {
        new strg[70];
        format(strg, sizeof(strg), "You killed %s, Well Done", pName[playerid]);
        SendClientMessage(killerid,0xFF9900AA,strg);
        SendClientMessage(killerid,0xFF9900AA,"You Got A Wanted lvl And Some Money From The Victim!");
        format(strg, sizeof(strg), "You been killed by %s", pName[killerid]);
        SendClientMessage(playerid,0x4B00B0AA,strg);
        format(strg, sizeof(strg), "You Lost Some Money When %s Was Shooting You", pName[killerid]);
        SendClientMessage(playerid,0x4B00B0AA,strg);
        SetPlayerWantedLevel(killerid,4);
        SetPlayerColor(killerid,0xf73219ff);
        GivePlayerMoney(killerid,18232);
    }
    SendClientMessage(playerid,0x4B00B0AA,"You Been Healed By The Hospital, You Medicals Fees Are 4000.");
    GivePlayerMoney(playerid,-4000);
    SendDeathMessage(killerid, playerid, reason);
    return 1;
}
with a few optimizations in there also.
Reply
#6

ok guys im not the best learner and honestly i fail at this. If you guys would reply with a link to a tutorial it would be helpful because this is confusing and i don't want to waste your time.
Reply
#7

Well there isnt a real tutorial, but to say one thing the code isnt even correct.

Daren_Jacobson has given the best code in this topic.
Try using his code if that doesnt work, try removing: SendDeathMessage(killerid, playerid, reason);

It crashed my server once (@windows)
Reply
#8

Quote:
Originally Posted by Pandabeer1337
Well there isnt a real tutorial, but to say one thing the code isnt even correct.
i know its not correct if it was then what would be the point of posting it?

still thanks guys
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)