Hey all! I'm updating SMLIB to new syntax, and want to implement methodmaps properly for UserMessages. Is the following valid or even correct?
PHP Code:
stock bool Client_ScreenFade(int client, int duration, int mode, int holdtime=-1, int r=0, int g=0, int b=0, int a=255, bool reliable=true)
{
Handle userMessage = StartMessageOne("Fade", client, (reliable?USERMSG_RELIABLE:0)); // Can view_as be used here to convert to Protobuf/BfWrite?
if (userMessage == null) {
return false;
}
if (GetFeatureStatus(FeatureType_Native, "GetUserMessageType") == FeatureStatus_Available &&
GetUserMessageType() == UM_Protobuf) {
Protobuf message = UserMessageToProtobuf(userMessage); // Is this valid, and does this need to be deleted below?
int color[4];
color[0] = r;
color[1] = g;
color[2] = b;
color[3] = a;
message.SetInt("duration", duration);
message.SetInt("hold_time", holdtime);
message.SetInt("flags", mode);
message.SetColor("clr", color);
}
else {
BfWrite message = UserMessageToBfWrite(userMessage); // Is this valid, and does this need to be deleted below?
message.WriteShort(duration); // Fade duration
message.WriteShort(holdtime); // Fade hold time
message.WriteShort(mode); // What to do
message.WriteByte(r); // Color R
message.WriteByte(g); // Color G
message.WriteByte(b); // Color B
message.WriteByte(a); // Color Alpha
}
EndMessage();
return true;
}
The wiki for UserMessages is still using old syntax/non-methodmapped functions, so this could also be used to update the wiki too :)