SA-MP Forums Archive
Command Saying not enough cash - 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)
+--- Thread: Command Saying not enough cash (/showthread.php?tid=451055)



Command Saying not enough cash - San1 - 15.07.2013

This command is configured wrong or sum. It says Not Enough cash when i have over 10$
NO ERRORS on COMPILE

pawn Код:
CMD:buyproducts(playerid, params[])
{
    new string2[128];
    if(PlayerInfo[playerid][pBizKey] != INVALID_BIZZ_ID && (IsPlayerInRangeOfPoint(playerid, 2.0, BizInfo[PlayerInfo[playerid][pBizKey]][IXCoord], BizInfo[PlayerInfo[playerid][pBizKey]][IYCoord], BizInfo[PlayerInfo[playerid][pBizKey]][IZCoord])))
    {
        if(GetPlayerCash(playerid < params[0]*10))
        {
            if(sscanf(params, "i", params[0])) return SendClientMessageEx(playerid, COLOR_GRAD3, "USAGE: /buyproducts [amount]");
            GivePlayerCash(playerid, -params[0]*10);
            BizInfo[PlayerInfo[playerid][pBizKey]][Products] += params[0];
            SaveBizInfo(PlayerInfo[playerid][pBizKey]);
            format(string2,sizeof(string2),"You have bought %d amount of business products", params);
            SendClientMessageEx(playerid, COLOR_GRAD3, string2);
            return 1;
        }
        else
        {
            SendClientMessageEx(playerid, COLOR_GRAD2, "You don't own a business, or are not inside one of them.");
            return 1;
        }
    }
    else
    {
        SendClientMessageEx(playerid, COLOR_GRAD2, "You don't have 100$ for each product.");
        return 1;
    }
}



Re: Command Saying not enough cash - Misiur - 15.07.2013

