Jump to content

its just buisines-- bug/fout


darkdudefly

Recommended Posts

ik heb een fout gevonden in dit script dat ik wou gaan gebruiken. :*D

als je iets koopt dan krijg je om de 10 min. geld, maar als je 1 prop ownt en je gaat naar een ander prop en je deot sell , verkoop je het prop waar je bij staat voor het geld ervan .

en bovendien kan je het dan ook kopen en geld van ontvangen + je andere prop werkt ook nog steeds.

kan iemand deze fout uit het script halen ?

of weet iemand een beter script?

/* 'Its Just Business' Filterscipt made by Desert 2010.
Thank you for downloading this filterscript. If you find any bugs please report them to me.
When adding businesses please make sure that MAX_BUSINESS matches your ammount of businesses for most efficient use.
If you are not sure about how many businesses you have open the Business.ini file which should be made in your scriptfiles directory.
And find the highest number id like this 0X=1.100  and plus it with 1. Then you know you have 1 business. if 10 like 10X is the highest
then you know you have 11 businesses. Simple right?

Credits to Y_Less and DracoBlue for DCMD sscanf and dini
*/

//Version 0.2


#include <a_samp>
#include <dutils>
#include <dini>
#include <IJB>


#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
#pragma unused ret_memcpy
#pragma tabsize 4

#define COLOUR_WHITE           0xFFFFFFFF
#define COLOUR_GREEN           0x33AA33AA
#define COLOUR_RED             0xFF3333AA
#define COLOUR_YELLOW          0xFFFF00AA
#define COLOUR_BLUE 		   0x0088FFAA


forward PayTime();

new OwnsBusiness[MAX_PLAYERS];
new antispam[MAX_PLAYERS];
forward AntiSpam(playerid);

public OnFilterScriptInit()
{
print("\n------------------------------------------------");
print(" 'Its Just Business' has succesfully been loaded");
print("------------------------------------------------\n");
LoadBusinesses();
SetTimer("PayTime",1000*60*10,1);
if(!fexist("Business.ini"))
{
	dini_Create("Business.ini");
	dini_IntSet("Business.ini","CurrentID",0);
	}
return 1;
}

public OnFilterScriptExit()
{
UnloadBusiness();
return 1;
}

public OnPlayerConnect(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
   new ob = dini_Int("Business.ini",name);
   if(ob == 0) dini_IntSet("Business.ini",name,0);
return 1;
}

public OnPlayerDisconnect(playerid)
{
antispam[playerid] = 0;
return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(buybus,6,cmdtext);
dcmd(sellbus,7,cmdtext);
dcmd(createbus,9,cmdtext);
dcmd(getprofit,9,cmdtext);
return 0;
}

dcmd_buybus(playerid,params[])
{
#pragma unused params
new biz[50];
new string[128];
if(DoesPlayerOwnBusiness(playerid) == 1) return SendClientMessage(playerid,COLOUR_RED,"You do already own a business");
if(IsPlayerInRangeOfBus(playerid) != -1)
{
	new b = IsPlayerInRangeOfBus(playerid);
	format(biz,sizeof(biz),"%iOwner",b);
	if(dini_Int("Business.ini",biz) == 1) return SendClientMessage(playerid,COLOUR_RED,"You can't buy this business! Someone already ownes it");
	format(biz,sizeof(biz),"%iCost",b);
	if(dini_Int("Business.ini",biz) > GetPlayerMoney(playerid))
	{
		format(string,sizeof(string),"You do not have enough cash for this business! Price is $%i",dini_Int("Business.ini",biz));
		SendClientMessage(playerid,COLOUR_RED,string);
		}
	else
	{
		new name[MAX_PLAYER_NAME],bizname[MAX_STRING],cost;
		GetPlayerName(playerid,name,sizeof(name));
		format(biz,sizeof(biz),"%iCost",b);
		cost = dini_Int("Business.ini",biz);
		GivePlayerMoney(playerid,-cost);
		OwnsBusiness[playerid] = 1;
		format(biz,sizeof(biz),"%iOwnerName",b);
		dini_Set("business.ini",biz,name);
		format(biz,sizeof(biz),"%iBusinessname",b);
		bizname = dini_Get("Business.ini",biz);
		format(biz,sizeof(biz),"%iOwner",b);
		dini_IntSet("business.ini",biz,1);
		format(biz,sizeof(biz),"%iCash",b);
		dini_IntSet("business.ini",biz,0);
		format(biz,sizeof(biz),"%iPayment",b);
		new cash = dini_Int("business.ini",biz);
		format(string,sizeof(string),"You have succesfully bought %s! This business pays %i dollars per 10 minutes",bizname,cash);
		SendClientMessage(playerid,COLOUR_GREEN,string);
		dini_IntSet("Business.ini",name,1);
		}
	}
else return SendClientMessage(playerid,COLOUR_RED,"You are not in range of any business");
return 1;
}

