SetDynamicObjectMaterial help -
Obsidian - 30.04.2018
Hi,
I have some problems with a command where I test the output of specific commands.
Код:
CMD:testcmd1(playerid, params[] )
{
new color[12];
if (sscanf(params, "s[12]", color))
return SendSyntaxMessage(playerid, "/testcmd [color]");
new Float:px, Float:py, Float:pz;
GetPlayerPos(playerid, px, py, pz);
new test = CreateDynamicObject(19462, px, py, pz, 0.0, 0.0, 0.0);
SetDynamicObjectMaterial(test, 0, 12979, "sw_block9", "sw_wall03", color);
return 1;
}
When compiled, I get the following error:
Код:
error 035: argument type mismatch (argument 6)
It's a type missmatch but somehow I have to pass the variable I get so I can create the object. Anyway, if someone knows how to do this properly, I would love to hear him out.
Re: SetDynamicObjectMaterial help -
Pottus - 30.04.2018
The color parameter does not take a string it takes an integer. You also need to do more checks to validate your input.
Re: SetDynamicObjectMaterial help -
git - 30.04.2018
You could use
strval to convert the string into an integer.
https://sampwiki.blast.hk/wiki/Strval
Re: SetDynamicObjectMaterial help -
Obsidian - 30.04.2018
Well, it worked using strval to some degree, however if I input a valid data (0xFF0000FF -> dark blue) the object gets spawned with the correct texture but with the default color
THe new code looks like:
Код:
CMD:testcmd1(playerid, params[] )
{
new color[12];
new colored;
if (sscanf(params, "s[12]", color))
return SendSyntaxMessage(playerid, "/testcmd [color]");
new Float:px, Float:py, Float:pz;
GetPlayerPos(playerid, px, py, pz);
colored = strval(color);
new test = CreateDynamicObject(19462, px, py, pz, 0.0, 0.0, 0.0);
SetDynamicObjectMaterial(test, 0, 12979, "sw_block9", "sw_wall03", colored);
return 1;
}
Re: SetDynamicObjectMaterial help -
Pottus - 30.04.2018
Again no checks to validate input....
Do we have input? Yes ----> What Kind? ----> Integer or Hex value ?
Re: SetDynamicObjectMaterial help -
Obsidian - 30.04.2018
Hex value, the command at this point is just for me to test the output in the end I will check the input and etc
Once I figure out this, I will take the data from the database
Re: SetDynamicObjectMaterial help -
Obsidian - 01.05.2018
Nump
Re: SetDynamicObjectMaterial help -
RoboN1X - 01.05.2018
As simple as this:
Код:
CMD:testcmd1(playerid, params[])
{
new hex:color;
if (sscanf(params, "x", color))
return SendSyntaxMessage(playerid, "/testcmd1 [color]");
new Float:px, Float:py, Float:pz;
GetPlayerPos(playerid, px, py, pz);
new test = CreateDynamicObject(19462, px, py, pz, 0.0, 0.0, 0.0);
SetDynamicObjectMaterial(test, 0, 12979, "sw_block9", "sw_wall03", color);
return 1;
}
Either hex or integer color code will work. When you process it to database, save and load the integer value.
You also want to use GetXYInFrontOfPlayer since the current code would stuck the object on player's character.