Help On this CMD
#1

This cmd have a problem when i join the server and type it does not show this message
PHP код:
SendClientMessage(playeridCOLOR_GRAD2"You're not in your bussiness."); 
PHP код:
CMD:bizwithdraw(playeridparams[])
{
    for(new 
biz 0biz MAX_BIZbiz++)
    {
        if(
IsPlayerInRangeOfPoint(playerid100BizInfo[biz][IXCoord], BizInfo[biz][IYCoord], BizInfo[biz][IZCoord]))
        {
            if(
GetPlayerVirtualWorld(playerid) == BizInfo[biz][VW])
            {
                if(!
strcmp(BizInfo[biz][Owner], GetPlayerNameEx(playerid), true))
                {
                    new 
money;
                    if(
sscanf(params,"d"money)) return SendClientMessage(playeridCOLOR_WHITE"USAGE: /bizwithdraw [amount]");
                    if(
money BizInfo[biz][Till]) return SendClientMessage(playeridCOLOR_GRAD2"You don't have that much money in your Till!");
                    new 
string[150];
                    
format(string,sizeof(string),"You've taken $%d out of your Business Till."money);
                    
SendClientMessage(playeridCOLOR_GREYstring);
                     
GivePlayerCash(playeridmoney);
                     
BizInfo[biz][Till] -= money;
                }
                else
                {
                    
SendClientMessage(playeridCOLOR_GRAD2"You're not in your bussiness.");
                }
            }
        }
    }
    return 
1;

Reply
#2

if(!strcmp(BizInfo[biz][Owner], GetPlayerNameEx(playerid), true))

That line has something wrong with it, but I don't really know how to fix it.
Reply
#3

Код:
CMD:bizwithdraw(playerid, params[])
{
    for(new biz = 0; biz < MAX_BIZ; biz++)
    {
        if(IsPlayerInRangeOfPoint(playerid, 100, BizInfo[biz][IXCoord], BizInfo[biz][IYCoord], BizInfo[biz][IZCoord]))
        {
            if(GetPlayerVirtualWorld(playerid) == BizInfo[biz][VW])
            {
                if(strcmp(BizInfo[biz][Owner], GetPlayerNameEx(playerid), true)) == 0)
                {
                    new money;
                    if(sscanf(params,"d", money)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /bizwithdraw [amount]");
                    if(money > BizInfo[biz][Till]) return SendClientMessage(playerid, COLOR_GRAD2, "You don't have that much money in your Till!");
                    new string[150];
                    format(string,sizeof(string),"You've taken $%d out of your Business Till.", money);
                    SendClientMessage(playerid, COLOR_GREY, string);
                     GivePlayerCash(playerid, money);
                     BizInfo[biz][Till] -= money;
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "You're not in your bussiness.");
                }
            }
        }
    }
    return 1;
}
Reply
#4

Quote:
Originally Posted by Bolex_
Посмотреть сообщение
Код:
CMD:bizwithdraw(playerid, params[])
{
    for(new biz = 0; biz < MAX_BIZ; biz++)
    {
        if(IsPlayerInRangeOfPoint(playerid, 100, BizInfo[biz][IXCoord], BizInfo[biz][IYCoord], BizInfo[biz][IZCoord]))
        {
            if(GetPlayerVirtualWorld(playerid) == BizInfo[biz][VW])
            {
                if(strcmp(BizInfo[biz][Owner], GetPlayerNameEx(playerid), true)) == 0)
                {
                    new money;
                    if(sscanf(params,"d", money)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /bizwithdraw [amount]");
                    if(money > BizInfo[biz][Till]) return SendClientMessage(playerid, COLOR_GRAD2, "You don't have that much money in your Till!");
                    new string[150];
                    format(string,sizeof(string),"You've taken $%d out of your Business Till.", money);
                    SendClientMessage(playerid, COLOR_GREY, string);
                     GivePlayerCash(playerid, money);
                     BizInfo[biz][Till] -= money;
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "You're not in your bussiness.");
                }
            }
        }
    }
    return 1;
}
This have not worked
Reply
#5

@Bolex, don't bother helping unless you know the obvious. According to wiki.sa-mp.com, you can find that strcmp = 0 when the string matches at the given length, and will be 1 (or -1) when not. Look at the picture further down, which is a screenshot from the wiki page.