dcmd_sellbus(playerid,params[])
{
#pragma unused params
if(DoesPlayerOwnBusiness(playerid) == 0) return SendClientMessage(playerid,COLOUR_RED,"You do not own any business");
else
{
    if(IsPlayerInRangeOfOwnedBusiness(playerid) != -1)
    {
        new biz[50],pname[MAX_PLAYER_NAME];
        new b = IsPlayerInRangeOfOwnedBusiness(playerid);
    	new string[128];
    	new name[MAX_STRING];
    	format(biz,sizeof(biz),"%iBusinessname",b);
    	name = dini_Get("business.ini",biz);
		format(string,sizeof(string),"You have sold %s",name);
		SendClientMessage(playerid,COLOUR_YELLOW,string);
		OwnsBusiness[playerid] = 0;
		format(biz,sizeof(biz),"%iOwner",b);
		dini_IntSet("business.ini",biz,0);
		format(biz,sizeof(biz),"%iCost",b);
		new cash = dini_Int("Business.ini",biz);
		GivePlayerMoney(playerid,cash);
		OwnsBusiness[playerid] = 0;
		GetPlayerName(playerid,pname,sizeof(pname));
		dini_IntSet("Business.ini",pname,0);
		}
	else return SendClientMessage(playerid,COLOUR_RED,"You are not in range of your business!");
	}
return 1;
}

dcmd_createbus(playerid,params[])
{
new cost,pay,name[100];
if(!IsPlayerAdmin(playerid)) return 0;
if(sscanf(params,"sii",name,cost,pay)) return SendClientMessage(playerid,COLOUR_RED,"Usage: /createbus NAME COST PAYMENT");
else
{
	new biz[100],Float:X,Float:Y,Float:Z;
	GetPlayerPos(playerid,X,Y,Z);
	new id = dini_Int("Business.ini","CurrentID");
	format(biz,sizeof(biz),"%iBusinessname",id);
	dini_Set("Business.ini",biz,name);
	format(biz,sizeof(biz),"%iPayment",id);
	dini_IntSet("Business.ini",biz,pay);
	format(biz,sizeof(biz),"%iCost",id);
	dini_IntSet("Business.ini",biz,cost);
	format(biz,sizeof(biz),"%iX",id);
	dini_FloatSet("Business.ini",biz,X);
	format(biz,sizeof(biz),"%iY",id);
	dini_FloatSet("Business.ini",biz,Y);
	format(biz,sizeof(biz),"%iZ",id);
	dini_FloatSet("Business.ini",biz,Z);
	format(biz,sizeof(biz),"%iOwnerName",id);
	dini_Set("business.ini",biz,"No Owner");
	Businessid[id] = CreatePickup(1239,23,X,Y,Z,-1);
	id = id+1;
	dini_IntSet("Business.ini","CurrentID",id);
	SendClientMessage(playerid,COLOUR_YELLOW,"Succesfully created business");
	}
return 1;
}

