/giveMoney cmd problem
#1

Hi guys I make /givemoney cmd but when I type /givemoney it show '/givemoney playerid money' perfect but when I type /givemoney 1 it says server:unknown cmd?

Here's my coods:
pawn Код:
if (strcmp("/Givemoney", cmdtext, true, 10) == 0)
    {
        if (PlayerInfo[playerid][pAdminLevel] >= 4)
        {
            if(IsPlayerConnected(playerid))
            {
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp))
                    {
                    SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /GiveMoney [playerid/PartOfName] [Money]");
                    return 1;
        }
        giveplayerid = ReturnUser(tmp);
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /GiveMoney [playerid/PartOfName] [Money]");
                    return 1;
        }
        new playa;
        playa = ReturnUser(tmp);
        Values = strval(tmp);
        PlayerInfo[giveplayerid][pCash] += Values;
            GivePlayerMoney(giveplayerid,Values);
        GetPlayerName(playa, giveplayer, sizeof(giveplayer));
        format(string,sizeof(string),"*Administrator %s have Give you %d Money!",sendername,Values);
        SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, string);
        format(string, sizeof(string),"* Gave %d Money to %s",Values,giveplayer);
                SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
            }
        }
        return 1;
    }
Reply
#2

Use scanff + zcmd / dcmd
Reply
#3

If you would indent correctly, that code could be a lot easier to read and therefore a lot easier to identify the problem. You should use ZCMD and SSCANF, instead of strcmp and strtock.
Reply
#4

Any tut of it with detail ?
Reply
#5

personally i would make it with DCMD+SPLIT...
Reply
#6

lol.... you just changed raven's rolePlay /money cmd.... This is Raven's cmds script!
You should download ravens(if you dont have the original one) and copy the cmd /money and replace for this! After chnage /money to /givemoney and the: Usage: /money to Usage: /givemoney
Reply
#7

ZCMD or DCMD are the best.

Код:
CMD:givemoney(playerid, params[])
{
	new otherId;
	new amount;

	if(PlayerInfo[playerid][pLogged] == 0)
	    return SendClientMessage(playerid, COLOR_RED, "[Error]: Please login before using this command.");

	if(PlayerInfo[playerid][pAdmin] < 1)
	    return SendClientMessage(playerid, COLOR_RED, ADMIN_CMD_ERROR);

	if(!IsPlayerConnected(otherId))
	    return SendClientMessage(playerid, COLOR_RED, "[Error]: Invalid Player ID.");

	if(sscanf(params, "ds", otherId, amount))
	{
	    SendClientMessage(playerid, COLOR_STEELBLUE, "[USAGE]: /givemoney [Playerid] [Amount]");
	    return true;
	}

	GetPlayerName(otherId, otherName, sizeof(otherName));
	GetPlayerName(playerid, playerName, sizeof(playerName));


	format(stri, sizeof(stri), "* Admin %s gave to %s $%d",playerName,PlayerInfo[otherId][pName],amount);
	SendClientMessageToAll(COLOR_YELLOW, stri);

	GivePlayerMoney(otherId, amount);

	return true;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)