Need help about this command
#1

I'm a new scripter as well, and i'm still learning about zcmd.

I need help for making this command working properly, i can't complie it i got too many errors.

pawn Код:
CMD:setbname(playerid, params[])
{
    if(!PlayerInfo[playerid][pBiz] && !PlayerInfo[playerid][pVBiz]) return SendClientMessage(playerid, COLOR_GREY, "You don't own a business.");
    }
    else if(PlayerInfo[playerid][pBiz])
    {
        new input;
        new idx = PlayerInfo[playerid][pBiz];
        if(IsPlayerInRangeOfPoint(playerid, 2, BizInfo[PlayerInfo[playerid][pBiz]][bX], BizInfo[PlayerInfo[playerid][pBiz]][bY], BizInfo[PlayerInfo[playerid][pBiz]][bZ]))
        BizInfo[idx][bName] = input;
        format(string, sizeof(string), "INFO: You have set your business name to '%s.'", input);
        SendClientMessageEx(playerid, COLOR_WHITE, string)
        Log("logs/business.log", string);
        }
    }
    return 1;
}
Reply
#2

pawn Код:
CMD:setbname(playerid, params[])
{
    if(!PlayerInfo[playerid][pBiz] && !PlayerInfo[playerid][pVBiz]) return SendClientMessage(playerid, COLOR_GREY, "You don't own a business.");
   
    else if(PlayerInfo[playerid][pBiz])
    {
        new input;
        new idx = PlayerInfo[playerid][pBiz];
        if(IsPlayerInRangeOfPoint(playerid, 2, BizInfo[PlayerInfo[playerid][pBiz]][bX], BizInfo[PlayerInfo[playerid][pBiz]][bY], BizInfo[PlayerInfo[playerid][pBiz]][bZ]))
        BizInfo[idx][bName] = input;
        format(string, sizeof(string), "INFO: You have set your business name to '%s.'", input);
        SendClientMessageEx(playerid, COLOR_WHITE, string)
        Log("logs/business.log", string);
       
    }
    return 1;
}
Here it is..

Edit: I didn't look at the code well, I just removed the unuseful brackets.
Reply
#3

The guy above is wrong aswell.

DO it like this
pawn Код:
CMD:setbname(playerid, params[])
{
    new input[128], idx = PlayerInfo[playerid][pBiz];
    if(!PlayerInfo[playerid][pBiz] && !PlayerInfo[playerid][pVBiz]) return SendClientMessage(playerid, COLOR_GREY, "You don't own a business.");
    if(sscanf(params, "s[128]", input)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setbname [name]");
    if(IsPlayerInRangeOfPoint(playerid, 2, BizInfo[PlayerInfo[playerid][pBiz]][bX], BizInfo[PlayerInfo[playerid][pBiz]][bY], BizInfo[PlayerInfo[playerid][pBiz]][bZ]))
    BizInfo[idx][bName] = input;
    format(string, sizeof(string), "INFO: You have set your business name to '%s.'", input);
    SendClientMessageEx(playerid, COLOR_WHITE, string)
    Log("logs/business.log", string);
    return 1;
}
Reply
#4

@Rapeassboi: Well, thanks i just got one error now, it's undefined "string", i just have to put "string[128]", right?
Reply
#5

Quote:
Originally Posted by Rapeassboi
Посмотреть сообщение
The guy above is wrong aswell.
So are you! You're trying to copy a string to another, using sscanf when params can be used and not to have to declare an array. You forgot to use a code block in the IsPlayerInRangeOfPoint statement and plus declaring variables when you don't use them (in case of an error message being displayed).

pawn Код:
CMD:setbname(playerid, params[])
{
    if (!PlayerInfo[playerid][pBiz] && !PlayerInfo[playerid][pVBiz]) return SendClientMessage(playerid, COLOR_GREY, "You don't own a business.");
    if (isnull(params)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /setbname <name>");
   
    new
        idx;
   
    if ((idx = PlayerInfo[playerid][pBiz]))
    {
        if (IsPlayerInRangeOfPoint(playerid, 2, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ]))
        {
            new
                string[128];
           
            strcat((BizInfo[idx][bName][0] = '\0', BizInfo[idx][bName]), params, strlen(params));
            format(string, sizeof (string), "INFO: You have set your business name to '%s.'", params);
            SendClientMessageEx(playerid, COLOR_WHITE, string)
            Log("logs/business.log", string);
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)