"Strings without a length are deprecated, please add a destination size"
#1

PHP код:
[22:46:40sscanf warningStrings without a length are deprecatedplease add a destination size.
[
22:46:40sscanf warningStrings without a length are deprecatedplease add a destination size.
[
22:46:51sscanf warningStrings without a length are deprecatedplease add a destination size.
[
22:46:51sscanf warningStrings without a length are deprecatedplease add a destination size.
[
22:46:51sscanf warningString buffer overflow
They started to come out since I made my duel system:

PHP код:
CMD:duel(playeridparams[])
{
    new 
invitedidWeapon1[50], Weapon2[50], iString[180];
     if(
sscanf(params"iss"invitedidWeapon1Weapon2)) return SendClientMessage(playerid,-1"{ff8080}Syntax: /duel (nickname) (weapon 1) (weapon 2)");
    if(!
IsPlayerConnected(invitedid)) return 1;
    if(
Player[invitedid][challengerid] == playerid) return SendClientMessage(playerid,-1"{ff8080}(duel) You are already awaiting a duel");    //duelspamfix
    
if(invitedid == playerid) return 1;
    if(
Player[invitedid][InDuel] == true) return SendClientMessage(playerid,-1"{ff8080}(duel) That player is already dueling someone.");
    if(
Player[playerid][InDuel] == true) return SendClientMessage(playerid,-1"{ff8080}(duel) You are already dueling someone.");
    
    new 
WeaponID1 GetWeaponID(Weapon1);
    if(
WeaponID1 || WeaponID1 46 || WeaponID1 == 19 || WeaponID1 == 20 || WeaponID1 == 21) return SendClientMessage(playerid,-1"Invalid Weapon Name.");
    if(
WeaponID1 == 40 || WeaponID1 == 43 || WeaponID1 == 44 || WeaponID1 == 45) return SendClientMessage(playerid,-1"That weapon is not allowed in duels.");
    new 
WeaponID2 GetWeaponID(Weapon2);
    if(
WeaponID2 || WeaponID2 46 || WeaponID2 == 19 || WeaponID2 == 20 || WeaponID2 == 21) return SendClientMessage(playerid,-1"Invalid Weapon Name.");
    if(
WeaponID2 == 40 || WeaponID2 == 43 || WeaponID2 == 44 || WeaponID2 == 45) return SendClientMessage(playerid,-1"That weapon is not allowed in duels.");
    
Player[invitedid][challengerid] = playerid;
    
Player[invitedid][duelweap1] = WeaponID1;
    
Player[invitedid][duelweap2] = WeaponID2;
    
    
format(iStringsizeof(iString), "{ff8080}(duel) Your duel request was sent to %s with '%s' and '%s'"PlayerName[invitedid], WeaponNames[WeaponID1], WeaponNames[WeaponID2]);
    
SendClientMessage(playerid, -1iString);
    
format(iStringsizeof(iString), "{ff8080}(duel) %s wants a duel with you - weapons: '%s' and '%s'"PlayerName[playerid], WeaponNames[WeaponID1], WeaponNames[WeaponID2]);
    
SendClientMessage(invitedid, -1iString);
    
    
SendClientMessage(invitedid, -1"{ff8080}(duel) Use /accept to stat the duel, or /decline (costs: 10 exp - reward 20 exp!)");
    
    
PlayerPlaySound(invitedid,1137,0.0,0.0,0.0);
    return 
1;

Is there anything wrong?
Reply
#2

You have to declare string sizes for the sscanf specifier.

PHP код:
CMD:duel(playeridparams[])
{
    new 
invitedidWeapon1[50], Weapon2[50], iString[180];
     if(
sscanf(params"is[50]s[50]"invitedidWeapon1Weapon2)) return SendClientMessage(playerid,-1"{ff8080}Syntax: /duel (nickname) (weapon 1) (weapon 2)");
    if(!
IsPlayerConnected(invitedid)) return 1;
    if(
Player[invitedid][challengerid] == playerid) return SendClientMessage(playerid,-1"{ff8080}(duel) You are already awaiting a duel");    //duelspamfix
    
if(invitedid == playerid) return 1;
    if(
Player[invitedid][InDuel] == true) return SendClientMessage(playerid,-1"{ff8080}(duel) That player is already dueling someone.");
    if(
Player[playerid][InDuel] == true) return SendClientMessage(playerid,-1"{ff8080}(duel) You are already dueling someone.");
    
    new 
WeaponID1 GetWeaponID(Weapon1);
    if(
WeaponID1 || WeaponID1 46 || WeaponID1 == 19 || WeaponID1 == 20 || WeaponID1 == 21) return SendClientMessage(playerid,-1"Invalid Weapon Name.");
    if(
WeaponID1 == 40 || WeaponID1 == 43 || WeaponID1 == 44 || WeaponID1 == 45) return SendClientMessage(playerid,-1"That weapon is not allowed in duels.");
    new 
WeaponID2 GetWeaponID(Weapon2);
    if(
WeaponID2 || WeaponID2 46 || WeaponID2 == 19 || WeaponID2 == 20 || WeaponID2 == 21) return SendClientMessage(playerid,-1"Invalid Weapon Name.");
    if(
WeaponID2 == 40 || WeaponID2 == 43 || WeaponID2 == 44 || WeaponID2 == 45) return SendClientMessage(playerid,-1"That weapon is not allowed in duels.");
    
Player[invitedid][challengerid] = playerid;
    
Player[invitedid][duelweap1] = WeaponID1;
    
Player[invitedid][duelweap2] = WeaponID2;
    
    
format(iStringsizeof(iString), "{ff8080}(duel) Your duel request was sent to %s with '%s' and '%s'"PlayerName[invitedid], WeaponNames[WeaponID1], WeaponNames[WeaponID2]);
    
SendClientMessage(playerid, -1iString);
    
format(iStringsizeof(iString), "{ff8080}(duel) %s wants a duel with you - weapons: '%s' and '%s'"PlayerName[playerid], WeaponNames[WeaponID1], WeaponNames[WeaponID2]);
    
SendClientMessage(invitedid, -1iString);
    
    
SendClientMessage(invitedid, -1"{ff8080}(duel) Use /accept to stat the duel, or /decline (costs: 10 exp - reward 20 exp!)");
    
    
PlayerPlaySound(invitedid,1137,0.0,0.0,0.0);
    return 
1;

Reply
#3

You'll need string here

Код:
 if(sscanf(params, "is[HERE]s[HERE]", invitedid, Weapon1, Weapon2))
Reply
#4

Oh well, sorry, didn't pay attention, I hope this fix. Thanks !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)