Business System
#1

So i have problem that i created business system but players cant buy them, when you write /buybiz nothing hapens.

Here is CMD
PHP код:
CMD:buybiz(playeridparams[])
{
    new 
string[128];
    new 
playername[MAX_PLAYER_NAME];
    new 
sendername[MAX_PLAYER_NAME];
    new 
Float:oldposxFloat:oldposyFloat:oldposz;
    
GetPlayerName(playeridplayernamesizeof(playername));
    
GetPlayerPos(playeridoldposxoldposyoldposz);
    for(new 
0sizeof(BizInfo); b++)
    {
        if(
IsPlayerInRangeOfPoint(playerid,2.0,BizInfo[b][bExteriorX], BizInfo[b][bExteriorY], BizInfo[b][bExteriorZ]) )
        {
            if( 
BizInfo[b][bOwned] == )
            {
                if(
PlayerInfo[playerid][pLevel] < BizInfo[b][bLevel])
                {
                    
format(stringsizeof(string), "   You must be Level %d to purchase this!"BizInfo[b][bLevel]);
                    
SendClientMessageEx(playeridCOLOR_GRAD5string);
                    return 
1;
                    
                }
                if(
PlayerInfo[playerid][pPbizkey] == INVALID_BIZ_ID)
                {
                    if(
GetPlayerCash(playerid) > BizInfo[b][bValue])
                    {
                        
PlayerInfo[playerid][pPbizkey] = b;
                        
BizInfo[b][bOwned] = 1;
                        
GetPlayerName(playeridsendernamesizeof(sendername));
                        
strmid(BizInfo[b][bOwner], sendername0strlen(sendername), 255);
                        
GivePlayerCash(playerid,-BizInfo[b][bValue]);
                        
SetPlayerInterior(playerid,BizInfo[b][bHInteriorWorld]);
                        if(
BizInfo[b][bCustomInterior] == 1)
                        {
                            
TogglePlayerControllable(playerid0);
                            
GameTextForPlayer(playerid"Objects loading..."40005);
                            
SetPVarInt(playerid"LoadingObjects"1);
                            
SetTimerEx("SafeLoadObjects"40000"d"playerid);
                        }
                        
SetPlayerPos(playerid,BizInfo[b][bInteriorX],BizInfo[b][bInteriorY],BizInfo[b][bInteriorZ]);
                        
GameTextForPlayer(playerid"~w~Welcome to your businesse~n~You can exit at any time by moving to this door and typing /exit."50003);
                        
PlayerInfo[playerid][pInt] = BizInfo[b][bHInteriorWorld];
                        
SendClientMessageEx(playeridCOLOR_WHITE"Congratulations on your new purchase!");
                        
SendClientMessageEx(playeridCOLOR_WHITE"Type /help to review the property help section!");
                        
SaveBiz();
                        
OnPlayerStatsUpdate(playerid);
                        
PlayerInfo[playerid][pLocal] = b+6000;
                        
PlayerInfo[playerid][pVW] = b+6000;
                        
SetPlayerVirtualWorld(playeridb+6000);
                        
format(stringsizeof(string), "This business is owned by\n %s\nLevel: %d\nID: %d",BizInfo[b][bOwner],BizInfo[b][bLevel],b);
                        
UpdateDynamic3DTextLabelText(BizInfo[b][bTextID], COLOR_LIGHTBLUEstring);
                        new 
ip[32];
                        
GetPlayerIp(playerid,ip,sizeof(ip));
                        
format(string,sizeof(string),"%s (IP: %s) has bought business ID %d for $%d.",GetPlayerNameEx(playerid),ip,b,BizInfo[b][bValue]);
                        
Log("logs/biz.log"string);
                        return 
1;
                    }
                    else
                    {
                        
SendClientMessageEx(playeridCOLOR_WHITE"   You don't have the cash for that!");
                        return 
1;
                    }
                }
                        }
            else
            {
                
SendClientMessageExplayeridCOLOR_WHITE"This business is owned." );
            }
        }
    }
    return 
