How to convert to ZCMD?
#1

Hi everyone, I got this command code in my script, how do I convert this to ZCMD? (headache)
Oh, sorry for the indentation.

Quote:
Код:
	if(strcmp(cmd, "/deposit", true) == 0)
	{
		tmp = strtok(cmdtext, idx);
		if(CPS_IsPlayerInCheckpoint(playerid, cpbank))
		{
		    if(BankRecentlyUsed[playerid] == 0)
		    {
				if(strlen(tmp) == 0) return SendClientMessage(playerid, ERROR, "Use: /deposit [AMOUNT]");
				else
				{
				    if(strval(tmp) == 0) return SendClientMessage(playerid, ERROR, "The amount must be higher than 1.");
				    else
				    {
					    if(strval(tmp) > GetPlayerMoney(playerid)) return SendClientMessage(playerid, ERROR, "You do not have this amount.");
					    else
					    {
					        new string[150], string2[150];
					    	SetPlayerBankCash(playerid, GetPlayerBankCash(playerid)+strval(tmp));
					    	SendClientMessage(playerid, GREY, "|_| Bank |_|");
							format(string, sizeof(string), "Amount deposited: $%d", strval(tmp));
					    	format(string2, sizeof(string2), "Current state: $%d", GetPlayerBankCash(playerid));
					    	SendClientMessage(playerid, WHITE, string);
					    	SendClientMessage(playerid, WHITE, string2);
					    	GivePlayerMoney(playerid, -strval(tmp));
					    	printf("%s (%d) deposited $%d. Location: Bank", name, playerid, strval(tmp));
					    	return true;
						}
					}
				}
			}
			else if(BankRecentlyUsed[playerid] >= 1) SendClientMessage(playerid, ERROR, "You have recently robbed the Bank."); return true;
		}
		else return SendClientMessage(playerid, ERROR, "You must be on the Bank to use this command!");
	}
Reply
#2

Quote:
Originally Posted by Uberanwar
Посмотреть сообщение
Hi everyone, I got this command code in my script, how do I convert this to ZCMD? (headache)
Oh, sorry for the indentation.
Try This
pawn Код:
CMD:deposit(playerid, params[])
{
    tmp = strtok(cmdtext, idx);
    if(CPS_ISPlayerInCheckpoint(playerid, cpbank))
    {
        if(BankRecentlyUsed[playerid] == 0)
        {
            if(strlen(tmp) == 0) return SendClientMessage(playerid, ERROR, "Use: /deposit [AMOUNT]");
                else
                {
                    if(strval(tmp) == 0) return SendClientMessage(playerid, ERROR, "The amount must be higher than 1.");
                    else
                    {
                        if(strval(tmp) > GetPlayerMoney(playerid)) return SendClientMessage(playerid, ERROR, "You do not have this amount.");
                        else
                        {
                            new string[150], string2[150];
                            SetPlayerBankCash(playerid, GetPlayerBankCash(playerid)+strval(tmp));
                            SendClientMessage(playerid, GREY, "|_| Bank |_|");
                            format(string, sizeof(string), "Amount deposited: $%d", strval(tmp));
                            format(string2, sizeof(string2), "Current state: $%d", GetPlayerBankCash(playerid));
                            SendClientMessage(playerid, WHITE, string);
                            SendClientMessage(playerid, WHITE, string2);
                            GivePlayerMoney(playerid, -strval(tmp));
                            printf("%s (%d) deposited $%d. Location: Bank", name, playerid, strval(tmp));
                            return true;
                        }
                    }
                }
            }
            else if(BankRecentlyUsed[playerid] >= 1) SendClientMessage(playerid, ERROR, "You have recently robbed the Bank."); return true;
        }
        else return SendClientMessage(playerid, ERROR, "You must be on the Bank to use this command!");
    }
    return 1;
}
Reply
#3

This should be good.
pawn Код:
CMD:(playerid,params[])
    {
        if(CPS_IsPlayerInCheckpoint(playerid, cpbank))
        {
            if(BankRecentlyUsed[playerid] == 0)
            {
            if(sscanf(params, "d", type)) return SendClientMessage(playerid, ERROR, "Use:  /deposit [amount]");
                else
                {
                    if(strval(tmp) == 0) return SendClientMessage(playerid, ERROR, "The amount must be higher than 1.");
                    else
                    {
                        if(strval(tmp) > GetPlayerMoney(playerid)) return SendClientMessage(playerid, ERROR, "You do not have this amount.");
                        else
                        {
                            new string[150], string2[150];
                            SetPlayerBankCash(playerid, GetPlayerBankCash(playerid)+strval(tmp));
                            SendClientMessage(playerid, GREY, "|_| Bank |_|");
                            format(string, sizeof(string), "Amount deposited: $%d", strval(tmp));
                            format(string2, sizeof(string2), "Current state: $%d", GetPlayerBankCash(playerid));
                            SendClientMessage(playerid, WHITE, string);
                            SendClientMessage(playerid, WHITE, string2);
                            GivePlayerMoney(playerid, -strval(tmp));
                            printf("%s (%d) deposited $%d. Location: Bank", name, playerid, strval(tmp));
                            return true;
                        }
                    }
                }
            }
            else if(BankRecentlyUsed[playerid] >= 1) SendClientMessage(playerid, ERROR, "You have recently robbed the Bank."); return true;
        }
        else return SendClientMessage(playerid, ERROR, "You must be on the Bank to use this command!");
    }
