Less verbose function-making -
Snipa - 17.06.2014
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.
Re: Less verbose function-making -
Ihateyou - 17.06.2014
hmm might be useful thx
but this is the entire tutorial? lol
Re: Less verbose function-making -
Jack_Leslie - 17.06.2014
What the f*ck? Just use Kick(playerid); lol, bad example.
Re: Less verbose function-making -
]Rafaellos[ - 17.06.2014
Quote:
Originally Posted by Jack_Leslie
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.
Re: Less verbose function-making -
Jack_Leslie - 17.06.2014
Quote:
Originally Posted by ]Rafaellos[
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.
Re: Less verbose function-making -
iZN - 17.06.2014
Quote:
Originally Posted by Jack_Leslie
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.
Re: Less verbose function-making -
Snipa - 17.06.2014
Quote:
Originally Posted by Jack_Leslie
What the f*ck? Just use Kick(playerid); lol, bad example.
|
Re: Less verbose function-making -
Jack_Leslie - 18.06.2014
Quote:
Originally Posted by iZN
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.
Re : Less verbose function-making -
S4t3K - 18.06.2014
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 i = 0; i < MAX_VEHICLES; i++)
{
if(IsValidVehicle(i)) SetVehicleToRespawn(i);
}
return SendClientMessageToAll(-1, "All the vehicles have been delay respawned by an administrator !");
}
CMD:respawnall(playerid, params[])
{
if(!IsNumeric(params)) return SCM(playerid, -1, "SYNTAX : /respawnall [Delay (seconds)]");
new time = strval(params);
SetTimer("respawnVehs", time*1000, false);
return 1;
}