sscanf warning: Strings without a length are deprecated, please add a destination size.
#1

Код:
COMMAND:ticket(playerid, params[])
{
	new targetid,string[128], amount, reason[50];
	if(sscanf(params, "uds", targetid, amount, reason)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /ticket [playerid] [amount] [reason]");
    if (GetPVarInt(playerid, "PlayerLogged") == 0) return SendClientMessage(playerid, COLOR_WHITE, "You must be logged in to use this.");
	//if (playerid == targetid) return SendClientMessage(playerid, COLOR_GREY, "You cannot ticket yourself.");
    if (!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_WHITE, "This player is not connected!");
	if(GetPVarInt(playerid, "Member") != 1) return nal(playerid);
	new Float:X, Float:Y, Float:Z;
	GetPlayerPos(playerid, X, Y, Z);
	if(!IsPlayerInRangeOfPoint(targetid, 10.0, X, Y, Z)) return error(playerid, "This player is not nearby you.");
	if(amount < 25 || amount > 2000) return SendClientMessage(playerid, COLOR_GREY, "Cannot go under 25 or above 2000.");
	new query[516], year, month, day, hour, minute, second;
	getdate(year, month, day);
	gettime(hour,minute,second);
	new datum[64], timel[64];
	format(timel, sizeof(timel), "%d:%d:%d", hour, minute, second);
 	format(datum, sizeof(datum), "%d-%d-%d", year, month, day);
	format(query, sizeof(query), "INSERT INTO `tickets`(`player`, `officer`, `time`, `date`, `amount`, `reason`) VALUES ('%s','%s','%s','%s',%d,'%s')",
    PlayerName(targetid), PlayerName(playerid),
	timel,datum, amount,reason);
	mysql_tquery(handlesql, query);
	format(string, sizeof(string), "* %s writes a ticket of $%d to %s", PlayerName(playerid), amount, PlayerName(targetid));
	ProxDetector(30.0, playerid, string, COLOR_PURPLE);
	return 1;
}
Is there something wrong with this code here?;

Код:
if(sscanf(params, "uds", targetid, amount, reason))
Help would be appreciated thank you.
Reply
#2

You've forgot to define string size. simple add the size inside [ and ] after s.
ex:
PHP код:
s[50
PHP код:
if(sscanf(params"uds[50]"targetidamountreason)) 
Reply
#3

Quote:
Originally Posted by YoDawg
Посмотреть сообщение
Is there something wrong with this code here?;
Yes. Strings without a length are deprecated. You must add a destination size.

Код:
sscanf(params, "uds[50]", targetid, amount, reason)
Reply
#4

Quote:
Originally Posted by jlalt
Посмотреть сообщение
You've forgot to define string size. simple add the size inside [ and ] after s.
ex:
PHP код:
s[50
PHP код:
if(sscanf(params"uds[50]"targetidamountreason)) 
Quote:
Originally Posted by Vince
Посмотреть сообщение
Yes. Strings without a length are deprecated. You must add a destination size.

Код:
sscanf(params, "uds[50]", targetid, amount, reason)
Thanks. Fixed the warning.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)