problem with my business system
#1

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?
Reply
#2

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.
Reply
#3

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(playeridparams[],help)
{
    new 
id IsPlayerNearBizEnt(playerid);
    if(
id == -|| id == 0) return SendClientMessage(playeridCOLOR_GREY"You are not near a biz");
    if(
BusinessInfo[id][bOwned] != || BusinessInfo[id][bPrice] == 0) return SendClientMessage(playeridCOLOR_GREY"This biz is not for sale.");
    if(
PlayerInfo[playerid][BizID] != 0) return SendClientMessage(playeridCOLOR_LIGHTRED"You already own a biz.");
    if(
GetPlayerMoney(playerid) < BusinessInfo[id][bPrice]) return SendClientMessage(playeridCOLOR_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"120000true);
    
SendClientMessage(playeridCOLOR_YELLOW"Congratulations on your new biz! Use /bizhelp to get help");
    new 
pname[MAX_PLAYER_NAME], string[9000 MAX_PLAYER_NAME];
    
GetPlayerName(playeridpnamesizeof(pname));
    
format(stringsizeof(string), "%s has bought a biz!"pname);
    
SendClientMessageToAll(0x00C1C1FFstring);
    return 
1;

Reply
#4

Quote:
Originally Posted by MarkNelson
Посмотреть сообщение
this is the buying command look
PHP код:
YCMD:buybiz(playeridparams[],help)
{
    new 
id IsPlayerNearBizEnt(playerid);
    if(
id == -|| id == 0) return SendClientMessage(playeridCOLOR_GREY"You are not near a biz");
    if(
BusinessInfo[id][bOwned] != || BusinessInfo[id][bPrice] == 0) return SendClientMessage(playeridCOLOR_GREY"This biz is not for sale.");
    if(
PlayerInfo[playerid][BizID] != 0) return SendClientMessage(playeridCOLOR_LIGHTRED"You already own a biz.");
    if(
GetPlayerMoney(playerid) < BusinessInfo[id][bPrice]) return SendClientMessage(playeridCOLOR_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"120000true);
    
SendClientMessage(playeridCOLOR_YELLOW"Congratulations on your new biz! Use /bizhelp to get help");
    new 
pname[MAX_PLAYER_NAME], string[9000 MAX_PLAYER_NAME];
    
GetPlayerName(playeridpnamesizeof(pname));
    
format(stringsizeof(string), "%s has bought a biz!"pname);
    
SendClientMessageToAll(0x00C1C1FFstring);
    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.
Reply
#5

well, see
PHP код:
YCMD:sellbiz(playeridparams[],help)
{
    new 
id PlayerInfo[playerid][BizID];
    if(
PlayerInfo[playerid][BizID] == 0) return SCM(playeridCOLOR_GREY"You don't own a biz!");
    
BusinessInfo[id][bOwned] = 0;
    
BusinessInfo[id][bOwner] = 0;
    
BusinessInfo[id][bLocked] = 1;
    
GivePlayerMoney(playeridBusinessInfo[id][bPrice]);
    
PlayerInfo[playerid][BizID] = 0;
    
SCM(playeridCOLOR_YELLOW"Business sold!");
    return 
1;
}
YCMD:bizsetname(playeridparams[],help)
{
    new 
name[128];
    if(
sscanf(params"s[128]"name)) return SCM(playeridCOLOR_GREY"/bizsetname [name]");
    if(
PlayerInfo[playerid][BizID] == 0) return SCM(playeridCOLOR_GREY"You don't own a biz!");
    
BusinessInfo[PlayerInfo[playerid][BizID]][bName] = name;
    
SCM(playeridCOLOR_YELLOW"Business name changed!");
    return 
1;

Reply
#6

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?
Reply
#7

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(playeridreason)
{
    
dini_IntSet(UserPath(playerid), "Money"PlayerInfo[playerid][Money]);
    
dini_IntSet(UserPath(playerid), "BizID"PlayerInfo[playerid][BizID]);
    
PlayerInfo[playerid][BizID] = 0;
    return 
1;

Reply
#8

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.
Reply
#9

PHP код:
stock UserPath(playerid)
{
    new 
string[128],playername[MAX_PLAYER_NAME];
    
GetPlayerName(playerid,playername,sizeof(playername));
    
format(string,sizeof(string),BPATH,playername);
    return 
string;

Reply
#10

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?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)