30.07.2013, 21:56
Something that I've always been intrigued about is why the native SA:MP functions seem to shy away from using a return whenever possible. What I mean by this is that the "get" functions are generally of the type where you must supply a variable as an argument, and then the result is saved to this variable (I forget the name for this type but let's call it a "supplied receiver function".) There seem to be a lot of times where the ease of scripting is impeded upon by being forced to use "supplied receiver functions" where the code could be a lot shorter if we were able to just use a function that directly returns the result, and so I'm just wondering why it's programmed that way.
An example of how code could be shortened if more "return" functions were used:
Simply becomes:
Whilst it may look more complex, I think that it does look neater as well and I know a lot of others agree.
Why do you think the SA:MP natives have been programmed this way?
Also, I'm not complaining. I do have a function that simply returns the player's name, health, armour, etc, because I find it a lot easier to program with them - I haven't found any uses where I need to store the result to a variable where I couldn't just directly allocate it, and that's why I'm curious.
An example of how code could be shortened if more "return" functions were used:
pawn Code:
new health;
GetPlayerHealth(playerid, health);
SetPlayerHealth(playerid, health + 5);
pawn Code:
SetPlayerHealth(playerid, GetPlayerHealth(playerid) + 5));
Why do you think the SA:MP natives have been programmed this way?
Also, I'm not complaining. I do have a function that simply returns the player's name, health, armour, etc, because I find it a lot easier to program with them - I haven't found any uses where I need to store the result to a variable where I couldn't just directly allocate it, and that's why I'm curious.