Zcmd problem
#1

Hi, I have a problem with my command i have this :
Код:
CMD:donate(playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
        new moneys, string[256];
		tmp = strtok(params, idx);
		if(!strlen(tmp)) return SendClientMessage(playerid, -1, "USAGE: /donate [amount]");
		if(PlayerInfo[playerid][pLocal] == 106) return SendClientMessage(playerid, COLOR_GREY, "You can't use this comand right here.");
		moneys = strval(tmp);
		if(moneys < 0 || moneys > 1000000) return SendClientMessage(playerid, COLOR_GREY, "You can't donate less than $1.000 or more than $1.000.000!");
		if(GetPlayerMoney(playerid) < moneys) return SendClientMessage(playerid, COLOR_GREY, "Transaction amount is invalid.");
		GivePlayerMoney(playerid, -moneys);
		GetPlayerName(playerid, sendername, sizeof(sendername));
		format(string, sizeof(string), "* %s donated %s!",sendername, FormatMoney(moneys));
		PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
		PayLog(string);
        format(string, sizeof(string), "~w~Thank you for your donation of~n~~r~~h~%s~w~, ~b~~h~%s ~w~!",sendername, FormatMoney(moneys));
        GameTextForPlayer(playerid, string, 3000, 5);
        format(string, sizeof(string), "* %s donated %s to The Mayor.",sendername, FormatMoney(moneys));
        SendFamilyMessage(7, COLOR_YAKUZA, string);
	}
	return 1;
}
when i typing in game /donate 100 i receive this:
Код:
if(!strlen(tmp)) return SendClientMessage(playerid, -1, "USAGE: /donate [amount]");
Help me for this problem.
Reply
#2

try using sscanf
pawn Код:
CMD:donate(playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
        new moneys, string[256];
        if(sscanf(params,"i",moneys)) return SendClientMessage(playerid, -1, "USAGE: /donate [amount]");
        if(PlayerInfo[playerid][pLocal] == 106) return SendClientMessage(playerid, COLOR_GREY, "You can't use this comand right here.");
        if(moneys < 0 || moneys > 1000000) return SendClientMessage(playerid, COLOR_GREY, "You can't donate less than $1.000 or more than $1.000.000!");
        if(GetPlayerMoney(playerid) < moneys) return SendClientMessage(playerid, COLOR_GREY, "Transaction amount is invalid.");
        GivePlayerMoney(playerid, -moneys);
        GetPlayerName(playerid, sendername, sizeof(sendername));
        format(string, sizeof(string), "* %s donated %s!",sendername, FormatMoney(moneys));
        PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
        PayLog(string);
        format(string, sizeof(string), "~w~Thank you for your donation of~n~~r~~h~%s~w~, ~b~~h~%s ~w~!",sendername, FormatMoney(moneys));
        GameTextForPlayer(playerid, string, 3000, 5);
        format(string, sizeof(string), "* %s donated %s to The Mayor.",sendername, FormatMoney(moneys));
        SendFamilyMessage(7, COLOR_YAKUZA, string);
    }
    return 1;
}
Reply
#3

Not working
Reply
#4

What's not working? Did you download sscanf and put
pawn Код:
#include <sscanf2>
at top?
Reply
#5

Yes i have.
Reply
#6

Quote:
Originally Posted by Tanush123
Посмотреть сообщение
try using sscanf
pawn Код:
CMD:donate(playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
        new moneys, string[256];
        if(sscanf(params,"i",moneys)) return SendClientMessage(playerid, -1, "USAGE: /donate [amount]");
        if(PlayerInfo[playerid][pLocal] == 106) return SendClientMessage(playerid, COLOR_GREY, "You can't use this comand right here.");
        if(moneys < 0 || moneys > 1000000) return SendClientMessage(playerid, COLOR_GREY, "You can't donate less than $1.000 or more than $1.000.000!");
        if(GetPlayerMoney(playerid) < moneys) return SendClientMessage(playerid, COLOR_GREY, "Transaction amount is invalid.");
        GivePlayerMoney(playerid, -moneys);
        GetPlayerName(playerid, sendername, sizeof(sendername));
        format(string, sizeof(string), "* %s donated %s!",sendername, FormatMoney(moneys));
        PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
        PayLog(string);
        format(string, sizeof(string), "~w~Thank you for your donation of~n~~r~~h~%s~w~, ~b~~h~%s ~w~!",sendername, FormatMoney(moneys));
        GameTextForPlayer(playerid, string, 3000, 5);
        format(string, sizeof(string), "* %s donated %s to The Mayor.",sendername, FormatMoney(moneys));
        SendFamilyMessage(7, COLOR_YAKUZA, string);
    }
    return 1;
}
use that cmd but replace
pawn Код:
if(sscanf(params,"i",moneys)) return SendClientMessage(playerid, -1, "USAGE: /donate [amount]");
with
pawn Код:
if(!sscanf(params,"i",moneys)) return SendClientMessage(playerid, -1, "USAGE: /donate [amount]");
Reply
#7

same problem
Reply
#8

Quote:
Originally Posted by new121
Посмотреть сообщение
use that cmd but replace
pawn Код:
if(sscanf(params,"i",moneys)) return SendClientMessage(playerid, -1, "USAGE: /donate [amount]");
with
pawn Код:
if(!sscanf(params,"i",moneys)) return SendClientMessage(playerid, -1, "USAGE: /donate [amount]");
Dude you even know how to use sscanf? That will keep shoting USAGE: /donate [amount]


What is the problem with the command? You get server unkown command or another problem
Reply
#9

So, when i type /donate show the gametext: ~w~Thank you for your donation of~n~~r~~h~k3nw00d_kri5ty~w~, ~b~~h~0$ ~w~!
When i type /donate and the amout of money what i have i receive: "USAGE: /donate [amount]",
And when i try the new121 method i receive Unknown Command.
Reply
#10

This should work..
pawn Код:
if(sscanf(params,"i",moneys)) return SendClientMessage(playerid, -1, "USAGE: /donate [amount]");
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)