Author Topic: a few stocks i made.  (Read 318 times)

Vertical

  • Newbie
  • *
  • Posts: 15
  • Reputation +0/-0
    • View Profile
a few stocks i made.
« on: February 09, 2011, 10:52:35 am »
I found theese stocks quite useful at times, i hope you enjoy!

GetClosestPlayer(playerid,range);
Description: Gets the closest player to a range amount of your choise (50 is defult) requires PlayerToPoint!


Quote
stock GetClosestPlayer(playerid,range = 50)
{
new splayer,jon;
if(IsPlayerConnected(playerid))
{
jon = MAX_PLAYERS * 50;
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
for(new r = range; r > 0; r--) {
for(new i = 0; i < MAX_PLAYERS; i++) {
if(i==playerid)  continue;
if(PlayerToPoint(r, i, x, y, z))
{
jon--;
splayer = i;
}
}
}
if(jon == MAX_PLAYERS * 50) splayer = INVALID_PLAYER_ID;
}
return splayer;
}

ReturnUser(name,playerid);
Description: My version of the ReturnUser function, it is easier to find the user using this since it checks if its ANYWHERE in the name, and not just from the beggining, for example:

players online:
0.Edd
1.Johny
2.Gai
3.Homo
4.Vertical
if i type in "Omo" it will return 2, if i type in "Ical" it will return 4 etc.

Quote
ReturnUser(const playername[], user = INVALID_PLAYER_ID)
{
      new i;
      new hasmultiple=-1;
      new ourplayer = -1;
      new tmpuname[MAX_STRING];
      for (i=0;i<MAX_PLAYERS;i++)
      {
      if (IsPlayerConnected(i))
      {
      GetPlayerName(i,tmpuname,sizeof(tmpuname));
      if (strfind(tmpuname,playername,true) != -1)
      {
         hasmultiple++;
         ourplayer = i;
      }
      if (hasmultiple>0)
      {
      SendClientMessage(user,ARED,"More Then One Player Found, Please Be More Accurate!");
      return INVALID_PLAYER_ID;
      }
      }
      }
      if(IsNumeric(playername) && IsPlayerConnected(strval(playername)))
      {
      hasmultiple++;
      ourplayer = strval(playername);
      if (hasmultiple>0)
      {
      SendClientMessage(user,0xA80000FF,"More Then One Player Found, Please Be More Accurate!");
      return INVALID_PLAYER_ID;
      }
      }
      return ourplayer;
}
i will release some more soon,

NOTE: b4  releasing them i changed a few things to make them more comfortable for the public, if you find any bugs (which i doubt you will) please contact me.

if you have any requests, dont hasitate to ask.  ;)
« Last Edit: February 09, 2011, 11:01:32 am by Vertical »

Share on Bluesky Share on Facebook


Jane

  • Management
  • Full
  • *******
  • Posts: 130
  • Reputation +1/-0
  • mIRC Scripters
    • View Profile
Re: a few stocks i made.
« Reply #1 on: February 09, 2011, 01:22:49 pm »
Great job, looking forward for more of you amaizing Jobs!

King_Hual

  • Trial Moderator
  • Newbie
  • ***
  • Posts: 36
  • Reputation +3/-2
    • View Profile
Re: a few stocks i made.
« Reply #2 on: February 09, 2011, 03:11:41 pm »
Ah yes, I remember creating something like the "Return User" stock for "!players" in the IRC plugin. Useful snippets :p

Vertical

  • Newbie
  • *
  • Posts: 15
  • Reputation +0/-0
    • View Profile
Re: a few stocks i made.
« Reply #3 on: February 09, 2011, 04:58:22 pm »
Thanks for the support.  :)