samp-streamer-plugin icon indicating copy to clipboard operation
samp-streamer-plugin copied to clipboard

Switch SetDynamicObjectMaterialText materialindex and text parameters

Open IstuntmanI opened this issue 5 years ago • 5 comments

native SetObjectMaterialText(objectid, text[], materialindex = 0,
materialsize = OBJECT_MATERIAL_SIZE_256x128, fontface[] = "Arial", fontsize = 24, bold = 1, fontcolor = 0xFFFFFFFF, backcolor = 0, textalignment = 0);

vs

native SetDynamicObjectMaterialText(STREAMER_TAG_OBJECT:objectid, materialindex, const text[],
materialsize = OBJECT_MATERIAL_SIZE_256x128, const fontface[] = "Arial", fontsize = 24, bold = 1, fontcolor = 0xFFFFFFFF, backcolor = 0, textalignment = 0);

I remember that this was discussed before, but probably not here on GitHub, as I can't find it, I can't remember if there was a reason for not switching them (probably because it makes more sense for index to be first, but compatibility with the regular SA-MP function is more important). Those two parameters should be switched to make it easy to convert from regular global objects, all it would require would be replacing "SetObjectMaterialText" to "SetDynamicObjectMaterialText".

Can't remember if there's a similar case for any other function.

IstuntmanI avatar Jul 17 '18 20:07 IstuntmanI

After having it the way it is for so long.. it'll be a HUGE pain in the ass for coders to convert all their mappings back to the new format (I myself have over 730,000 objects that are in the current format)

Chaprnks avatar Jul 18 '18 15:07 Chaprnks

How about we just create a new function and alias it for backwards compatibility, there's no point making a breaking API change.

Southclaws avatar Jul 18 '18 15:07 Southclaws

Yeah, that sounds like a great idea! Thanks Southclaws

Chaprnks avatar Jul 18 '18 16:07 Chaprnks

Following Windows API conventions (no real reason), the new name could simple be appended with C to indicate it's a compatible version: SetDynamicObjectMaterialTextC.

Southclaws avatar Jul 18 '18 16:07 Southclaws

Every other material native has the material index as the second parameter, so it was just done this way to be consistent. I did always try to make most of the streamer natives as similar as possible to their SA-MP counterparts, but several others (not just this one) have parameters that turned out to be jumbled around as well. Of course, as others pointed out, changing this now would mean breaking a lot of existing scripts.

I guess you could make some new alternate natives (appended with a C for compatible, or even an A for alias?) that resemble the SA-MP ones almost exactly, but I'm not sure this would actually benefit many people.

samp-incognito avatar Jul 23 '18 20:07 samp-incognito