When I buy a second or third business it doesn't set a key
#1

Here is the thing, when I buy first business key is set to my account normally but I have little problems with second and third business keys.

Код:
 if (PlayerData[playerid][pBusinessKey][0] == 0)
	 		return PlayerData[playerid][pBusinessKey][0] = id;
	 	if (PlayerData[playerid][pBusinessKey][1] == 0)
	 		return PlayerData[playerid][pBusinessKey][1] = id;
	 	if (PlayerData[playerid][pBusinessKey][2] == 0)
		 	return PlayerData[playerid][pBusinessKey][2] = id;
This code doesn't set keys to second and third businesses




I will show you /buybusiness command
Код:
	else if ((id = Business_Nearest(playerid)) != -1)
	{
	    if (Business_GetCount(playerid) >= MAX_OWNABLE_BUSINESSES)
			return SendErrorMessage(playerid, "You can only own %d businesses at a time.", MAX_OWNABLE_BUSINESSES);

		if (BusinessData[id][bizOwner] != 0)
		    return SendErrorMessage(playerid, "This business is already owned at the moment.");

		if (BusinessData[id][bizPrice] > GetMoney(playerid))
		    return SendErrorMessage(playerid, "You have insufficient funds for the purchase.");

	    BusinessData[id][bizOwner] = GetPlayerSQLID(playerid);

		Business_Refresh(id);
		Business_Save(id);

	    GiveMoney(playerid, -BusinessData[id][bizPrice]);
	    SendServerMessage(playerid, "You have purchased \"%s\" for %s!", BusinessData[id][bizName], FormatNumber(BusinessData[id][bizPrice]));

		ShowPlayerFooter(playerid, "You have ~g~purchased~w~ a business!");
	    Log_Write("logs/biz_log.txt", "[%s] %s has purchased business ID: %d for %s.", ReturnDate(), ReturnName(playerid), id, FormatNumber(BusinessData[id][bizPrice]));
        if (PlayerData[playerid][pBusinessKey][0] == 0)
	 		return PlayerData[playerid][pBusinessKey][0] = id;
	 	if (PlayerData[playerid][pBusinessKey][1] == 0)
	 		return PlayerData[playerid][pBusinessKey][1] = id;
	 	if (PlayerData[playerid][pBusinessKey][2] == 0)
		 	return PlayerData[playerid][pBusinessKey][2] = id;
	}
Thank you very much ...
Reply
#2

try this i hope it will work
PHP код:
    else if ((id Business_Nearest(playerid)) != -1)
    {
        if (
Business_GetCount(playerid) >= MAX_OWNABLE_BUSINESSES)
            return 
SendErrorMessage(playerid"You can only own %d businesses at a time."MAX_OWNABLE_BUSINESSES);
        if (
BusinessData[id][bizOwner] != 0)
            return 
SendErrorMessage(playerid"This business is already owned at the moment.");
        if (
BusinessData[id][bizPrice] > GetMoney(playerid))
            return 
SendErrorMessage(playerid"You have insufficient funds for the purchase.");
        
BusinessData[id][bizOwner] = GetPlayerSQLID(playerid);
        
Business_Refresh(id);
        
Business_Save(id);
        
GiveMoney(playerid, -BusinessData[id][bizPrice]);
        
SendServerMessage(playerid"You have purchased \"%s\" for %s!"BusinessData[id][bizName], FormatNumber(BusinessData[id][bizPrice]));
        
ShowPlayerFooter(playerid"You have ~g~purchased~w~ a business!");
        
Log_Write("logs/biz_log.txt""[%s] %s has purchased business ID: %d for %s."ReturnDate(), ReturnName(playerid), idFormatNumber(BusinessData[id][bizPrice]));
         if(
PlayerData[playerid][pBusinessKey][0] == 0)  PlayerData[playerid][pBusinessKey][0] = id;
         else if(
PlayerData[playerid][pBusinessKey][1] == 0)  PlayerData[playerid][pBusinessKey][1] = id;
        else if(
PlayerData[playerid][pBusinessKey][2] == 0)  PlayerData[playerid][pBusinessKey][2] = id;
    } 
Reply
#3

Maybe try like this:

PHP код:
if (PlayerData[playerid][pBusinessKey][0] == 0)
             return 
PlayerData[playerid][pBusinessKey][0] = id;
         else if (
PlayerData[playerid][pBusinessKey][1] == 0)
             return 
PlayerData[playerid][pBusinessKey][1] = id;
         else (
PlayerData[playerid][pBusinessKey][2] == 0)
             return 
PlayerData[playerid][pBusinessKey][2] = id
Reply
#4

Please people, EXPLAIN where the error is, and not just paste up solutions, that MAY work, yet not teach him ANYTHING at all about why the issue is happening.

Fact is that every question he asks about is script related, and then he ends up not posting the information needed, even when asked about it.


Really, this is why pasting solutions, does nothing. If you said "Read up on XXXX" then he'd go ****** and read. If you said "It's in this section of the script" he'll go ****** that, and read up on it.

By posting up simple "fixes", with a simple "try this" it doesn't teach them anything except to copy and paste, after asking the simplest questions on the forums.
Reply
#5

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
Please people, EXPLAIN where the error is, and not just paste up solutions, that MAY work, yet not teach him ANYTHING at all about why the issue is happening.

Fact is that every question he asks about is script related, and then he ends up not posting the information needed, even when asked about it.


Really, this is why pasting solutions, does nothing. If you said "Read up on XXXX" then he'd go ****** and read. If you said "It's in this section of the script" he'll go ****** that, and read up on it.

By posting up simple "fixes", with a simple "try this" it doesn't teach them anything except to copy and paste, after asking the simplest questions on the forums.
Instead of typing all that would you explean how to fix?
Reply
#6

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
Please people, EXPLAIN where the error is, and not just paste up solutions, that MAY work, yet not teach him ANYTHING at all about why the issue is happening.

Fact is that every question he asks about is script related, and then he ends up not posting the information needed, even when asked about it.


Really, this is why pasting solutions, does nothing. If you said "Read up on XXXX" then he'd go ****** and read. If you said "It's in this section of the script" he'll go ****** that, and read up on it.

By posting up simple "fixes", with a simple "try this" it doesn't teach them anything except to copy and paste, after asking the simplest questions on the forums.
There are no Errors in the script my friend, and I pasted a code and explained what is happening, /buybusiness CMD Isn't setting keys for Second and third slot it works fine only on slot one, there is nothing else needed to find the solution to the problem.



Thank you everyone for the help but It's still not working.
Reply
#7

Quote:
Originally Posted by CoachCarter
Посмотреть сообщение
There are no Errors in the script my friend
Yet it doesn't do what you want it to do... Riiiggghhhttt...


It is however to do with the if section. You should use debug messages to the log to show what it is actually doing. A few more, in each of the 3 key setting areas, and see what it is doing when it runs, then you'll know where the code is going awry, and you'd then know what to be working towards.

Quote:
Originally Posted by jlalt
Посмотреть сообщение
Instead of typing all that would you explean how to fix?
Better than posting up incorrect code and "hoping" that it works...
Reply
#8

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
Better than posting up incorrect code and "hoping" that it works...
actually i test it before post works fine for me
Reply
#9

Quote:
Originally Posted by jlalt
Посмотреть сообщение
actually i test it before post works fine for me
And even if it works? Then what? He doesn't understand what fixed it, and he will be back in a few minutes because something else broke. Better to teach a man how to fish instead of giving him fish.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)