Hi all,
For the longest time I've been creating custom script commands simply so I can read a value from struct map_session_data{}. For example, I wanted to return the value of sd->state.showzeny, so I created a simple buildin just for that purpose.It would go something like this:
BUILDIN(read_showzeny)
{
struct map_session_data *sd = script->rid2sd(st);
if (sd != NULL)
script_pushint(st, sd->state.showzeny);
else
script_pushint(st, -1);
return true;
}
Seems not bad, right? But then it got me thinking. I'm creating all these script commands for one simple action. Surely there's a better way? That's when I stumbled across the getunitdata() command.
Then it came to me - create a script command which can fetch this data for a player.
The Goal
Create a script command which can fetch the data which map_session_data provides. It would work similar to getunitdata():
*getplayerdata(<account id>, <DataType>{,<Variable>})
Maybe also setplayerdata()?
Helped needed: The one thing is, not all the stuff in there is useful. Maybe it would be best to selectively choose what can be retrieved as data? I made a list for this stuff. Let me know what you think.