SA-MP Forums Archive
Cmd not working well - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Cmd not working well (/showthread.php?tid=277033)



Cmd not working well - jaksimaksi - 16.08.2011

pawn Код:
CMD:takebizmoney(playerid, params[])
{
new kiek;
new msg[68];

format(bizfile,sizeof(bizfile),"Business/%i.ini",GetPlayerBusinessID(playerid));


for(new i = 0;i<MAX_BUSS;i++)
{

if(sscanf(params, "i", kiek)) return SendClientMessage(playerid,COLOR_GREY,"[Naudojimas]: /takebizmoney [how much]");


if(dini_Int(bizfile, "Bizmoney") < kiek)
{
   SendClientMessage(playerid, COLOR_GREY, "ur biz dont have so much money");
   return 1;
}

if(!IsNumeric(params))
{
   SendClientMessage(playerid, COLOR_GREY, "wrong letters");
   return 1;
}

BusinessInfo[i][Bizmoney]-=kiek;
GivePlayerMoney(playerid,kiek);

format(msg,sizeof(msg),"tooked %i$",kiek);
SendClientMessage(playerid, COLOR_WHITE, msg);
}
return 1;
}
Whats wrong? When i type /takebiz money amount, server spams to me that amount and gives bad amount... I think something is with new i. This command should take player biz money


Re: Cmd not working well - MadeMan - 16.08.2011

You don't need the loop and sscanf already checks IsNumeric

pawn Код:
CMD:takebizmoney(playerid, params[])
{
    new kiek;
    new msg[68];
    format(bizfile,sizeof(bizfile),"Business/%i.ini",GetPlayerBusinessID(playerid));
    if(sscanf(params, "i", kiek)) return SendClientMessage(playerid,COLOR_GREY,"[Naudojimas]: /takebizmoney [how much]");
    if(dini_Int(bizfile, "Bizmoney") < kiek)
    {
        SendClientMessage(playerid, COLOR_GREY, "ur biz dont have so much money");
        return 1;
    }
    BusinessInfo[i][Bizmoney]-=kiek;
    GivePlayerMoney(playerid,kiek);
    format(msg,sizeof(msg),"tooked %i$",kiek);
    SendClientMessage(playerid, COLOR_WHITE, msg);
    return 1;
}



AW: Cmd not working well - jaksimaksi - 16.08.2011

error 017: undefined symbol "i"


Re: Cmd not working well - MadeMan - 16.08.2011

pawn Код:
CMD:takebizmoney(playerid, params[])
{
    new kiek;
    new msg[68];
    new bizid = GetPlayerBusinessID(playerid);
    format(bizfile,sizeof(bizfile),"Business/%i.ini",bizid);
    if(sscanf(params, "i", kiek)) return SendClientMessage(playerid,COLOR_GREY,"[Naudojimas]: /takebizmoney [how much]");
    if(BusinessInfo[bizid][Bizmoney] < kiek)
    {
        SendClientMessage(playerid, COLOR_GREY, "ur biz dont have so much money");
        return 1;
    }
    BusinessInfo[bizid][Bizmoney]-=kiek;
    GivePlayerMoney(playerid,kiek);
    dini_IntSet(bizfile, "Bizmoney", BusinessInfo[bizid][Bizmoney]);
    format(msg,sizeof(msg),"tooked %i$",kiek);
    SendClientMessage(playerid, COLOR_WHITE, msg);
    return 1;
}



AW: Cmd not working well - jaksimaksi - 16.08.2011

Thanks, works. But now not - money from bussiness

pawn Код:
BusinessInfo[bizid][Bizmoney]-=kiek;



Re: AW: Cmd not working well - MadeMan - 16.08.2011

Quote:
Originally Posted by jaksimaksi
Посмотреть сообщение
Thanks, works. But now not - money from bussiness

pawn Код:
BusinessInfo[bizid][Bizmoney]-=kiek;
How do you know?


AW: Cmd not working well - jaksimaksi - 16.08.2011

I tested it. Gives the money but not - from bussiness