1;

Reply
#2

pawn Код:
CMD:buybiz(playerid, params[])
{
    new string[128];
    new playername[MAX_PLAYER_NAME];
    new sendername[MAX_PLAYER_NAME];
    new Float:oldposx, Float:oldposy, Float:oldposz;
    GetPlayerName(playerid, playername, sizeof(playername));
    GetPlayerPos(playerid, oldposx, oldposy, oldposz);
    for(new b = 0; b < sizeof(BizInfo); b++)
    {
        if(IsPlayerInRangeOfPoint(playerid,2.0,BizInfo[b][bExteriorX], BizInfo[b][bExteriorY], BizInfo[b][bExteriorZ]) )
        {
            if( BizInfo[b][bOwned] == 0 )
            {
                if(PlayerInfo[playerid][pLevel] < BizInfo[b][bLevel])
                {
                    format(string, sizeof(string), "   You must be Level %d to purchase this!", BizInfo[b][bLevel]);
                    SendClientMessageEx(playerid, COLOR_GRAD5, string);
                    return 1;
                   
                }
                if(PlayerInfo[playerid][pPbizkey] == INVALID_BIZ_ID)
                {

                    if(GetPlayerCash(playerid) > BizInfo[b][bValue])
                    {
                        PlayerInfo[playerid][pPbizkey] = b;
                        BizInfo[b][bOwned] = 1;
                        GetPlayerName(playerid, sendername, sizeof(sendername));
                        strmid(BizInfo[b][bOwner], sendername, 0, strlen(sendername), 255);
                        GivePlayerCash(playerid,-BizInfo[b][bValue]);
                        SetPlayerInterior(playerid,BizInfo[b][bHInteriorWorld]);
                        if(BizInfo[b][bCustomInterior] == 1)
                        {
                            TogglePlayerControllable(playerid, 0);
                            GameTextForPlayer(playerid, "Objects loading...", 4000, 5);
                            SetPVarInt(playerid, "LoadingObjects", 1);
                            SetTimerEx("SafeLoadObjects", 4000, 0, "d", playerid);
                        }
                        SetPlayerPos(playerid,BizInfo[b][bInteriorX],BizInfo[b][bInteriorY],BizInfo[b][bInteriorZ]);
                        GameTextForPlayer(playerid, "~w~Welcome to your businesse~n~You can exit at any time by moving to this door and typing /exit.", 5000, 3);
                        PlayerInfo[playerid][pInt] = BizInfo[b][bHInteriorWorld];
                        SendClientMessageEx(playerid, COLOR_WHITE, "Congratulations on your new purchase!");
                        SendClientMessageEx(playerid, COLOR_WHITE, "Type /help to review the property help section!");
                        SaveBiz();
                        OnPlayerStatsUpdate(playerid);
                        PlayerInfo[playerid][pLocal] = b+6000;
                        PlayerInfo[playerid][pVW] = b+6000;
                        SetPlayerVirtualWorld(playerid, b+6000);

                        format(string, sizeof(string), "This business is owned by\n %s\nLevel: %d\nID: %d",BizInfo[b][bOwner],BizInfo[b][bLevel],b);
                        UpdateDynamic3DTextLabelText(BizInfo[b][bTextID], COLOR_LIGHTBLUE, string);
                        new ip[32];
                        GetPlayerIp(playerid,ip,sizeof(ip));
                        format(string,sizeof(string),"%s (IP: %s) has bought business ID %d for $%d.",GetPlayerNameEx(playerid),ip,b,BizInfo[b][bValue]);
                        Log("logs/biz.log", string);
                        return 1;
                    }
                    else
                    {
                        SendClientMessageEx(playerid, COLOR_WHITE, "   You don't have the cash for that!");
                        return 1;
                    }
                }
                       }
            else
            {
                SendClientMessageEx( playerid, COLOR_WHITE, "This business is owned." );
            }
        }
    }
    return 1;
}
you have a bad placed "}" I think that could be the problem

