Need help about this command -
NekoChan - 17.01.2014
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;
}
Re: Need help about this command -
Zamora - 17.01.2014
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.
Re: Need help about this command -
Rapeassboi - 17.01.2014
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;
}
Re: Need help about this command -
NekoChan - 17.01.2014
@Rapeassboi: Well, thanks i just got one error now, it's undefined "string", i just have to put "string[128]", right?
Re: Need help about this command -
Konstantinos - 17.01.2014
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;
}