dcmd_getprofit(playerid,params[])
{
#pragma unused params
new b;
if(DoesPlayerOwnBusiness(playerid) == 0) return SendClientMessage(playerid,COLOUR_RED,"You do now own a business!");
if(IsPlayerInRangeOfOwnedBusiness(playerid) == -1) return SendClientMessage(playerid,COLOUR_RED,"You are not in range of your business!");
else
{
	b = IsPlayerInRangeOfOwnedBusiness(playerid);
	if(GetBusinessCashAmmount(b) == 0) return SendClientMessage(playerid,COLOUR_RED,"Your business does not contain any cash");
	else
	{
	    new cash = GetBusinessCashAmmount(b);
	    GivePlayerMoney(playerid,cash);
		new string[128],biz[50];
		format(string,sizeof(string),"You have recieved $%i from your business",cash);
		SendClientMessage(playerid,COLOUR_GREEN,string);
		format(biz,sizeof(biz),"%iCash",b);
		dini_IntSet("Business.ini",biz,0);
		}
	}
return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
   if(antispam[playerid] == pickupid) return 1;
for(new b=0; b<MAX_BUSINESS; b++)
{
    if(pickupid == Businessid[b])
    {
        antispam[playerid] = pickupid;
        SetTimerEx("AntiSpam",1000*30,0,"playerid",playerid);
        new biz[128];
        format(biz,sizeof(biz),"%iOwner",b);
		if(dini_Int("Business.ini",biz) == 1)
		{
		    new name[MAX_PLAYER_NAME],name2[50];
		    format(name2,sizeof(name2),"%iOwnerName",b);
		    GetPlayerName(playerid,name,sizeof(name));
		    format(biz,sizeof(biz),"%s",dini_Get("Business.ini",name2));
		    if(strcmp(biz,name,false))
		    {
			    new bname[50],pname[MAX_PLAYER_NAME],string[128];
			    format(biz,sizeof(biz),"%iBusinessname",b);
				format(bname,sizeof(bname),"%s",dini_Get("Business.ini",biz));
				format(biz,sizeof(biz),"%iOwnerName",b);
				format(pname,sizeof(pname),"%s",dini_Get("Business.ini",biz));
				format(string,sizeof(string),"Welcome to %s! This business is owned by %s",bname,pname);
				SendClientMessage(playerid,COLOUR_YELLOW,string);
				}
			else
			{
				format(biz,sizeof(biz),"Welcome back to your business %s. Use /getprofit to collect profit",name);
				SendClientMessage(playerid,COLOUR_YELLOW,biz);
				format(biz,sizeof(biz),"%iCash",b);
				new cash = dini_Int("Business.ini",biz);
				format(biz,sizeof(biz),"Your business contains $%i",cash);
				SendClientMessage(playerid,COLOUR_WHITE,biz);
				}
			}
		else
		{
		    new bname[50],string[128];
		    format(biz,sizeof(biz),"%iBusinessname",b);
			format(bname,sizeof(bname),"%s",dini_Get("Business.ini",biz));
			format(string,sizeof(string),"Welcome to %s! This business has no owner. Use /buybus to buy it",bname);
			SendClientMessage(playerid,COLOUR_WHITE,string);
			format(biz,sizeof(biz),"%iCost",b);
			new cash = dini_Int("Business.ini",biz);
			format(string,sizeof(string),"%s costs $%i",bname,cash);
			SendClientMessage(playerid,COLOUR_WHITE,string);
			}
		}
	}
return 1;
}

public PayTime()
{
   print("There has been a payday!");
   SendClientMessageToAll(COLOUR_BLUE,"Business's cash ammount has increased");
for(new b=0; b<MAX_BUSINESS; b++)
{
	new biz[50],pay,ammount;
	format(biz,sizeof(biz),"%iPayment",b);
	pay = dini_Int("Business.ini",biz);
	format(biz,sizeof(biz),"%iCash",b);
	ammount = dini_Int("Business.ini",biz);
	ammount = ammount+pay;
	dini_IntSet("Business.ini",biz,ammount);
	}
return 1;
}

public AntiSpam(playerid)
{
antispam[playerid] = 0;
return 1;
}


