Post reply

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.
Name:
Email:
Subject:
Message icon:

Verification:

shortcuts: hit alt+s to submit/post or alt+p to preview


Topic Summary

Posted by: Vertical
« on: February 09, 2011, 04:58:22 pm »

Thanks for the support.  :)
Posted by: King_Hual
« 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
Posted by: Jane
« on: February 09, 2011, 01:22:49 pm »

Great job, looking forward for more of you amaizing Jobs!
Posted by: Vertical
« 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.  ;)