ZCMD help
#1

i found this command useful for my server

Quote:

if(strcmp(cmd,"/bet", true) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /bet [amount] [color (red or black)]");
new amount = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /bet [amount] [color (red or black)]");
new rand = random(2);
new string[128];
if(!rand)
{
if(strcmp(tmp, "red", true) == 0)
{
if(GetPlayerMoney(playerid) >= amount) {
GivePlayerMoney(playerid, amount);
format(string, sizeof(string), "RED WINS: You win %d dollars !",amount);
SendClientMessage(playerid, COLOR_WHITE, string);
}else SendClientMessage(playerid, COLOR_WHITE, "You dont have this moneys");
}
else if(strcmp(tmp, "black", true) == 0)
{
if(GetPlayerMoney(playerid) >= amount) {
GivePlayerMoney(playerid, -amount);
format(string, sizeof(string), "BLACK WINS: You lose %d dollars !",amount);
SendClientMessage(playerid, COLOR_WHITE, string);
}else SendClientMessage(playerid, COLOR_WHITE, "You dont have this moneys");
}else SendClientMessage(playerid, COLOR_WHITE, "Only Red or White");
}else{
if(strcmp(tmp, "black", true) == 0)
{
if(GetPlayerMoney(playerid) >= amount) {
GivePlayerMoney(playerid, amount);
format(string, sizeof(string), "BLACK WINS: You win %d dollars !",amount);
SendClientMessage(playerid, COLOR_WHITE, string);
}else SendClientMessage(playerid, COLOR_WHITE, "You dont have this moneys");
}
else if(strcmp(tmp, "red", true) == 0)
{
if(GetPlayerMoney(playerid) >= amount) {
GivePlayerMoney(playerid, -amount);
format(string, sizeof(string), "RED WINS: You lose %d dollars !",amount);
SendClientMessage(playerid, COLOR_WHITE, string);
}else SendClientMessage(playerid, COLOR_WHITE, "You dont have this moneys");
}else SendClientMessage(playerid, COLOR_WHITE, "Only Red or White");
}
return 1;
}

i always use zcmd and strok is difficult for me

i want to convert it to zcmd

i tried a lot to do it but i failed.

if someone could help make and convert this to zcmd or just only in the important parts

no problem if you modify or reduce the lines it but it should do the same thing.

Thanks
Reply
#2

pawn Код:
CMD:bet(playerid, params[])
{
    new Color[32], amount;
    if(sscanf(params, "ds[32]",amount, Color)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /bet [amount] [color (red or black)]");
    new rand = random(2);
    new string[128];
    if(!rand)
    {
        if(strcmp(Color, "red", true) == 0)
        {
            if(GetPlayerMoney(playerid) >= amount)
            {
                GivePlayerMoney(playerid, amount);
                format(string, sizeof(string), "RED WINS: You have won %d dollars !",amount);
                SendClientMessage(playerid, COLOR_WHITE, string);
            }
            else
            {
                SendClientMessage(playerid, COLOR_WHITE, "You dont have enough money.");
            }
        }
        else if(strcmp(Color, "black", true) == 0)
        {
            if(GetPlayerMoney(playerid) >= amount)
            {
                GivePlayerMoney(playerid, -amount);
                format(string, sizeof(string), "BLACK WINS: You have lost %d dollars !",amount);
                SendClientMessage(playerid, COLOR_WHITE, string);
            }
            else
            {
                SendClientMessage(playerid, COLOR_WHITE, "You dont have enough money.");
            }
        }
    }
    return 1;
}
Tell me the outcome, This is untested.
Reply
#3

Use sscanf instead of strtok.
Reply
#4

(57)warning 203 : symbol is never used : "bet"

no line 57

line 55 : return 1;
line 56: }

thanks for helping


if i could get one like this it would be more better for me to understand ive been looking it for weeks

i want to make a command with ZCMD

/bet amount red/black

example; /bet 100 red

if red comes out

RED
+$100

if black

BLACK
-$100
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)