I think this is the correct way:
pawn Код:
CMD:buybiz(playerid, params[])
{
    new string[128];
    new playername[MAX_PLAYER_NAME];
    new sendername[MAX_PLAYER_NAME];
    new Float:oldposx, Float:oldposy, Float:oldposz;
    GetPlayerName(playerid, playername, sizeof(playername));
    GetPlayerPos(playerid, oldposx, oldposy, oldposz);
    for(new b = 0; b < sizeof(BizInfo); b++)
    {
        if(IsPlayerInRangeOfPoint(playerid,2.0,BizInfo[b][bExteriorX], BizInfo[b][bExteriorY], BizInfo[b][bExteriorZ]) )
        {
            if( BizInfo[b][bOwned] == 0 )
            {
                if(PlayerInfo[playerid][pLevel] < BizInfo[b][bLevel])
                {
                    format(string, sizeof(string), "   You must be Level %d to purchase this!", BizInfo[b][bLevel]);
                    SendClientMessageEx(playerid, COLOR_GRAD5, string);
                    return 1;
                   
                }
                if(PlayerInfo[playerid][pPbizkey] == INVALID_BIZ_ID)
                {

                    if(GetPlayerCash(playerid) > BizInfo[b][bValue])
                    {
                        PlayerInfo[playerid][pPbizkey] = b;
                        BizInfo[b][bOwned] = 1;
                        GetPlayerName(playerid, sendername, sizeof(sendername));
                        strmid(BizInfo[b][bOwner], sendername, 0, strlen(sendername), 255);
                        GivePlayerCash(playerid,-BizInfo[b][bValue]);
                        SetPlayerInterior(playerid,BizInfo[b][bHInteriorWorld]);
                        if(BizInfo[b][bCustomInterior] == 1)
                        {
                            TogglePlayerControllable(playerid, 0);
                            GameTextForPlayer(playerid, "Objects loading...", 4000, 5);
                            SetPVarInt(playerid, "LoadingObjects", 1);
                            SetTimerEx("SafeLoadObjects", 4000, 0, "d", playerid);
                        }
                        SetPlayerPos(playerid,BizInfo[b][bInteriorX],BizInfo[b][bInteriorY],BizInfo[b][bInteriorZ]);
                        GameTextForPlayer(playerid, "~w~Welcome to your businesse~n~You can exit at any time by moving to this door and typing /exit.", 5000, 3);
                        PlayerInfo[playerid][pInt] = BizInfo[b][bHInteriorWorld];
                        SendClientMessageEx(playerid, COLOR_WHITE, "Congratulations on your new purchase!");
                        SendClientMessageEx(playerid, COLOR_WHITE, "Type /help to review the property help section!");
                        SaveBiz();
                        OnPlayerStatsUpdate(playerid);
                        PlayerInfo[playerid][pLocal] = b+6000;
                        PlayerInfo[playerid][pVW] = b+6000;
                        SetPlayerVirtualWorld(playerid, b+6000);

                        format(string, sizeof(string), "This business is owned by\n %s\nLevel: %d\nID: %d",BizInfo[b][bOwner],BizInfo[b][bLevel],b);
                        UpdateDynamic3DTextLabelText(BizInfo[b][bTextID], COLOR_LIGHTBLUE, string);
                        new ip[32];
                        GetPlayerIp(playerid,ip,sizeof(ip));
                        format(string,sizeof(string),"%s (IP: %s) has bought business ID %d for $%d.",GetPlayerNameEx(playerid),ip,b,BizInfo[b][bValue]);
                        Log("logs/biz.log", string);
                        return 1;
                    }
                    else
                    {
                        SendClientMessageEx(playerid, COLOR_WHITE, "   You don't have the cash for that!");
                        return 1;
                    }
                }
            }
            else
            {
                SendClientMessageEx( playerid, COLOR_WHITE, "This business is owned." );
            }
        }
    }
    return 1;
}
Reply
#3

