Headshot System Help - 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 System Help (
/showthread.php?tid=625548)
Headshot System Help -
XBoss30 - 03.01.2017
I want to make this headshot system, so example:
when i shoot a player it should show:
Areeb has been shoot by XBoss30 to the head and XBoss30 has earned $100
here is my code:
On top of the script
new headshot[MAX_PLAYERS];
PHP код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
if(issuerid != INVALID_PLAYER_ID)
{
if(IsPlayerConnected(issuerid))
{
if(bodypart == 9)
{
SetPlayerHealth(playerid, 0.0);
new string[100];
GetPlayerName(playerid, headshot, sizeof(headshot));
format(string, sizeof(string), "%s was shoot to the head by %d and %d has earned $100", headshot, issuerid);
GivePlayerMoney(issuerid, 100);
SendClientMessageToAll(COLOR_RED,string);
GameTextForPlayer(issuerid,"~r~Headshot",2000,3);
PlayerPlaySound(issuerid, 17802, 0.0, 0.0, 0.0);
GameTextForPlayer(playerid,"~r~Headshot",2000,3);
PlayerPlaySound(playerid, 17802, 0.0, 0.0, 0.0);
}
}
}
return 1;
}
Re: Headshot System Help - iLearner - 03.01.2017
PHP код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
if(issuerid != INVALID_PLAYER_ID && bodypart == 9)
{
new string[100], headshot[24], pname[24];
GetPlayerName(playerid, headshot, sizeof(headshot));
GetPlayerName(issuerid, pname sizeof(pname));
format(string, sizeof(string), "%s(%i) was shoot to the head by %s(%i) and %d has earned $100", headshot,playerid, pname, issuerid);
GivePlayerMoney(issuerid, 100);
SendClientMessageToAll(COLOR_RED,string);
GameTextForPlayer(issuerid,"~r~Headshot",2000,3);
PlayerPlaySound(issuerid, 17802, 0.0, 0.0, 0.0);
GameTextForPlayer(playerid,"~r~Headshot",2000,3);
PlayerPlaySound(playerid, 17802, 0.0, 0.0, 0.0);
SetPlayerHealth(playerid, 0.0);
}
return 1;
}
Some touch ups, though its recommended to check that playerid
is not dead.
Re: Headshot System Help -
XBoss30 - 03.01.2017
Thanks
Re: Headshot System Help -
Logic_ - 03.01.2017
you can do some checks in one line as well, also you can make the money amount random.