[Tutorial] Macro Example VIA Distance Formula
#5

Yeah but doing that, the code has to call the function which would take time, not a lot of time but it would still take some time. If you use a macro it is processed when it is compiled, so your compiled code for the distance function actually turns into this when its compiled.;
Код:
YCMD:distancefromstart(playerid, params[], help)
{
    if (help)
    {
        SendClientMessage(playerid, 0xFF0000AA, "Gets the distance between you and the only spawn point in this script");
    }
	else
	{
		new Float:x, Float:y, Float:z;
		GetPlayerPos(playerid, x, y, z);
		new string[64];
		format(string, sizeof(string), "%f, meters from start", (floatsqroot((x-1958.3783)*(x-1958.3783) + (y-1343.1572)*(y-1343.1572) + (z-15.3746)*(z-15.3746))));
		SendClientMessage( playerid, 0xFF3333FF, string);
	}
	return 1;
}
There are sometimes when its useful to create a macro, or just type it into the code. Your using the example where it'd just be easier to type it into the code. Not saying there's a right and a wrong way, both are valid, but I think many people would benefit from using a macro instead of a simple function.
Reply


Messages In This Thread
Macro Example VIA Distance Formula - by dowster - 12.07.2011, 21:55
Re: Macro Example VIA Distance Formula - by Daren_Jacobson - 12.07.2011, 23:37
Re: Macro Example VIA Distance Formula - by dowster - 13.07.2011, 03:03
Re: Macro Example VIA Distance Formula - by jameskmonger - 15.07.2011, 11:34
Re: Macro Example VIA Distance Formula - by dowster - 15.07.2011, 17:40
Re: Macro Example VIA Distance Formula - by Ricop522 - 15.07.2011, 19:30
Re: Macro Example VIA Distance Formula - by RyDeR` - 15.07.2011, 20:49
Re: Macro Example VIA Distance Formula - by dowster - 15.07.2011, 20:59

Forum Jump:


Users browsing this thread: 1 Guest(s)