You put an "}" in there pal

Код:
CMD:buybiz(playerid, params[])
{
    new string[128];
    new playername[MAX_PLAYER_NAME];
    new sendername[MAX_PLAYER_NAME];
    new Float:oldposx, Float:oldposy, Float:oldposz;
    GetPlayerName(playerid, playername, sizeof(playername));
    GetPlayerPos(playerid, oldposx, oldposy, oldposz);
    for(new b = 0; b < sizeof(BizInfo); b++)
    {
        if(IsPlayerInRangeOfPoint(playerid,2.0,BizInfo[b][bExteriorX], BizInfo[b][bExteriorY], BizInfo[b][bExteriorZ]) )
        {
            if( BizInfo[b][bOwned] == 0 )
            {
                if(PlayerInfo[playerid][pLevel] < BizInfo[b][bLevel])
                {
                    format(string, sizeof(string), "   You must be Level %d to purchase this!", BizInfo[b][bLevel]);
                    SendClientMessageEx(playerid, COLOR_GRAD5, string);
                    return 1;
                    
                }
                if(PlayerInfo[playerid][pPbizkey] == INVALID_BIZ_ID)
                {

                    if(GetPlayerCash(playerid) > BizInfo[b][bValue])
                    {
                        PlayerInfo[playerid][pPbizkey] = b;
                        BizInfo[b][bOwned] = 1;
                        GetPlayerName(playerid, sendername, sizeof(sendername));
                        strmid(BizInfo[b][bOwner], sendername, 0, strlen(sendername), 255);
                        GivePlayerCash(playerid,-BizInfo[b][bValue]);
                        SetPlayerInterior(playerid,BizInfo[b][bHInteriorWorld]);
                        if(BizInfo[b][bCustomInterior] == 1)
                        {
                            TogglePlayerControllable(playerid, 0);
                            GameTextForPlayer(playerid, "Objects loading...", 4000, 5);
                            SetPVarInt(playerid, "LoadingObjects", 1);
                            SetTimerEx("SafeLoadObjects", 4000, 0, "d", playerid);
                        }
                        SetPlayerPos(playerid,BizInfo[b][bInteriorX],BizInfo[b][bInteriorY],BizInfo[b][bInteriorZ]);
                        GameTextForPlayer(playerid, "~w~Welcome to your businesse~n~You can exit at any time by moving to this door and typing /exit.", 5000, 3);
                        PlayerInfo[playerid][pInt] = BizInfo[b][bHInteriorWorld];
                        SendClientMessageEx(playerid, COLOR_WHITE, "Congratulations on your new purchase!");
                        SendClientMessageEx(playerid, COLOR_WHITE, "Type /help to review the property help section!");
                        SaveBiz();
                        OnPlayerStatsUpdate(playerid);
                        PlayerInfo[playerid][pLocal] = b+6000;
                        PlayerInfo[playerid][pVW] = b+6000;
                        SetPlayerVirtualWorld(playerid, b+6000);

                        format(string, sizeof(string), "This business is owned by\n %s\nLevel: %d\nID: %d",BizInfo[b][bOwner],BizInfo[b][bLevel],b);
                        UpdateDynamic3DTextLabelText(BizInfo[b][bTextID], COLOR_LIGHTBLUE, string);
                        new ip[32];
                        GetPlayerIp(playerid,ip,sizeof(ip));
                        format(string,sizeof(string),"%s (IP: %s) has bought business ID %d for $%d.",GetPlayerNameEx(playerid),ip,b,BizInfo[b][bValue]);
                        Log("logs/biz.log", string);
                        return 1;
                    }
                    else
                    {
                        SendClientMessageEx(playerid, COLOR_WHITE, "   You don't have the cash for that!");
                        return 1;
                    }
                }
            }
            else
            {
                SendClientMessageEx( playerid, COLOR_WHITE, "This business is owned." );
            }
        }
    }
    return 1;
}
Reply
#4

Still it isn't working
Reply
#5

Can someone else can help?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)