PHP код:
                if(!strcmp(BizInfo[biz][Owner], GetPlayerNameEx(playerid), true))  //here is the problem
                

                    new 
money
                    if(
sscanf(params,"d"money)) return SendClientMessage(playeridCOLOR_WHITE"USAGE: /bizwithdraw [amount]"); 
                    if(
money BizInfo[biz][Till]) return SendClientMessage(playeridCOLOR_GRAD2"You don't have that much money in your Till!"); 
                    new 
string[150]; 
                    
format(string,sizeof(string),"You've taken $%d out of your Business Till."money); 
                    
SendClientMessage(playeridCOLOR_GREYstring); 
                     
GivePlayerCash(playeridmoney); 
                     
BizInfo[biz][Till] -= money
                } 
                else  
//because this code executes
                

                    
SendClientMessage(playeridCOLOR_GRAD2"You're not in your bussiness."); 
                } 
So how can you solve it?
First of all you have to ensure that
PHP код:
BizInfo[biz][Owner
has been set correctly, when the owner is being set. If this doesn't match with the players name, it will eventually fail.
Can you show code where you set the biz owner, and does similar code work somewhere else?
Also, note that, if one of the strings are empy, they will return 0 on strcmp as well, so just in case - check that as well in order to avoid bugs.


Reply
#6

Quote:
Originally Posted by Bolex_
Посмотреть сообщение
Код:
CMD:bizwithdraw(playerid, params[])
{
    for(new biz = 0; biz < MAX_BIZ; biz++)
    {
        if(IsPlayerInRangeOfPoint(playerid, 100, BizInfo[biz][IXCoord], BizInfo[biz][IYCoord], BizInfo[biz][IZCoord]))
        {
            if(GetPlayerVirtualWorld(playerid) == BizInfo[biz][VW])
            {
                if(strcmp(BizInfo[biz][Owner], GetPlayerNameEx(playerid), true)) == 0)
                {
                    new money;
                    if(sscanf(params,"d", money)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /bizwithdraw [amount]");
                    if(money > BizInfo[biz][Till]) return SendClientMessage(playerid, COLOR_GRAD2, "You don't have that much money in your Till!");
                    new string[150];
                    format(string,sizeof(string),"You've taken $%d out of your Business Till.", money);
                    SendClientMessage(playerid, COLOR_GREY, string);
                     GivePlayerCash(playerid, money);
                     BizInfo[biz][Till] -= money;
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "You're not in your bussiness.");
                }
            }
        }
    }
    return 1;
}
So Its False How to fix it?
Reply
#7

Did you check if the variable contained the correct username? (And that it's a string?)
Reply
#8

Try This:
PHP код:
CMD:bizwithdraw(playeridparams[])
{
    for(new 
biz 0biz MAX_BIZbiz++)
    {
        if(
IsPlayerInRangeOfPoint(playerid100BizInfo[biz][IXCoord], BizInfo[biz][IYCoord], BizInfo[biz][IZCoord]))
        {
            if(
GetPlayerVirtualWorld(playerid) == BizInfo[biz][VW])
            {
                if(!
strcmp(BizInfo[biz][Owner], GetPlayerNameEx(playerid), true))
                {
                    new 
money;
                    if(
sscanf(params,"d"money)) return SendClientMessage(playeridCOLOR_WHITE"USAGE: /bizwithdraw [amount]");
                    if(
money BizInfo[biz][Till]) return SendClientMessage(playeridCOLOR_GRAD2"You don't have that much money in your Till!");
                    new 
string[150];
                    
format(string,sizeof(string),"You've taken $%d out of your Business Till."money);
                    
SendClientMessage(playeridCOLOR_GREYstring);
                     
GivePlayerCash(playeridmoney);
                     
BizInfo[biz][Till] -= money;
                }
                else
                {
                    
SendClientMessage(playeridCOLOR_GRAD2"You're not in your bussiness.");
                }
            }
        }
    }
    return 
1;

Also, Make sure your Owner's name is getting saved correctly inside files.
Reply
#9

IsPlayerInRangeOfPoint 100 -> That's a huge range, lover it to about 2-3 units if you want player to stand at pickup/cp/entrance, or to about 10-20 if you want him to be in vicinity.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)