Converting from dcmd to normal command(+rep)
#1

Код:
dcmd_lotto(playerid, params[])
{
    if(!strlen(params)) //If the player doesn't put a nubmer
    {
        SendClientMessage(playerid, 0x62FF32FF, "***Lotto information***"); //Lotto info
        SendClientMessage(playerid, 0x62FF32FF, "Pick a number between 1 and 100 with /lotto [1-100]"); //Lotto info
        new str[75]; //Creates the string
        format(str, sizeof(str), "Current Jackpot is $%d!!!!", Jackpot); //Formats the jackpot string
        SendClientMessage(playerid, 0x62FF32FF, str); //Shows the current jackpot
    }
    new Num = strval(params); //Makes the param that the player entered into a intiger
    if(Numbers[Num] == 1) //If the number is used
    {
        new str[75]; //Makes a variable
        format(str, sizeof(str), "Lotto number %d is already taken!", Num); //Formats a str 
        SendClientMessage(playerid, 0xE21F1FFF, str); //Sends the message
        return 1;
    }
    if(GetPVarInt(playerid, "LottoNumber") != 0) return SendClientMessage(playerid, 0xE21F1FFF, "You have already got a lotto number");
    SetPVarInt(playerid, "LottoNumber", Num); //Sets the players number
    Numbers[Num] = 1; //Number is used
    GivePlayerMoney(playerid, -TICKET_COST); //Takes away the ticket cost.
    new str[75];
    format(str, sizeof(str), " Lotto ticket brought! You now have number %d for the next draw", Num);
    SendClientMessage(playerid, 0x62FF32FF, str); //Lotto info
    format(str, sizeof(str), " Draws are held every %d minutes and the winners are announced. Current jackpot is $%d", LOTTO_DRAW, Jackpot);
    Jackpot = Jackpot + LOTTO_JACKPOT; //Ads to the lotto jackpot
    SendClientMessage(playerid, 0x62FF32FF, str); //Lotto info
    return 1;
}
i need to convert in into default server like ifstrcmp/lotto.....
Reply
#2

dcmd is based on strcmp...

just use a cmd processor like zcmd...ocmd..ycmd...rcmd...
Reply
#3

my gm is using if(strcmp(cmd, "/test", true)
so i need this type of command with that lotto too.
Reply
#4

If anything you should be converting your existing commands to a new system rather than the other way around. That said, dcmd should work fine with your existing code since it is, like Kaliber already said, based on strcmp. It's been a long time since I last used it, but I seem to remember some line that had to be put inside OnPlayerCommandText. So if you put that line above or below all your existing commands it should work fine.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)