Author Topic: Long shot code  (Read 3554 times)

0 Members and 1 Guest are viewing this topic.

Offline NeskWriter

  • Crime Boss
  • ****
  • Posts: 355
    • View Profile
Long shot code
« on: October 13, 2013, 04:01:16 pm »
As you may already know, this code deals with a long shot. Yes, if you kill a player, a stock function will compare the distance between you and your victim/you and the guy who shot you. if the distance is longer than 50 meters, you/your killer will be congratulated.

P.S. Seby has told me that it was not a new idea, so excuse me if the similar code already exists!

[pawn]
public OnPlayerDeath(playerid, killerid, reason, bodypart)
{
    if(killerid != INVALID_PLAYER_ID)
    {
        if(GetDistanceBetween(playerid, killerid) >= 50) //Replace "50" with your own integer, if you want. "50" is the default distance of long shot between victim and killer.
        {
            new longshotmsg[128];
            format(longshotmsg, sizeof(longshotmsg), "%s killed %s by a long shot.", RetPlayerName(killerid), RetPlayerName(playerid));
            SendClientMessageToAll(COLOR_GREEN, longshotmsg);
            SetPlayerMoney(killerid, GetPlayerMoney(playerid) + 1000);
            SendClientMessage(killerid, COLOR_GREEN, "You've been given $1000 as a bonus of long shot");
        }
    }
    return 0;
}
[/pawn]
Here are stock functions I used:
[pawn]
//A stock function to get distance between two players (very similar to that one from GUPS)
stock GetDistanceBetween(playerid, playerid2)
{
new Float:px, Float:py, Float:pz, Float:px2, Float:py2, Float:pz2, Float:distance;
GetPlayerPos(playerid, px, py, pz);
GetPlayerPos(playerid2, px2, py2, pz2);
distance = floatsqroot(floatpower((px2 - px), 2) + floatpower((py2 - py), 2) + floatpower((pz2 - pz), 2));
return floatround(distance);
}
//This function returns player name
stock RetPlayerName(playerid)
{
    new pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, sizeof(pname));
    return pname;
}
//This is definition of HEX-code of green color
#define COLOR_GREEN 0x00FF00AA
[/pawn]


-Funniest quotes-

Quote from: asad3man
i cant able to understand

Offline sseebbyy

  • VC:MP Veteran
  • *****
  • Posts: 774
  • Immortal VC:MP Player
    • View Profile
    • Zombie Invasion => Server Forum [DEAD PROJECT]
Re: Long shot code
« Reply #1 on: October 13, 2013, 05:42:48 pm »
If you reposted this, why you didn't moved it to the Snippet Showroom ?

Quote
Painful/Noob scripters acts like: I Am The Best Scripter Because I Announce My Releases With Big Font Size Without Giving Too Much Info' In The Hope They All Will Download And Check It. I Ignore Bad Replies, Replies That I Could Learn From, And Replies With So Much Text.



Offline NeskWriter

  • Crime Boss
  • ****
  • Posts: 355
    • View Profile
Re: Long shot code
« Reply #2 on: October 13, 2013, 05:51:47 pm »
If you reposted this, why you didn't moved it to the Snippet Showroom ?

Sorry, I've got monster laggs with internet today. Let someone of moders move it. Thanx


-Funniest quotes-

Quote from: asad3man
i cant able to understand

Offline NeskWriter

  • Crime Boss
  • ****
  • Posts: 355
    • View Profile
Re: Long shot code
« Reply #3 on: October 16, 2013, 06:01:13 pm »
stormeus can I just up my topic?


-Funniest quotes-

Quote from: asad3man
i cant able to understand

Offline stormeus

  • VC:MP Developer
  • VC:MP Veteran
  • *
  • Posts: 1122
    • View Profile
Re: Long shot code
« Reply #4 on: October 16, 2013, 10:34:10 pm »
Don't bump threads unless you have something to add; it's spammy.
Do not PM me for support.