stock sscanf(string[], format[], {Float,_}:...)
{
#if defined isnull
	if (isnull(string))
#else
	if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
#endif
	{
		return format[0];
	}
#pragma tabsize 4
new
	formatPos = 0,
	stringPos = 0,
	paramPos = 2,
	paramCount = numargs(),
	delim = ' ';
while (string[stringPos] && string[stringPos] <= ' ')
{
	stringPos++;
}
while (paramPos < paramCount && string[stringPos])
{
	switch (format[formatPos++])
	{
		case '\0':
		{
			return 0;
		}
		case 'i', 'd':
		{
			new
				neg = 1,
				num = 0,
				ch = string[stringPos];
			if (ch == '-')
			{
				neg = -1;
				ch = string[++stringPos];
			}
			do
			{
				stringPos++;
				if ('0' <= ch <= '9')
				{
					num = (num * 10) + (ch - '0');
				}
				else
				{
					return -1;
				}
			}
			while ((ch = string[stringPos]) > ' ' && ch != delim);
			setarg(paramPos, 0, num * neg);
		}
		case 'h', 'x':
		{
			new
				num = 0,
				ch = string[stringPos];
			do
			{
				stringPos++;
				switch (ch)
				{
					case 'x', 'X':
					{
						num = 0;
						continue;
					}
					case '0' .. '9':
					{
						num = (num << 4) | (ch - '0');
					}
					case 'a' .. 'f':
					{
						num = (num << 4) | (ch - ('a' - 10));
					}
					case 'A' .. 'F':
					{
						num = (num << 4) | (ch - ('A' - 10));
					}
					default:
					{
						return -1;
					}
				}
			}
			while ((ch = string[stringPos]) > ' ' && ch != delim);
			setarg(paramPos, 0, num);
		}
		case 'c':
		{
			setarg(paramPos, 0, string[stringPos++]);
		}
		case 'f':
		{
			setarg(paramPos, 0, _:floatstr(string[stringPos]));
		}
		case 'p':
		{
			delim = format[formatPos++];
			continue;
		}
		case '\'':
		{
			new
				end = formatPos - 1,
				ch;
			while ((ch = format[++end]) && ch != '\'') {}
			if (!ch)
			{
				return -1;
			}
			format[end] = '\0';
			if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
			{
				if (format[end + 1])
				{
					return -1;
				}
				return 0;
			}
			format[end] = '\'';
			stringPos = ch + (end - formatPos);
			formatPos = end + 1;
		}
		case 'u':
		{
			new
				end = stringPos - 1,
				id = 0,
				bool:num = true,
				ch;
			while ((ch = string[++end]) && ch != delim)
			{
				if (num)
				{
					if ('0' <= ch <= '9')
					{
						id = (id * 10) + (ch - '0');
					}
					else
					{
						num = false;
					}
				}
			}
			if (num && IsPlayerConnected(id))
			{
				setarg(paramPos, 0, id);
			}
			else
			{
				#if !defined foreach
					#define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
					#define __SSCANF_FOREACH__
				#endif
				string[end] = '\0';
				num = false;
				new
					name[MAX_PLAYER_NAME];
				id = end - stringPos;
				foreach (Player, playerid)
				{
					GetPlayerName(playerid, name, sizeof (name));
					if (!strcmp(name, string[stringPos], true, id))
					{
						setarg(paramPos, 0, playerid);
						num = true;
						break;
					}
				}
				if (!num)
				{
					setarg(paramPos, 0, INVALID_PLAYER_ID);
				}
				string[end] = ch;
				#if defined __SSCANF_FOREACH__
					#undef foreach
					#undef __SSCANF_FOREACH__
				#endif
			}
			stringPos = end;
		}
		case 's', 'z':
		{
			new
				i = 0,
				ch;
			if (format[formatPos])
			{
				while ((ch = string[stringPos++]) && ch != delim)
				{
					setarg(paramPos, i++, ch);
				}
				if (!i)
				{
					return -1;
				}
			}
			else
			{
				while ((ch = string[stringPos++]))
				{
					setarg(paramPos, i++, ch);
				}
			}
			stringPos--;
			setarg(paramPos, i, '\0');
		}
		default:
		{
			continue;
		}
	}
	while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
	{
		stringPos++;
	}
	while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
	{
		stringPos++;
	}
	paramPos++;
}
do
{
	if ((delim = format[formatPos++]) > ' ')
	{
		if (delim == '\'')
		{
			while ((delim = format[formatPos++]) && delim != '\'') {}
		}
		else if (delim != 'z')
		{
			return delim;
		}
	}
}
while (delim > ' ');
return 0;
}

ik denk dat ik best een ander script heb :zz: , want dit script vernadern is redelijk veel werk denk ik. of het is dat je gewoon bij de sell command moet laten maken dat het mijn prop is. alleen weet ik niet hoe dat moet... :N

Link to comment
Delen op andere websites

Een reactie plaatsen

Je kan nu een reactie plaatsen en pas achteraf registreren. Als je al lid bent, log eerst in om met je eigen account een reactie te plaatsen.

Gast
Op dit onderwerp reageren...

×   Je hebt text geplaatst met opmaak.   Opmaak verwijderen

  Only 75 emoji are allowed.

×   Je link is automatisch ingevoegd.   In plaats daarvan weergeven als link

×   Je vorige bewerkingen zijn hersteld.   Alles verwijderen

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent actief   0 leden

    • Er zijn hier geen geregistreerde gebruikers aanwezig.
×
×
  • Create New...