[HELP] Fix buycomponent
#1

Код:
CMD:buycomponent(playerid, params[])
{
    if(!IsAtComponent(playerid))
    {// Component
		SendClientMessageEx(playerid, COLOR_GREY, "Kamu tidak sedang ada di toko komponen (Ocean Docks).");
		return 1;
    }
    if(PlayerInfo[playerid][pJob] != 7 && PlayerInfo[playerid][pJob2] != 7)
	{
		SendClientMessageEx(playerid, COLOR_GREY, "Kamu bukan mechanic.");
		return 1;
	}
    new component, string[128];
	if(sscanf(params, "d", component))
	    return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /buycomponent [jumlah]");
    if(component < 1)
        return SendClientMessageEx(playerid, COLOR_WHITE, "Error: Invalid amount of component!");

	if (GetPlayerCash(playerid) >= component*10)
	{
		PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
		PlayerInfo[playerid][pComponent] += component;
		GivePlayerCash(playerid, -(component*10));
		SaveAccountsUpdate();
		format(string, sizeof(string), "Kamu telah membeli %d component seharga $%d", component, component*10);
		SendClientMessageEx(playerid, COLOR_GREEN, string);
	}
	else
	{
		SendClientMessageEx(playerid, COLOR_GRAD4, "You don't have the cash for this item!");
    }
	return 1;
}
how to fix /buycomponent on my script?
i use /buycomponent -250000000 and -2500000000 , directly get the money 99999999

how to fix that /buycomponent -250000000 and -2500000000 no more bugs?


#sorry for bad my english
Reply
#2

Why *10?
Reply
#3

instead of
pawn Код:
if(component < 1)
do
pawn Код:
if(component < -0)
i know it looks weird.. i mean... there is no -0 xD but hey, it works

i tested it like this:
pawn Код:
new comp = -250000000;

public OnFilterScriptInit()
{
    if(comp < -0) printf("comp: %d smaller/equal 0",comp);
    else printf("comp: %d bigger 0",comp);
    return 1;
}
it printed
Код:
comp: -250000000 smaller 0
which is true and for comp = 0 it prints
Код:
comp: 0 bigger/equal 0
and comp = 1
Код:
comp: 1 bigger/equal 0
kinda weird solution... there might be something better 2 do in this case but i don't know atm.
Reply
#4

thank's
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)