Reply
#4

This code does not work

Quote:
Originally Posted by San1
Посмотреть сообщение
Try This
pawn Код:
CMD:deposit(playerid, params[])
{
    tmp = strtok(cmdtext, idx);
    if(CPS_ISPlayerInCheckpoint(playerid, cpbank))
    {
        if(BankRecentlyUsed[playerid] == 0)
        {
            if(strlen(tmp) == 0) return SendClientMessage(playerid, ERROR, "Use: /deposit [AMOUNT]");
                else
                {
                    if(strval(tmp) == 0) return SendClientMessage(playerid, ERROR, "The amount must be higher than 1.");
                    else
                    {
                        if(strval(tmp) > GetPlayerMoney(playerid)) return SendClientMessage(playerid, ERROR, "You do not have this amount.");
                        else
                        {
                            new string[150], string2[150];
                            SetPlayerBankCash(playerid, GetPlayerBankCash(playerid)+strval(tmp));
                            SendClientMessage(playerid, GREY, "|_| Bank |_|");
                            format(string, sizeof(string), "Amount deposited: $%d", strval(tmp));
                            format(string2, sizeof(string2), "Current state: $%d", GetPlayerBankCash(playerid));
                            SendClientMessage(playerid, WHITE, string);
                            SendClientMessage(playerid, WHITE, string2);
                            GivePlayerMoney(playerid, -strval(tmp));
                            printf("%s (%d) deposited $%d. Location: Bank", name, playerid, strval(tmp));
                            return true;
                        }
                    }
                }
            }
            else if(BankRecentlyUsed[playerid] >= 1) SendClientMessage(playerid, ERROR, "You have recently robbed the Bank."); return true;
        }
        else return SendClientMessage(playerid, ERROR, "You must be on the Bank to use this command!");
    }
    return 1;
}
This does not work

Quote:
Originally Posted by Goldilox
Посмотреть сообщение
This should be good.
pawn Код:
CMD:(playerid,params[])
    {
        if(CPS_IsPlayerInCheckpoint(playerid, cpbank))
        {
            if(BankRecentlyUsed[playerid] == 0)
            {
            if(sscanf(params, "d", type)) return SendClientMessage(playerid, ERROR, "Use:  /deposit [amount]");
                else
                {
                    if(strval(tmp) == 0) return SendClientMessage(playerid, ERROR, "The amount must be higher than 1.");
                    else
                    {
                        if(strval(tmp) > GetPlayerMoney(playerid)) return SendClientMessage(playerid, ERROR, "You do not have this amount.");
                        else
                        {
                            new string[150], string2[150];
                            SetPlayerBankCash(playerid, GetPlayerBankCash(playerid)+strval(tmp));
                            SendClientMessage(playerid, GREY, "|_| Bank |_|");
                            format(string, sizeof(string), "Amount deposited: $%d", strval(tmp));
                            format(string2, sizeof(string2), "Current state: $%d", GetPlayerBankCash(playerid));
                            SendClientMessage(playerid, WHITE, string);
                            SendClientMessage(playerid, WHITE, string2);
                            GivePlayerMoney(playerid, -strval(tmp));
                            printf("%s (%d) deposited $%d. Location: Bank", name, playerid, strval(tmp));
                            return true;
                        }
                    }
                }
            }
            else if(BankRecentlyUsed[playerid] >= 1) SendClientMessage(playerid, ERROR, "You have recently robbed the Bank."); return true;
        }
        else return SendClientMessage(playerid, ERROR, "You must be on the Bank to use this command!");
    }

Use this;

pawn Код:
CMD:deposit(playerid,params[])
{
    new amount;
    if( sscanf( params, "d", amount) )
    return SendClientMessage(playerid, ERROR, "Use: /deposit [AMOUNT]");

    if(CPS_IsPlayerInCheckpoint(playerid, cpbank))
    {
    if(BankRecentlyUsed[playerid] == 0)
    {
    if(amount > GetPlayerMoney(playerid))
        return SendClientMessage(playerid, ERROR, "You do not have this amount.");

    new string[150], string2[150];
    SetPlayerBankCash(playerid, GetPlayerBankCash(playerid)+amount);
    SendClientMessage(playerid, GREY, "|_| Bank |_|");
    format(string, sizeof(string), "Amount deposited: $%d", amount);
    format(string2, sizeof(string2), "Current state: $%d", GetPlayerBankCash(playerid));
    SendClientMessage(playerid, WHITE, string);
    SendClientMessage(playerid, WHITE, string2);
    GivePlayerMoney(playerid, -amount);
    printf("%s (%d) deposited $%d. Location: Bank", name, playerid, amount);
    }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)