SA-MP Forums Archive
Business owner bugged - 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: Business owner bugged (/showthread.php?tid=625931)



Business owner bugged - ThatFag - 08.01.2017

Hello there, im currently running a server for like 2-3 weeks and the business system was working okay but now a bug just showed up , when an admin does /mybusinesses it shows him all existing businesses not the one that he owns ( that what cmd is meant to show) , i checked out the databases and saw that at "Owner table" the name was not saving as "NoBody" if there was no owner but as blank space " " , how can i check this shit out to fix it i got no idea


Re: Business owner bugged - Lordzy - 08.01.2017

Alter your table and modify the column's default value to 'NoBody'.
pawn Код:
ALTER `table` MODIFY 'buis_owner_column` VARCHAR(25) NOT NULL DEFAULT 'NoBody'
You should also restart your server once a week to make sure things are going well.

PS : It's better to use foreign keys than storing plain names.


Re: Business owner bugged - ThatFag - 08.01.2017

It was defined as "Null" but i think the problem is coming from SaveBusiness stock.
is there a way i could debug so i can find out whats the matter ?


Re: Business owner bugged - Vince - 08.01.2017

To do it properly the "owner" column should store the id of the player that owns it, not their name. If there isn't an owner then that column should be null.

The importance of proper foreign keys only surfaces the moment a player's name changes or the player's account gets deleted in its entirety. Your artificial relation is suddenly broken and you are left with what are known as "orphaned rows" which are a mess to clean up.

Whereas with proper relations a name change doesn't affect anything because it is only stored in one place and if a user is deleted the database engine automatically does a cleanup, e.g. removing that player as the owner from any businesses.


Re: Business owner bugged - ThatFag - 08.01.2017

So you saying to store the playerid as owner and not their name ?
i also have "SQLID" on my player database and i was thinking to make it for owner instant of players name because that sqlid never changes even if the player has changed the name or did anything


Re: Business owner bugged - Lordzy - 08.01.2017

Quote:
Originally Posted by ThatFag
Посмотреть сообщение
So you saying to store the playerid as owner and not their name ?
i also have "SQLID" on my player database and i was thinking to make it for owner instant of players name because that sqlid never changes even if the player has changed the name or did anything
Not the playerid because it changes. You can use th "SQLID" data as a reference on business table.


Re: Business owner bugged - daniel2516 - 08.01.2017

Deleted