Help me with replacing old strings
#1

i just knew i was using old strings but i dont know how to replace them
here is one or two of what i use
pawn Код:
sscanf(line, "p<|>s[256]s[30]ds[64]s[64]dds[30]s[64]s[64]",
    ServerMOTD,ServerMOTDSetBy,ServerMaxPlayers,ServerMaxPlayersDate,ServerMaxPlayersTime,ServerTickets,ServerMaxFlightStreak,ServerMaxFlightStreakWinner,ServerMaxFlightStreakDate,ServerMaxFlightStreakTime);
    mysql_free_result();
    sTrackPlayers=1;
here is another one;
pawn Код:
public LoadStuff()
{
    new query[156];
    format(query,sizeof(query),"SELECT * FROM statistics");
    mysql_query(query);
    mysql_store_result();
    new line[1024];
    mysql_fetch_row(line);
    sscanf(line, "p<|>s[256]s[30]ds[64]s[64]dds[30]s[64]s[64]",
    ServerMOTD,ServerMOTDSetBy,ServerMaxPlayers,ServerMaxPlayersDate,ServerMaxPlayersTime,ServerTickets,ServerMaxFlightStreak,ServerMaxFlightStreakWinner,ServerMaxFlightStreakDate,ServerMaxFlightStreakTime);
    mysql_free_result();
    sTrackPlayers=1;
}
i think these old strings are giving me these warnings in server_log
Код:
SA-MP Dedicated Server
----------------------
v0.3x, ©2005-2013 SA-MP Team

[21:50:07] filterscripts = ""  (string)
[21:50:07] 
[21:50:07] Server Plugins
[21:50:07] --------------
[21:50:07]  Loading plugin: mysql
[21:50:07] 

  > MySQL plugin R5 successfully loaded.

[21:50:07]   Loaded.
[21:50:07]  Loading plugin: streamer
[21:50:07] 

*** Streamer Plugin v2.5 by Incognito loaded ***

[21:50:07]   Loaded.
[21:50:07]  Loading plugin: sscanf
[21:50:07] 

[21:50:07]  ===============================

[21:50:07]       sscanf plugin loaded.     

[21:50:07]          Version:  2.8.1        

[21:50:07]    © 2012 Alex "******" Cole  

[21:50:07]  ===============================

[21:50:07]   Loaded.
[21:50:07]  Loaded 3 plugins.

[21:50:08] 
[21:50:08] Filterscripts
[21:50:08] ---------------
[21:50:08]   Loaded 0 filterscripts.

[21:50:08] [MYSQL]: Connection to `Pilots Heaven` succesful!
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:50:08] Failed to load airline.
[21:50:08] ** 33	<->	Airline Vehicles loaded from	<->	MySQL		   **
[21:50:08] ** 109	<->	Vehicles loaded from	<->	MySQL		   **
[21:50:08] 
----------------------------------
[21:50:08]  Pilots Heaven | By Mehdi
[21:50:08] ----------------------------------

[21:50:08] Number of vehicle models: 118
[21:51:03] Incoming connection: 192.168.0.101:50854
[21:51:03] [join] Mehdi has joined the server (0:192.168.0.101)
[21:51:03] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:51:03] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:51:03] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:51:03] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:51:03] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:51:03] sscanf warning: Strings without a length are deprecated, please add a destination size.
[21:51:03] [part] Mehdi has left the server (0:2)
Ill be so happy if i can get this to work
Reply
#2

I doubt it's that code that you're showing. Look for s in sscanf where there's no length specified after it, example:

pawn Код:
sscanf(string, "ssddff");
This is the proper way:

pawn Код:
sscanf(string, "s[50]s[100]ddff");
Reply
#3

Yes that! after s i add [24] or so
but i dont know which number to add
i tryed this lots of time and i get buffer why?
here is one
pawn Код:
sscanf(query, "p<|>ssd", cUsername, wUsername, ncID);
                //format(szMessageString, sizeof(szMessageString), "\n");
                format(szMessageString, sizeof(szMessageString), "%s%d | %s (Wants: %s)\n", szMessageString, ncID, cUsername, wUsername);
            }
            if(tRows >= 12) { format(szMessageString,sizeof(szMessageString), "%sNext Page", szMessageString); }
            ShowPlayerDialog(playerid, namerequests1, DIALOG_STYLE_LIST, title, szMessageString, "Select", "Back");
            mysql_free_result();
            return 1;
        }
        else
        {
            mysql_free_result();
            SendClientMessage(playerid, COLOR_ERROR, "There are no active namechange requests!");
            return 1;
        }
}
i have to put [Number] after S but how do i know which number to add? so it dont buffer what do i count?
Reply
#4

You put the length of the variables. Lets say you declare cUsername like:

pawn Код:
new cUsername[133];
Then you put s[133]
Reply
#5

i still dont understand man
Reply
#6

Quote:
Originally Posted by Geeboi_Mehdi
Посмотреть сообщение
i still dont understand man
Example:
pawn Код:
printf("In line XXX s[%i]s[%i]d",sizeof(cUsername),sizeof(wUsername));
sscanf(query, "p<|>ssd", cUsername, wUsername, ncID);// line XXX
//In you log after call you will see the correct numbers
//and if you compare you will see the same number in " new cUsername[THIS NUMBERS]; "
Hope you understand now.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)