Convert this into ZCMD.
#1

I need someone to convert from strcmp to zcmd (cmd). I have some troubles i try but i failed so i wanna see the correct. Thanks.


pawn Код:
if(strcmp(cmd, "/sladoled", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pJob] != 26)
            {
                SendClientMessage(playerid, COLOR_GREY, "   You dont have the job!");
                return 1;
            }
            new tmpcar = GetPlayerVehicleID(playerid);
            if(IsASladCar(tmpcar))
            {
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp))
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "HELP: /sladoled [playerid/PartOfName] [cjena]");
                    return 1;
                }
                new money;
                giveplayerid = ReturnUser(tmp);
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp)) { return 1; }
                money = strval(tmp);
                if(money < 1 || money > 50)
                {
                    SendClientMessage(playerid, COLOR_GREY, "  Price cant be lower than 1$ or more than!");
                    return 1;
                }
                if(IsPlayerConnected(giveplayerid))
                {
                    if(giveplayerid != INVALID_PLAYER_ID)
                    {
                        if(ProxDetectorS(8.0, playerid, giveplayerid))
                        {
                            if(giveplayerid == playerid)
                            {
                                SendClientMessage(playerid, COLOR_GREY, "   You cant give a icecream to yourself !");
                                return 1;
                            }
                            GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                            GetPlayerName(playerid, sendername, sizeof(sendername));
                            format(string, sizeof(string), "* You sold an iceccream to %s for $%d.", giveplayer, money);
                            SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
                            format(string, sizeof(string), "* IceMan %s wants to sell you a $%d, (typej /accept sladoled) to accept.", sendername, money);
                            SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, string);
                            IceCreamOffer[giveplayerid] = playerid;
                            IceCreamPrice[giveplayerid] = money;
                        }
                        else
                        {
                            SendClientMessage(playerid, COLOR_GREY, "   The player is not near you!");
                        }
                    }
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "   The player is offline.!");
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GRAD2, "   You are not in a Ice-cream Truck.");
                return 1;
            }
        }
        return 1;
    }
Reply
#2

I think changing
pawn Код:
if(strcmp(cmd, "/sladoled", true) == 0)
to
pawn Код:
CMD:sladoled(playerid,params[])
Would cover all of the converting.
Reply
#3

pawn Код:
CMD:sladoled(playerid,params[])
{
    if(PlayerInfo[playerid][pJob] != 26)
    {
        SendClientMessage(playerid, COLOR_GREY, "   You dont have the job!"); return 1;
    }
    new tmpcar = GetPlayerVehicleID(playerid);
    if(IsASladCar(tmpcar))
    {
        new string[128],idx;
        string = strtok(params, idx);
        if(!strlen(string)) { SendClientMessage(playerid, COLOR_GRAD2, "HELP: /sladoled [playerid/PartOfName] [cjena]"); return 1; }
        new gid = ReturnUser(string);
        string = strtok(params, idx);
        if(!strlen(string)) { SendClientMessage(playerid, COLOR_GRAD2, "HELP: /sladoled [playerid/PartOfName] [cjena]"); return 1; }
        new money = strval(string),name[24];
        if(money < 1 || money > 50)
        {
            SendClientMessage(playerid, COLOR_GREY, "  Price cant be lower than 1$ or more than!"); return 1;
        }
        if(IsPlayerConnected(gid))
        {
            if(ProxDetectorS(8.0, playerid, gid))
            {
                if(gid == playerid)
                {
                    SendClientMessage(playerid, COLOR_GREY, "   You cant give a icecream to yourself !"); return 1;
                }
                GetPlayerName(gid, name, sizeof(name));
                format(string, sizeof(string), "* You sold an iceccream to %s for $%d.", name, money);
                SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
                GetPlayerName(playerid, name, sizeof(name));
                format(string, sizeof(string), "* IceMan %s wants to sell you a $%d, (typej /accept sladoled) to accept.", name, money);
                SendClientMessage(gid, COLOR_LIGHTBLUE, string);
                IceCreamOffer[gid] = playerid; IceCreamPrice[gid] = money;
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "   The player is not near you!");
            }
        }
        else
        {
            SendClientMessage(playerid, COLOR_GREY, "   The player is offline.!");
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_GRAD2, "   You are not in a Ice-cream Truck.");
    }
    return 1;
}
here you go
Reply
#4

Quote:
Originally Posted by Jstylezzz
Посмотреть сообщение
I think changing
pawn Код:
if(strcmp(cmd, "/sladoled", true) == 0)
to
pawn Код:
CMD:sladoled(playerid,params[])
Would cover all of the converting.
You forgot one thing remove this non-sense line.

if(IsPlayerConnected(playerid))
Reply
#5

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
You forgot one thing remove this non-sense line.

if(IsPlayerConnected(playerid))
I always wondered why people had that selection? Why would you want to check if the player that is typing the command is online? :S
Reply
#6

It's a leftover from 0.1b where people could still send commands after being kicked or banned. It useless now, but it's the mentality. Copy-paste without ever asking yourself the question: why do I need this?

As for the original question, just changing the header of the command won't cut it because of cmdtext. Use sscanf.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)