pawn Код:
if(GetPlayerCash(playerid < params[0]*10))
{
            if(sscanf(params, "i", params[0])) return SendClientMessageEx(playerid, COLOR_GRAD3, "USAGE: /buyproducts [amount]");
Wrong order, and wrong bracket

pawn Код:
if(sscanf(params, "i", params[0])) return SendClientMessageEx(playerid, COLOR_GRAD3, "USAGE: /buyproducts [amount]");
if(GetPlayerCash(playerid) < params[0]*10)
{



Re: Command Saying not enough cash - JimmyCh - 15.07.2013

You wrote the code wrong, it should be like this:
pawn Код:
CMD:buyproducts(playerid, params[])
{
    new string2[128];
    if(PlayerInfo[playerid][pBizKey] != INVALID_BIZZ_ID && (IsPlayerInRangeOfPoint(playerid, 2.0, BizInfo[PlayerInfo[playerid][pBizKey]][IXCoord], BizInfo[PlayerInfo[playerid][pBizKey]][IYCoord], BizInfo[PlayerInfo[playerid][pBizKey]][IZCoord])))
    {
        if(GetPlayerCash(playerid < params[0]*10))
        {
            if(sscanf(params, "i", params[0])) return SendClientMessageEx(playerid, COLOR_GRAD3, "USAGE: /buyproducts [amount]");
            GivePlayerCash(playerid, -params[0]*10);
            BizInfo[PlayerInfo[playerid][pBizKey]][Products] += params[0];
            SaveBizInfo(PlayerInfo[playerid][pBizKey]);
            format(string2,sizeof(string2),"You have bought %d amount of business products", params);
            SendClientMessageEx(playerid, COLOR_GRAD3, string2);
            return 1;
        }
        else
        {
        SendClientMessageEx(playerid, COLOR_GRAD2, "You don't have 100$ for each product.");
        return 1;
        }
    else
    {
    SendClientMessageEx(playerid, COLOR_GRAD2, "You don't own a business, or are not inside one of them.");
    return 1;
    }
return 1;
}



Re: Command Saying not enough cash - San1 - 15.07.2013

None of yall Fixed works. Someone please fix it


Re: Command Saying not enough cash - JimmyCh - 15.07.2013

This should work:
pawn Код:
CMD:buyproducts(playerid, params[])
{
    new string2[128];
    if(PlayerInfo[playerid][pBizKey] != INVALID_BIZZ_ID && (IsPlayerInRangeOfPoint(playerid, 2.0, BizInfo[PlayerInfo[playerid][pBizKey]][IXCoord], BizInfo[PlayerInfo[playerid][pBizKey]][IYCoord], BizInfo[PlayerInfo[playerid][pBizKey]][IZCoord])))
    {
        if(GetPlayerCash(playerid < params[0]*10))
        {
            if(sscanf(params, "i", params[0])) return SendClientMessageEx(playerid, COLOR_GRAD3, "USAGE: /buyproducts [amount]");
            GivePlayerCash(playerid, -params[0]*10);
            BizInfo[PlayerInfo[playerid][pBizKey]][Products] += params[0];
            SaveBizInfo(PlayerInfo[playerid][pBizKey]);
            format(string2,sizeof(string2),"You have bought %d amount of business products", params);
            SendClientMessageEx(playerid, COLOR_GRAD3, string2);
            return 1;
        }
        else return SendClientMessageEx(playerid, COLOR_GRAD2, "You don't have 100$ for each product.");
    }
    else return SendClientMessageEx(playerid, COLOR_GRAD2, "You don't own a business, or are not inside one of them.");

return 1;
}
Anyway if it doesn't work, show me what errors you are getting.


Re: Command Saying not enough cash - San1 - 15.07.2013

Quote:
Originally Posted by JimmyCh
Посмотреть сообщение
This should work:
pawn Код:
CMD:buyproducts(playerid, params[])
{
    new string2[128];
    if(PlayerInfo[playerid][pBizKey] != INVALID_BIZZ_ID && (IsPlayerInRangeOfPoint(playerid, 2.0, BizInfo[PlayerInfo[playerid][pBizKey]][IXCoord], BizInfo[PlayerInfo[playerid][pBizKey]][IYCoord], BizInfo[PlayerInfo[playerid][pBizKey]][IZCoord])))
    {
        if(GetPlayerCash(playerid < params[0]*10))
        {
            if(sscanf(params, "i", params[0])) return SendClientMessageEx(playerid, COLOR_GRAD3, "USAGE: /buyproducts [amount]");
            GivePlayerCash(playerid, -params[0]*10);
            BizInfo[PlayerInfo[playerid][pBizKey]][Products] += params[0];
            SaveBizInfo(PlayerInfo[playerid][pBizKey]);
            format(string2,sizeof(string2),"You have bought %d amount of business products", params);
            SendClientMessageEx(playerid, COLOR_GRAD3, string2);
            return 1;
        }
        else return SendClientMessageEx(playerid, COLOR_GRAD2, "You don't have 100$ for each product.");
    }
    else return SendClientMessageEx(playerid, COLOR_GRAD2, "You don't own a business, or are not inside one of them.");

return 1; // Error Line
}
Anyway if it doesn't work, show me what errors you are getting.
Код:
C:\Documents and Settings\Adrian\My Documents\Samp Servers\EXRP\gamemodes\EXRPu16.pwn(35471) : warning 225: unreachable code



Re: Command Saying not enough cash - Boolean - 15.07.2013

pawn Код:
if(PlayerInfo[playerid][pBizKey] != INVALID_BIZZ_ID && IsPlayerInRangeOfPoint(playerid, 2.0, BizInfo[PlayerInfo[playerid][pBizKey]][IXCoord], BizInfo[PlayerInfo[playerid][pBizKey]][IYCoord], BizInfo[PlayerInfo[playerid][pBizKey]][IZCoord]))



Re: Command Saying not enough cash - Misiur - 15.07.2013

I don't know if you are even trying to do something - like understanding how your code should look like

pawn Код:
CMD:buyproducts(playerid, params[])
{
    new string2[128];
    if(PlayerInfo[playerid][pBizKey] != INVALID_BIZZ_ID && (IsPlayerInRangeOfPoint(playerid, 2.0, BizInfo[PlayerInfo[playerid][pBizKey]][IXCoord], BizInfo[PlayerInfo[playerid][pBizKey]][IYCoord], BizInfo[PlayerInfo[playerid][pBizKey]][IZCoord])))
    {
        if(sscanf(params, "i", params[0])) return SendClientMessageEx(playerid, COLOR_GRAD3, "USAGE: /buyproducts [amount]");
        new price = params[0] * 10;
        if(GetPlayerCash(playerid) >= price)
        {
            GivePlayerCash(playerid, -price);
            BizInfo[PlayerInfo[playerid][pBizKey]][Products] += params[0];
            SaveBizInfo(PlayerInfo[playerid][pBizKey]);
            format(string2,sizeof(string2),"You have bought %d amount of business products", params);
            return SendClientMessageEx(playerid, COLOR_GRAD3, string2);
        }
        else return SendClientMessageEx(playerid, COLOR_GRAD2, "You don't own a business, or are not inside one of them.");
    }
    else return SendClientMessageEx(playerid, COLOR_GRAD2, "You don't have 100$ for each product.");
}