What did I do wrong?
#1

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
Reply
#2

Just do this
PHP код:
CMD:carcolor(playeridcmd[], cmdtext[])
{
    new 
string[144], vcolor1vcolor2;
    if(!
IsPlayerSpawned(playerid))
        return 
SendMessage(100playeridCOLOR_WHITE""#COL_ERROR"[ERROR]: "#COL_WHITE"You must spawn before using this command.");
    
if(!IsPlayerInAnyVehicle(playerid))
        return 
SendMessage(100playeridCOLOR_WHITE""#COL_ERROR"[ERROR]: "#COL_WHITE"You are not in a vehicle.");
    
if(sscanf(params"dd"vcolor1vcolor2)) return SendClientMesage(playeridCOLOR_WHITE"USAGE:/carcolor [color1] [color2]");
    
ChangeVehicleColor(GetPlayerVehicleID(playerid), vcolor1vcolor2);
    
format(stringsizeof(string), "Vehicle colors changed to %d, and %d."vcolor1vcolor2);
    
SendMessage(100playeridCOLOR_REGULAR_PLAYERstring);
    return 
1;

EDIT:much better
Reply
#3

Quote:
Originally Posted by JesterlJoker
Посмотреть сообщение
Just do this
PHP код:
CMD:carcolor(playeridcmd[], cmdtext[])
{
    new 
string[144], vcolor1vcolor2;
    if(!
IsPlayerSpawned(playerid))
        return 
SendMessage(100playeridCOLOR_WHITE""#COL_ERROR"[ERROR]: "#COL_WHITE"You must spawn before using this command.");
    
if(!IsPlayerInAnyVehicle(playerid))
        return 
SendMessage(100playeridCOLOR_WHITE""#COL_ERROR"[ERROR]: "#COL_WHITE"You are not in a vehicle.");
    
if(sscanf(params"dd"vcolor1vcolor2)) return SendClientMesage(playeridCOLOR_WHITE"USAGE:/carcolor [color1] [color2]");
    
ChangeVehicleColor(GetPlayerVehicleID(playerid), vcolor1vcolor2);
    
format(stringsizeof(string), "Vehicle colors changed to %d, and %d."vcolor1vcolor2);
    
SendMessage(100playeridCOLOR_REGULAR_PLAYERstring);
    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.
Reply
#4

PHP код:
CMD:carcolor(playeridparams[])
{
    if(
GetPlayerState(playerid) != 2) return SendClientMessage(playerid0xFF0000FF"You are not driving a vehicle.");
    new 
color[2];
    if(
sscanf(params"iI(-1)"color[0], color[1]))
    {
        return 
SendClientMessage(playerid0xFF0000FF"USAGE: /carcolor <color1> <color2>");
    }
    if(
color[1] == -1color[1] = color[0]; // If color2 was left out, set it the same as color 1
    
new szSuccess[44];
    
format(szSuccesssizeof(szSuccess), "Vehicle colors changed to: {FFFFFF}%i and %i."color[0], color[1]);
    
SendClientMessage(playerid0x00FF00FFszSuccess);
    
ChangeVehicleColor(GetPlayerVehicleID(playerid), color[0], color[1]);
    return 
1;

try ZCMD one.
Reply
#5

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.
Reply
#6

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,
Reply
#7

DELETED
Reply
#8

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.
Reply
#9

If I could I would.
Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)