sscanf /issuelicense [playerid] [param] help.
#1

I just need help with something simple. I dont need the command made or anything, I'm a decent enough scripter.

Код:
if(sscanf(params, "us[144]", PID))
Pretty sure us[144] does playerid/partofname but I need it to do "playerid/partofname parameter"
Note, PID = playerid
That parameter will be defined with this, for example (read below).
Код:
if(!strcmp(params, "none"))
Reply
#2

PHP код:
new PIDsomething[144];
if(
sscanf(params"us[144]"PIDsomething)) 
PHP код:
if(!strcmp(something"none")) 
^ You are looking for something inside your parameter called "something". If you take params in the precedent condition, you will have "/issulicense ..."
Reply
#3

PHP код:
if(sscanf(params"u"PID)) 
Reply
#4

Quote:
Originally Posted by Dayrion
Посмотреть сообщение
PHP код:
new PIDsomething[144];
if(
sscanf(params"us[144]"PIDsomething)) 
PHP код:
if(!strcmp(something"none")) 
^ You are looking for something inside your parameter called "something". If you take params in the precedent condition, you will have "/issulicense ..."
Thanks, gonna give this a try. REP for your effort.
Reply
#5

This is what I ended up with.

Код:
CMD:issuelicense(playerid, params[])
{
	new PID;
	new string[128];
	new param[144];
	new Float:X;
	new Float:Y;
	new Float:Z;
	GetPlayerPos(PID, X, Y, Z);
	if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
	if(PlayerInfo[playerid][pAdmin] < 6) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
	if(IsPlayerInRangeOfPoint(playerid, 5.0, X, Y, Z))
	if(sscanf(params, "us[144]", PID, param))
	{
		SendClientMessage(playerid, COLOR_GREY, "[Usage:] /issuelicense [playerid/partofname] [param]");
		SendClientMessage(playerid, COLOR_GREY, "PARAMS: PF, BLS");
		SendClientMessage(playerid, COLOR_GREY, "TIP: If you want to revoke a license, use /revokelicense.");
	}
	if(!strcmp(param, "PF"))
	{
		PlayerInfo[playerid][pPF] = 1;
		format(string, sizeof(string), "You have given %s a PF license.", RPN(playerid));
		SendClientMessage(playerid, -1, string);
		format(string, sizeof(string), "%s has given you a PF license.", RPN(playerid));
		SendClientMessage(PID, -1, string);
	}
	if(!strcmp(param, "BLS"))
	{
		PlayerInfo[playerid][pBLS] = 1;
		format(string, sizeof(string), "You have given %s a BLS license.", RPN(playerid));
		SendClientMessage(playerid, -1, string);
		format(string, sizeof(string), "%s has given you a BLS license.", RPN(playerid));
		SendClientMessage(PID, -1, string);
	}
	return 1;
}

CMD:revokelicense(playerid, params[])
{
	new PID;
	new string[128];
	new param[144];
	if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
	if(PlayerInfo[playerid][pAdmin] < 6) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
	if(sscanf(params, "us[144]", PID, param))
	{
		SendClientMessage(playerid, COLOR_GREY, "[Usage:] /revokelicense [playerid/partofname] [param]");
		SendClientMessage(playerid, COLOR_GREY, "PARAMS: PF, BLS");
		SendClientMessage(playerid, COLOR_GREY, "TIP: If you want to give a license, use /issuelicense.");
	}
	if(!strcmp(param, "PF"))
	{
		PlayerInfo[playerid][pPF] = 0;
		format(string, sizeof(string), "You have revoked %s's PF license.", RPN(playerid));
		SendClientMessage(playerid, -1, string);
		format(string, sizeof(string), "%s has revoked your PF license.", RPN(playerid));
		SendClientMessage(PID, -1, string);
	}
	if(!strcmp(param, "BLS"))
	{
		PlayerInfo[playerid][pBLS] = 0;
		format(string, sizeof(string), "You have revoked %s's BLS license.", RPN(playerid));
		SendClientMessage(playerid, -1, string);
		format(string, sizeof(string), "%s has revoked your BLS license.", RPN(playerid));
		SendClientMessage(PID, -1, string);
	}
	return 1;
}
Ingame it gives me all the licenses at the same time rather than waiting for the parameter to be inputted.

Reply
#6

Why make something 144, when it can't take that much in the first instance?

Quote:
Originally Posted by WikiLimits
Text Input (Chat/Commands) 128 cells (512 bytes)
And DON'T just set it to 128...
Reply
#7

You have to return the usage code otherwise the code will keep executing till the end.
Reply
#8

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
Why make something 144, when it can't take that much in the first instance?




And DON'T just set it to 128...
I'm not here to get useless posts like this here, I'm here to improve my scripting ability. Acknowledge the fact that I stated I was a "decent" scripter. Doesn't mean I'm ****** or Zeex quality, or even indeed, your quality.

@iLearner I appreciate it, you've earnt my reputation. Going to test it out.
Reply
#9

Quote:
Originally Posted by xLucy
Посмотреть сообщение
I'm not here to get useless posts like this here, I'm here to improve my scripting ability. Acknowledge the fact that I stated I was a "decent" scripter. Doesn't mean I'm ****** or Zeex quality, or even indeed, your quality.
It's not useless, nor was it an attack on you... Why are you taking it so personally...

You're here to improve your scripting ability, yet the second someone says something about a choice you've made you deny it, and shun it...


Good job on showing that you're a hypocrite.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)