15.07.2011, 17:40
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.;
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.
Код:
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; }