SA-MP Forums Archive
Converting from dcmd to normal command(+rep) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Converting from dcmd to normal command(+rep) (/showthread.php?tid=619636)



Converting from dcmd to normal command(+rep) - bugmenotlol - 20.10.2016

Код:
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.....


Re: Converting from dcmd to normal command(+rep) - Kaliber - 20.10.2016

dcmd is based on strcmp...

just use a cmd processor like zcmd...ocmd..ycmd...rcmd...


Re: Converting from dcmd to normal command(+rep) - bugmenotlol - 20.10.2016

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


Re: Converting from dcmd to normal command(+rep) - Vince - 20.10.2016

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.