SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts

Reply
 
Thread Tools Display Modes
Old 06/12/2009, 03:19 PM   #551
Correlli
Godfather
 
Correlli's Avatar
 
Join Date: May 2009
Location: Slovenia
Posts: 6,340
Reputation: 365
Default Re: Useful Functions

Quote:
Originally Posted by [K4L
Leopard ]
pawn Code:
stock SetServerName(name[])
{
  printf("Setting server name to: \"%s\"", name);
  return SendRconCommandEx("hostname %s", name);
}
Try to compile that, it will give you an error, because you can't return macro functions.
Correlli is offline   Reply With Quote
Old 06/12/2009, 03:40 PM   #552
MenaceX^
High-roller
 
Join Date: Aug 2008
Posts: 3,262
Reputation: 13
Default Re: Useful Functions

The strlen part in SendRconCommandEx is useless.
MenaceX^ is offline   Reply With Quote
Old 06/12/2009, 03:41 PM   #553
Balon
Big Clucker
 
Join Date: Oct 2007
Posts: 108
Reputation: 2
Default Re: Useful Functions

Quote:
Originally Posted by Don Correlli
pawn Code:
new
    FALSE = 0;

pawn Code:
#if !defined SendRconCommandEx
  #define SendRconCommandEx(%0,%1) \
  do \
  { \
    new \
        string[64]; \
    if(strlen(%0) > 0) \
    { \
      format(string, sizeof(string), %0, %1); \
      SendRconCommand(string); \
    } \
  } \
  while(FALSE)
#endif
Balon is offline   Reply With Quote
Old 06/12/2009, 03:41 PM   #554
MenaceX^
High-roller
 
Join Date: Aug 2008
Posts: 3,262
Reputation: 13
Default Re: Useful Functions

Quote:
Originally Posted by Balon
Quote:
Originally Posted by Don Correlli
pawn Code:
new
    FALSE = 0;

pawn Code:
#if !defined SendRconCommandEx
  #define SendRconCommandEx(%0,%1) \
  do \
  { \
    new \
        string[64]; \
    if(strlen(%0) > 0) \
    { \
      format(string, sizeof(string), %0, %1); \
      SendRconCommand(string); \
    } \
  } \
  while(FALSE)
#endif
Yeah I saw and edited the reply.
And by the way Don, they are all based on ******' #define function so you should give him credits.
MenaceX^ is offline   Reply With Quote
Old 06/12/2009, 03:46 PM   #555
pspleo
Gangsta
 
Join Date: Nov 2007
Posts: 747
Reputation: 4
Default Re: Useful Functions

Quote:
Originally Posted by Don Correlli
Quote:
Originally Posted by [K4L
Leopard ]
pawn Code:
stock SetServerName(name[])
{
  printf("Setting server name to: \"%s\"", name);
  return SendRconCommandEx("hostname %s", name);
}
Try to compile that, it will give you an error, because you can't return macro functions.
You are right. My fault.

Leo
pspleo is offline   Reply With Quote
Old 06/12/2009, 03:54 PM   #556
MenaceX^
High-roller
 
Join Date: Aug 2008
Posts: 3,262
Reputation: 13
Default Re: Useful Functions

Quote:
Originally Posted by [K4L
Leopard ]
Quote:
Originally Posted by Don Correlli
Quote:
Originally Posted by [K4L
Leopard ]
pawn Code:
stock SetServerName(name[])
{
  printf("Setting server name to: \"%s\"", name);
  return SendRconCommandEx("hostname %s", name);
}
Try to compile that, it will give you an error, because you can't return macro functions.
You are right. My fault.

Leo
What's this miserliness about lines?
MenaceX^ is offline   Reply With Quote
Old 06/12/2009, 04:30 PM   #557
_[HuN]_Epsilon_
Huge Clucker
 
Join Date: Apr 2009
Location: Behind You!
Posts: 265
Reputation: 9
Default Re: Useful Functions

pawn Code:
bool: IsEvenNumber(value)
{
    new estr[16];
    format(estr,16,"%.2f",floatdiv(value,2));
    if(!strval(estr[strfind(estr,".",true)+1])) return true;
    return false;
}
#define NotEvenNumber(%1) !IsEvenNumber(%1)

This function checks a given value is an even number or not. The macro checks the opposite thing.

Epsilon
_[HuN]_Epsilon_ is offline   Reply With Quote
Old 06/12/2009, 04:40 PM   #558
StrickenKid
Gangsta
 
Join Date: Feb 2009
Posts: 762
Reputation: 44
Default Re: Useful Functions

PlayerDirection(playerid)

This function gets the direction a player is going:

Returns:
N - North
E - East
S - South
W - West

Note that the function has been setup backwards because SA-MP's directions are backwards.

pawn Code:
stock PlayerDirection(playerid)
{
  new
        Float:ang,
        dir[2];
    if(IsPlayerInAnyVehicle(playerid))
        GetVehicleZAngle(GetPlayerVehicleID(playerid), ang);
    else
        GetPlayerFacingAngle(playerid, ang);
    if (ang > 45 && ang < 135)
        format(dir, sizeof(dir), "W");
    else if (ang > 135 && ang < 225)
        format(dir, sizeof(dir), "S");
    else if (ang > 225 && ang < 315)
        format(dir, sizeof(dir), "E");
    else
        format(dir, sizeof(dir), "N");
  return dir;
}
__________________
StrickenKid is offline   Reply With Quote
Old 06/12/2009, 07:36 PM   #559
Nero_3D
High-roller
 
Nero_3D's Avatar
 
Join Date: Jun 2007
Location: Germany
Posts: 2,849
Reputation: 675
Default Re: Useful Functions

Quote:
Originally Posted by <__Ǝthan__>
Note that the function has been setup backwards because SA-MP's directions are backwards.
I forgot if thats true but I know that the wiki try to tell me something different :S -> SetPlayerFacingAngle
Nero_3D is offline   Reply With Quote
Old 06/12/2009, 07:50 PM   #560
StrickenKid
Gangsta
 
Join Date: Feb 2009
Posts: 762
Reputation: 44
Default Re: Useful Functions

Yes, and that's wrong, this is how it is:

Code:
    north (0)
     |
(90)west- -east (270)
     |
   south (180)
__________________
StrickenKid is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Include] [INC] LSF - Lorenc's Simple Functions (w/ gang/clan functions) Lorenc_ Includes 14 21/04/2018 04:06 AM
Functions? sciman001 Help Archive 7 19/03/2011 03:03 PM
How to get functions? Twain32 Help Archive 4 08/10/2010 07:37 PM
[Include] [INC] SA:MP New Functions 0.4a DKN ipsBruno Lançamentos/Releases 22 17/06/2010 08:38 AM
What this functions do? harrold Help Archive 2 08/05/2009 11:30 PM


All times are GMT. The time now is 06:27 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.