problem with my business system -
MarkNelson - 21.12.2017
Hello everyone. Well, i'm updating my server script but i've faced a problem and i tried to fix it but failed..
Let me tell you about the issue. My dynamic property system works well, it saves the property and the property owner, but the problem is... lemme explain this too :
Player 1 is named Hobo, he bought a property
Player 2 is named Harry.
Well, Hobo bought a property then left the game, then Harry joins the game and he can use the property owner cmds.
So, if the both of players has a name which starts with the same alphabet
like Hobo and Harry, both of their names starts with "H"
both of them is the owner.
P.S: I'm using dini
So, can you help me fixing this?
Re: problem with my business system -
RogueDrifter - 21.12.2017
show one of the cmds and show how does a player buy a property, the reason could be to one of the following:
1- you're doing a player variable that isn't terminated onplayerdisconnect, EX:
PHP код:
CMD:buyproperty(playerd,params[])
{
propertyplayer[playerid]=1;//should set that to 0 onplayerdisconnect
return 1;
}
but you don't reset that onplayerdisconnect to 0
OR: your name string is too short and only reads the first letter, for EX:
PHP код:
name[2];//should be longer than 2
public OnPlayerConnect(playerid)
{
GetPlayerName(playerid,name,sizeof(name));
SendClientMessageEx(playerid,-1,"Hi %s",name);
return 1;
}
so yes provide more info please.
Re: problem with my business system -
MarkNelson - 21.12.2017
Quote:
Originally Posted by RogueDrifter
show one of the cmds and show how does a player buy a property, the reason could be to one of the following:
1- you're doing a player variable that isn't terminated onplayerdisconnect, EX:
PHP код:
CMD:buyproperty(playerd,params[])
{
propertyplayer[playerid]=1;//should set that to 0 onplayerdisconnect
return 1;
}
but you don't reset that onplayerdisconnect to 0
OR: your name string is too short and only reads the first letter, for EX:
PHP код:
name[2];//should be longer than 2
public OnPlayerConnect(playerid)
{
GetPlayerName(playerid,name,sizeof(name));
SendClientMessageEx(playerid,-1,"Hi %s",name);
return 1;
}
so yes provide more info please.
|
this is the buying command look
PHP код:
YCMD:buybiz(playerid, params[],help)
{
new id = IsPlayerNearBizEnt(playerid);
if(id == -1 || id == 0) return SendClientMessage(playerid, COLOR_GREY, "You are not near a biz");
if(BusinessInfo[id][bOwned] != 0 || BusinessInfo[id][bPrice] == 0) return SendClientMessage(playerid, COLOR_GREY, "This biz is not for sale.");
if(PlayerInfo[playerid][BizID] != 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You already own a biz.");
if(GetPlayerMoney(playerid) < BusinessInfo[id][bPrice]) return SendClientMessage(playerid, COLOR_LIGHTRED, "Sorry, you can not afford this biz.");
PlayerInfo[playerid][BizID] = id;
PlayerInfo[playerid][Money] -= BusinessInfo[id][bPrice];
GivePlayerMoney(playerid, -BusinessInfo[id][bPrice]);
BusinessInfo[id][bLocked] = 0;
BusinessInfo[id][bOwned] = 1;
BusinessInfo[id][bOwner] = RemoveUnderScore(playerid);
SetTimer("bizpayout", 120000, true);
SendClientMessage(playerid, COLOR_YELLOW, "Congratulations on your new biz! Use /bizhelp to get help");
new pname[MAX_PLAYER_NAME], string[9000 + MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(string, sizeof(string), "%s has bought a biz!", pname);
SendClientMessageToAll(0x00C1C1FF, string);
return 1;
}
Re: problem with my business system -
RogueDrifter - 21.12.2017
Quote:
Originally Posted by MarkNelson
this is the buying command look
PHP код:
YCMD:buybiz(playerid, params[],help)
{
new id = IsPlayerNearBizEnt(playerid);
if(id == -1 || id == 0) return SendClientMessage(playerid, COLOR_GREY, "You are not near a biz");
if(BusinessInfo[id][bOwned] != 0 || BusinessInfo[id][bPrice] == 0) return SendClientMessage(playerid, COLOR_GREY, "This biz is not for sale.");
if(PlayerInfo[playerid][BizID] != 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You already own a biz.");
if(GetPlayerMoney(playerid) < BusinessInfo[id][bPrice]) return SendClientMessage(playerid, COLOR_LIGHTRED, "Sorry, you can not afford this biz.");
PlayerInfo[playerid][BizID] = id;
PlayerInfo[playerid][Money] -= BusinessInfo[id][bPrice];
GivePlayerMoney(playerid, -BusinessInfo[id][bPrice]);
BusinessInfo[id][bLocked] = 0;
BusinessInfo[id][bOwned] = 1;
BusinessInfo[id][bOwner] = RemoveUnderScore(playerid);
SetTimer("bizpayout", 120000, true);
SendClientMessage(playerid, COLOR_YELLOW, "Congratulations on your new biz! Use /bizhelp to get help");
new pname[MAX_PLAYER_NAME], string[9000 + MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(string, sizeof(string), "%s has bought a biz!", pname);
SendClientMessageToAll(0x00C1C1FF, string);
return 1;
}
|
I need to see one of the biz command, not just the buying i need to know if you're basing it on a [playerid] variable or not, also make sure that all of those [id] and [playerid] are set to either 0 or -1 at OnPlayerDisconnect.
Re: problem with my business system -
MarkNelson - 21.12.2017
well, see
PHP код:
YCMD:sellbiz(playerid, params[],help)
{
new id = PlayerInfo[playerid][BizID];
if(PlayerInfo[playerid][BizID] == 0) return SCM(playerid, COLOR_GREY, "You don't own a biz!");
BusinessInfo[id][bOwned] = 0;
BusinessInfo[id][bOwner] = 0;
BusinessInfo[id][bLocked] = 1;
GivePlayerMoney(playerid, BusinessInfo[id][bPrice]);
PlayerInfo[playerid][BizID] = 0;
SCM(playerid, COLOR_YELLOW, "Business sold!");
return 1;
}
YCMD:bizsetname(playerid, params[],help)
{
new name[128];
if(sscanf(params, "s[128]", name)) return SCM(playerid, COLOR_GREY, "/bizsetname [name]");
if(PlayerInfo[playerid][BizID] == 0) return SCM(playerid, COLOR_GREY, "You don't own a biz!");
BusinessInfo[PlayerInfo[playerid][BizID]][bName] = name;
SCM(playerid, COLOR_YELLOW, "Business name changed!");
return 1;
}
Re: problem with my business system -
RogueDrifter - 21.12.2017
is this line
PHP код:
PlayerInfo[playerid][BizID];
set to 0 at
OnPlayerDisconnect?
like do you have this
PlayerInfo[playerid][BizID] = 0; also id=0; at the disconnect callback function?
Re: problem with my business system -
MarkNelson - 21.12.2017
yea, look :
PHP код:
public OnPlayerConnect(playerid)
{
if(fexist(UserPath(playerid)))
{
PlayerInfo[playerid][Money] = dini_Int(UserPath(playerid), "Money");
if(dini_Isset(UserPath(playerid), "BizID"))
{
PlayerInfo[playerid][BizID] = dini_Int(UserPath(playerid), "BizID");
}
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
dini_IntSet(UserPath(playerid), "Money", PlayerInfo[playerid][Money]);
dini_IntSet(UserPath(playerid), "BizID", PlayerInfo[playerid][BizID]);
PlayerInfo[playerid][BizID] = 0;
return 1;
}
Re: problem with my business system -
RogueDrifter - 21.12.2017
Hm and the player who SUPPOSEDLY doesn't own the biz can use the /sellbiz command right? if so please show me the UserPath callback we'll trace this down to see how it's set this is the only possible thing since that's the only exception put at the /sellbiz cmd.
Re: problem with my business system -
MarkNelson - 21.12.2017
PHP код:
stock UserPath(playerid)
{
new string[128],playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playername));
format(string,sizeof(string),BPATH,playername);
return string;
}
Re: problem with my business system -
RogueDrifter - 21.12.2017
Well i'll be damned, i see nothing wrong with the code, although here's one last thing, what is the define of BPATH also quick question are you sure about you said in the post? it only happens for players with the same first initials? H and H for ex? did you try different names at the same playerid? like are you sure that the biz is not saved at playerid 0 ? if the above checks correct the only thing wrong could be in the PlayerInfo, are the other player's data also being loaded for the player connecting after? EX: player A connects with id 0, gains 5000 cash, disconnects, player B connects id 0 and gets the 5000 cash that player A had, does that happen?