[Tutorial] Less verbose function-making
#1

Are you tired of having to type so much just to create a function?

Instead, throw this code at the top of your script (under the includes).

pawn Code:
#define F:%0(%1)    forward %0(%1); \
                    public %0(%1)
This...
pawn Code:
forward KickPublic(playerid);
public KickPublic(playerid)
{
    Kick(playerid);
}
becomes this:

pawn Code:
F:KickPublic(playerid)
{
    Kick(playerid);
}
Just a simple text replacement. You can still call the functions, set them to timers, etc.
Reply
#2

hmm might be useful thx

but this is the entire tutorial? lol
Reply
#3

What the f*ck? Just use Kick(playerid); lol, bad example.
Reply
#4

Quote:
Originally Posted by Jack_Leslie
View Post
What the f*ck? Just use Kick(playerid); lol, bad example.
Actually is not bad example. Why? Because if you use Kick(playerid); messages aren't going to show. This example is now used by Everyone.
Reply
#5

Quote:
Originally Posted by ]Rafaellos[
View Post
Actually is not bad example. Why? Because if you use Kick(playerid); messages aren't going to show. This example is now used by Everyone.
Is that stated in the tutorial? No, it's not.
Reply
#6

Quote:
Originally Posted by Jack_Leslie
View Post
Is that stated in the tutorial? No, it's not.
The tutorial is not meant for the Kick native, you should read the thread again, he just gave an example. Check wiki for more information about Kick native.
Reply
#7

Quote:
Originally Posted by Jack_Leslie
View Post
What the f*ck? Just use Kick(playerid); lol, bad example.
Reply
#8

Quote:
Originally Posted by iZN
View Post
The tutorial is not meant for the Kick native, you should read the thread again, he just gave an example. Check wiki for more information about Kick native.
As I said though, bad example, what if someone who's never scripted before comes across this thread, and thinks "Oh, that's how I need to kick a player from my server", they're going to start doing it that way, wasting time.
Reply
#9

And if I can add something to the discussion, this is an example.

It could totally by something like this

PHP Code:

native IsValidVehicle
(vehicleid);
F:respawnVehs()
{
      for(new 
0MAX_VEHICLESi++)
      {
            if(
IsValidVehicle(i)) SetVehicleToRespawn(i);
      }
      return 
SendClientMessageToAll(-1"All the vehicles have been delay respawned by an administrator !");
}
CMD:respawnall(playeridparams[])
{
      if(!
IsNumeric(params)) return SCM(playerid, -1"SYNTAX : /respawnall [Delay (seconds)]");
      new 
time strval(params);
      
SetTimer("respawnVehs"time*1000false);
      return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)