PDA

View Full Version : sscanf warning: Strings without a length are deprecated, please add a destination size.


YoDawg
22/07/2017, 10:20 AM
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.

jlalt
22/07/2017, 10:22 AM
You've forgot to define string size. simple add the size inside [ and ] after s.
ex:

s[50]



if(sscanf(params, "uds[50]", targetid, amount, reason))

Vince
22/07/2017, 10:22 AM
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)

YoDawg
22/07/2017, 10:32 AM
You've forgot to define string size. simple add the size inside [ and ] after s.
ex:

s[50]



if(sscanf(params, "uds[50]", targetid, amount, reason))

Yes. Strings without a length are deprecated. You must add a destination size.

sscanf(params, "uds[50]", targetid, amount, reason)


Thanks. Fixed the warning.