How to create own function
#1

Hi, need a short tutorial how to make own function.
Reply
#2

First, forward it:
pawn Код:
forward FunctionName(parameters);
The parameters are just variable names that you use. Treat them the same as other variables:
pawn Код:
FunctionName (id, message[], Float:radius) //first one is an integer, then string, then a floating point number
Second, declare it:
pawn Код:
public FunctionName(parameters) //Must match the forward line EXACTLY
{
     return 1;
}
Then use it. Make a function for repeated tasks throughout the script to save time.
Reply
#3

thank's, exactly what i needed
Reply
#4

How to use string? Can you give me an example?
Reply
#5

callbacks and functions aren't the same.
use
pawn Код:
FunctionName(parameters)
{
  return value;
}
or
pawn Код:
stock FunctionName(parameters)
{
  return value;
}
value equals the number (or array) you want to return. Use value as 1, if you dont need to return anything specific. Read on wiki the difference between stock functions and common functions
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)