sscanf in kinda big command.
#1

Hey, im making a big command with zcmd and sscanf.
But im having some troubles making it work properly.
Its a vehicle cmd /v [sell/buy/find]
I think its something wrong with the way i use sscanf, can anyone help me get this right?

http://pastebin.com/c6vmBRqz
Reply
#2

pawn Код:
CMD:v(playerid, params[])
{
    new amount, string[128], objectives[12], targetid;

    if(sscanf(params, "s[12]du", objectives, amount, targetid)) SendClientMessage(playerid, COLOR_RED, "{F42626}[Usage] {FFFFFF}/v [sell/buy/find]");
    else if(!strcmp(objectives, "sell", true))
    {
        if(amount > ...) SendClientMessage(playerid, COLOR_RED, "amount must be higher than ...");
        else if(!IsPlayerConnected(targetid)) SendClientMessage(playerid, COLOR_RED, "id is offline");
        else{
            // set amount and targetid
        }
    }
    else if(!strcmp(objectives, "buy", true))
    {
    }
    else if(!strcmp(objectives, "find", true))
    {
    }
    else SendClientMessage(playerid, COLOR_RED, "{F42626}[Usage] {FFFFFF}/v [sell/buy/find]");
    return 1;
}
Reply
#3

Ok, i got the commands working now. When i type /v ig it shows use: /v [sell/buy/find].
But when i do /v find it dosent show any text. How to make when i do '/v find' let the game send you msg 'Use: /v find [id]' ?
Also when i do /v find carid ig, it shows 'use: /v [sell/buy/find]', i just want it to show when player type: /v
Reply
#4

Optional values
pawn Код:
CMD:v(playerid, params[])
{
    new amount, string[128], objectives[12], targetid;

    if(sscanf(params, "s[12]D(-1)U(-1)", objectives, amount, targetid)) SendClientMessage(playerid, COLOR_RED, "{F42626}[Usage] {FFFFFF}/v [sell/buy/find]");
    else if(!strcmp(objectives, "sell", true))
    {
        if(amount > ...) SendClientMessage(playerid, COLOR_RED, "amount must be higher than ...");
        else if(!IsPlayerConnected(targetid)) SendClientMessage(playerid, COLOR_RED, "id is offline");
        else{
            // set amount and targetid
        }
    }
    else if(!strcmp(objectives, "buy", true))
    {
    }
    else if(!strcmp(objectives, "find", true))
    {
        if(amount == (-1) || targetid == (-1)) SendClientMessage(playerid, COLOR_RED, "'Use: /v find [id]'");
    }
    else SendClientMessage(playerid, COLOR_RED, "{F42626}[Usage] {FFFFFF}/v [sell/buy/find]");
    return 1;
}
Reply
#5

Just what i needed! Thanks alot for your help Jefff!

if(amount == (-1) || targetid == (-1))
it didnt work on /v sell tho, what do i need to put there?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)