What did I do wrong? -
UnholyBeast - 18.02.2017
Alright. I'm trying to make a command that changes both colors of your current vehicle, but the command stops and returns nothing if you use /carcolor 4 5. It only works if you use /carcolor 4.
CODE REMOVED
Re: What did I do wrong? -
JesterlJoker - 18.02.2017
Just do this
PHP код:
CMD:carcolor(playerid, cmd[], cmdtext[])
{
new string[144], vcolor1, vcolor2;
if(!IsPlayerSpawned(playerid))
return SendMessage(100, playerid, COLOR_WHITE, ""#COL_ERROR"[ERROR]: "#COL_WHITE"You must spawn before using this command.");
if(!IsPlayerInAnyVehicle(playerid))
return SendMessage(100, playerid, COLOR_WHITE, ""#COL_ERROR"[ERROR]: "#COL_WHITE"You are not in a vehicle.");
if(sscanf(params, "dd", vcolor1, vcolor2)) return SendClientMesage(playerid, COLOR_WHITE, "USAGE:/carcolor [color1] [color2]");
ChangeVehicleColor(GetPlayerVehicleID(playerid), vcolor1, vcolor2);
format(string, sizeof(string), "Vehicle colors changed to %d, and %d.", vcolor1, vcolor2);
SendMessage(100, playerid, COLOR_REGULAR_PLAYER, string);
return 1;
}
EDIT:much better
Re: What did I do wrong? -
UnholyBeast - 18.02.2017
Quote:
Originally Posted by JesterlJoker
Just do this
PHP код:
CMD:carcolor(playerid, cmd[], cmdtext[])
{
new string[144], vcolor1, vcolor2;
if(!IsPlayerSpawned(playerid))
return SendMessage(100, playerid, COLOR_WHITE, ""#COL_ERROR"[ERROR]: "#COL_WHITE"You must spawn before using this command.");
if(!IsPlayerInAnyVehicle(playerid))
return SendMessage(100, playerid, COLOR_WHITE, ""#COL_ERROR"[ERROR]: "#COL_WHITE"You are not in a vehicle.");
if(sscanf(params, "dd", vcolor1, vcolor2)) return SendClientMesage(playerid, COLOR_WHITE, "USAGE:/carcolor [color1] [color2]");
ChangeVehicleColor(GetPlayerVehicleID(playerid), vcolor1, vcolor2);
format(string, sizeof(string), "Vehicle colors changed to %d, and %d.", vcolor1, vcolor2);
SendMessage(100, playerid, COLOR_REGULAR_PLAYER, string);
return 1;
}
EDIT:much better
|
I wouldn't say it is. Now it's not compiling.
Код:
error 017: undefined symbol "params"
.
I've tried making params a new define, and it still only lets me change the first color.
Re: What did I do wrong? -
RyderX - 18.02.2017
PHP код:
CMD:carcolor(playerid, params[])
{
if(GetPlayerState(playerid) != 2) return SendClientMessage(playerid, 0xFF0000FF, "You are not driving a vehicle.");
new color[2];
if(sscanf(params, "iI(-1)", color[0], color[1]))
{
return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /carcolor <color1> <color2>");
}
if(color[1] == -1) color[1] = color[0]; // If color2 was left out, set it the same as color 1
new szSuccess[44];
format(szSuccess, sizeof(szSuccess), "Vehicle colors changed to: {FFFFFF}%i and %i.", color[0], color[1]);
SendClientMessage(playerid, 0x00FF00FF, szSuccess);
ChangeVehicleColor(GetPlayerVehicleID(playerid), color[0], color[1]);
return 1;
}
try ZCMD one.
Re: What did I do wrong? -
UnholyBeast - 18.02.2017
I've taken over development of a gamemode, and I am just trying to get familiar with it's own command processor. Here's a command that works just fine. That uses multiple variables, and doesn't require the use of params, or zcmd.
CODE REMOVED. If you still feel like helping. Please PM me.
Re: What did I do wrong? -
Sew_Sumi - 18.02.2017
Keep it to the thread, shuffling your assistance off to PMs avoids helping anyone else who has this issue.
The reason it's only getting one color, is because you're only looking for one color with sscanf.
RyderX has the sscanf method you need to use in the command that they handed you,
Re: What did I do wrong? -
UnholyBeast - 18.02.2017
DELETED
Re: What did I do wrong? -
Sew_Sumi - 18.02.2017
You may as well delete the entire thread considering you've removed the code on a forum that holds information like this to help the next people who are looking at getting help.
Re: What did I do wrong? -
UnholyBeast - 18.02.2017
If I could I would.
Re: What did I do wrong? -
Sew_Sumi - 18.02.2017
You can, click top right thread tools, delete thread.
Bare in mind that doing what you've done, deleting the code on the forum, will make you unappealing to help in the future...
And even then, when you edit the thread, chances are that the ****** cache already has archived it, so in the larger scale, it's a pointless paranoia that you've got.