24.06.2012, 12:58
I got problem, sscanf get problem
Maybe this?
Or all system:
Please help
Quote:
[15:05:30] sscanf warning: Strings without a length are deprecated, please add a destination size. [15:05:30] sscanf warning: Strings without a length are deprecated, please add a destination size. [15:05:32] sscanf warning: Strings without a length are deprecated, please add a destination size. [15:05:32] sscanf warning: Strings without a length are deprecated, please add a destination size. [15:05:36] sscanf warning: Strings without a length are deprecated, please add a destination size. [15:05:36] sscanf warning: Strings without a length are deprecated, please add a destination size. |
Код:
new String[150]; if(dialogid == DIALOG_LOGIN) { if(response) { new File:File = fopen(Player[playerid][PlayerFile],io_read); fread(File,String); sscanf(String,"s s i i i i i i i i i i i i i",Player[playerid][PlayerPassword],Player[playerid][PlayerDateOfRegister],Player[playerid][PlayerVisits],Player[playerid][PlayerMoney],Player[playerid][PlayerRespect],Player[playerid][PlayerLevel],Player[playerid][PlayerRespectToNextLevel],Player[playerid][PlayerSuicides],Player[playerid][PlayerDeaths],Player[playerid][PlayerKills],Player[playerid][PlayerSendMessages],Player[playerid][PlayerSendCommands], Player[playerid][PlayerAdministratorLevel],Player[playerid][PlayerModerator],Player[playerid][PlayerVip]); fclose(File); if(isnull(inputtext) || strcmp(inputtext,Player[playerid][PlayerPassword])) { SendClientMessage(playerid,0,""RED">> Podałeś nieprawidłowe hasło."); ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Logowanie","Wpisz poniżej hasło do konta ktуre podałeś podczas rejestacji.","Ok","Anuluj"); return 1; } Server[ServerVisits] += 1; Player[playerid][PlayerLoggedIn] = 1; Player[playerid][PlayerVisits] += 1; SendClientMessage(playerid,0,""GREEN">> Zalogowałeś się pomyślnie."); } if(!response) { format(String,150,""RED">> Gracz "DARK_RED"%s (%d) "RED"został wyrzucony z serwera. Powуd: Anulowanie logowania.",Player[playerid][PlayerName],playerid); SendClientMessageToAll(0,String); Kick(playerid); } }
Код:
#include <a_samp> #include <sscanf2> #include <zcmd> #define SLOTS 30 #define DIALOG_LOGIN 0 #define DIALOG_REGISTER 1 #define RED "{FF0000}" #define DARK_RED "{BB0000}" #define GREEN "{00FF00}" #define DARK_GREEN "{00BB00}" #define AQUA "{00FFFF}" #define DARK_AQUA "{00BBBB}" enum ServerMain { ServerVisits, ServerPlayersRecord, ServerPlayersRegistered, ServerSuicides, ServerDeaths, ServerKills, ServerSendMessages, ServerSendCommands, ServerAdministrators, ServerModerators, ServerVips, ServerPlayers } new Server[ServerMain]; enum PlayerMain { PlayerName[24], PlayerIp[16], PlayerFile[28], PlayerPassword[20], PlayerDateOfRegister[10], PlayerLoggedIn, PlayerVisits, PlayerMoney, PlayerRespect, PlayerLevel, PlayerRespectToNextLevel, PlayerSuicides, PlayerDeaths, PlayerKills, PlayerSendMessages, PlayerSendCommands, PlayerAdministratorLevel, PlayerModerator, PlayerVip } new Player[SLOTS][PlayerMain]; main(){} public OnGameModeInit() { new String[150]; SetTimer("GlobalFunctions",1000,1); new File:File = fopen("Settings.ini",io_read); fread(File,String); sscanf(String,"i i i i i i i i",Server[ServerVisits],Server[ServerPlayersRecord],Server[ServerPlayersRegistered],Server[ServerSuicides],Server[ServerDeaths],Server[ServerKills],Server[ServerSendMessages],Server[ServerSendCommands]); fclose(File); return 1; } public OnGameModeExit() { new String[150]; fremove("Settings.ini"); new File:File = fopen("Settings.ini",io_write); format(String,150,"%i %i %i %i %i %i %i %i",Server[ServerVisits],Server[ServerPlayersRecord],Server[ServerPlayersRegistered],Server[ServerSuicides],Server[ServerDeaths],Server[ServerKills],Server[ServerSendMessages],Server[ServerSendCommands]); fwrite(File,String); fclose(File); return 1; } public OnPlayerConnect(playerid) { Server[ServerPlayers] += 1; GetPlayerName(playerid,Player[playerid][PlayerName],24); GetPlayerIp(playerid,Player[playerid][PlayerIp],16); format(Player[playerid][PlayerFile],28,"Players/%s.ini",Player[playerid][PlayerName]); format(Player[playerid][PlayerPassword],20," "); format(Player[playerid][PlayerDateOfRegister],10," "); Player[playerid][PlayerLoggedIn] = 0; Player[playerid][PlayerVisits] = 0; Player[playerid][PlayerMoney] = 0; Player[playerid][PlayerRespect] = 0; Player[playerid][PlayerLevel] = 0; Player[playerid][PlayerRespectToNextLevel] = 0; Player[playerid][PlayerSuicides] = 0; Player[playerid][PlayerDeaths] = 0; Player[playerid][PlayerKills] = 0; Player[playerid][PlayerSendMessages] = 0; Player[playerid][PlayerSendCommands] = 0; Player[playerid][PlayerAdministratorLevel] = 0; Player[playerid][PlayerModerator] = 0; Player[playerid][PlayerVip] = 0; if(fexist(Player[playerid][PlayerFile])) ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Logowanie","Wpisz poniżej hasło do konta ktуre podałeś podczas rejestacji.","Ok","Anuluj"); if(!fexist(Player[playerid][PlayerFile])) ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_PASSWORD,"Rejestracja","Wpisz poniżej hasło do konta ktуrego bdziesz używał podczas logowania.","Ok","Anuluj"); return 1; } public OnPlayerDisconnect(playerid,reason) { new String[150]; Server[ServerPlayers] -= 1; if(Player[playerid][PlayerLoggedIn] == 1) { if(fexist(Player[playerid][PlayerFile])) fremove(Player[playerid][PlayerFile]); new File:File = fopen(Player[playerid][PlayerFile],io_write); format(String,150,"%s %s %i %i %i %i %i %i %i %i %i %i %i %i %i",Player[playerid][PlayerPassword],Player[playerid][PlayerDateOfRegister],Player[playerid][PlayerVisits],Player[playerid][PlayerMoney],Player[playerid][PlayerRespect],Player[playerid][PlayerLevel],Player[playerid][PlayerRespectToNextLevel],Player[playerid][PlayerSuicides],Player[playerid][PlayerDeaths],Player[playerid][PlayerKills],Player[playerid][PlayerSendMessages],Player[playerid][PlayerSendCommands], Player[playerid][PlayerAdministratorLevel],Player[playerid][PlayerModerator],Player[playerid][PlayerVip]); fwrite(File,String); fclose(File); } return 1; } public OnPlayerDeath(playerid,killerid,reason) { new String[150]; if(IsPlayerConnected(killerid)) { Server[ServerDeaths] += 1; Player[playerid][PlayerMoney] -= 1000; Player[playerid][PlayerRespect] -= 1; Player[playerid][PlayerDeaths] += 1; GameTextForPlayer(playerid,"~B~~H~~H~~H~Respekt ~G~~H~~H~-1",3000,1); format(String,150,""RED">> Zostałeś zabity przez "DARK_RED"%s (%d)"RED", tracisz 1000 pieniędzy i 1 respektu.",Player[killerid][PlayerName],killerid); SendClientMessage(playerid,0,String); Server[ServerKills] += 1; Player[killerid][PlayerMoney] += 10000; Player[killerid][PlayerRespect] += 10; Player[killerid][PlayerKills] += 1; GameTextForPlayer(killerid,"~B~~H~~H~~H~Respekt ~G~~H~~H~+10",3000,1); format(String,150,""GREEN">> Zabiłeś gracza "DARK_GREEN"%s (%d)"GREEN", otrzymujesz 10000 pieniedzy i 10 respektu.",Player[playerid][PlayerName],playerid); SendClientMessage(killerid,0,String); } if(!IsPlayerConnected(killerid)) { Server[ServerSuicides] += 1; Player[playerid][PlayerMoney] -= 1000; Player[playerid][PlayerRespect] -= 1; Player[playerid][PlayerSuicides] += 1; GameTextForPlayer(playerid,"~B~~H~~H~~H~Respekt ~G~~H~~H~-1",3000,1); SendClientMessage(playerid,0,""RED">> Popełniłeś samobуjstwo, tracisz 1000 pienidzy i 1 respektu."); } return 1; } public OnPlayerText(playerid,text[]) { new String[150]; if(Player[playerid][PlayerLoggedIn] == 0) return 0; Server[ServerSendMessages] += 1; Player[playerid][PlayerSendMessages] += 1; format(String,150,"(ID %d): %s",playerid,text); if(Player[playerid][PlayerAdministratorLevel] > 0) format(String,150,"(Administrator ID %d): %s",playerid,text); if(Player[playerid][PlayerModerator] == 1) format(String,150,"(Moderator ID %d): %s",playerid,text); if(Player[playerid][PlayerVip] == 1) format(String,150,"(Vip ID %d): %s",playerid,text); SendPlayerMessageToAll(playerid,String); return 0; } public OnPlayerCommandPerformed(playerid,cmdtext[],success) { if(success) { Server[ServerSendCommands] += 1; Player[playerid][PlayerSendCommands] += 1; return 1; } if(!success) { SendClientMessage(playerid,0,""RED">> Komenda ktуrą wpisałeś nie istnieje, wpisz /Pomoc aby uzyskać pomoc na temat gry na serwerze."); return 0; } return 1; } public OnDialogResponse(playerid,dialogid,response,listitem,inputtext[]) { new String[150]; if(dialogid == DIALOG_LOGIN) { if(response) { new File:File = fopen(Player[playerid][PlayerFile],io_read); fread(File,String); sscanf(String,"s s i i i i i i i i i i i i i",Player[playerid][PlayerPassword],Player[playerid][PlayerDateOfRegister],Player[playerid][PlayerVisits],Player[playerid][PlayerMoney],Player[playerid][PlayerRespect],Player[playerid][PlayerLevel],Player[playerid][PlayerRespectToNextLevel],Player[playerid][PlayerSuicides],Player[playerid][PlayerDeaths],Player[playerid][PlayerKills],Player[playerid][PlayerSendMessages],Player[playerid][PlayerSendCommands], Player[playerid][PlayerAdministratorLevel],Player[playerid][PlayerModerator],Player[playerid][PlayerVip]); fclose(File); if(isnull(inputtext) || strcmp(inputtext,Player[playerid][PlayerPassword])) { SendClientMessage(playerid,0,""RED">> Podałeś nieprawidłowe hasło."); ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Logowanie","Wpisz poniżej hasło do konta ktуre podałeś podczas rejestacji.","Ok","Anuluj"); return 1; } Server[ServerVisits] += 1; Player[playerid][PlayerLoggedIn] = 1; Player[playerid][PlayerVisits] += 1; SendClientMessage(playerid,0,""GREEN">> Zalogowałeś się pomyślnie."); } if(!response) { format(String,150,""RED">> Gracz "DARK_RED"%s (%d) "RED"został wyrzucony z serwera. Powуd: Anulowanie logowania.",Player[playerid][PlayerName],playerid); SendClientMessageToAll(0,String); Kick(playerid); } } if(dialogid == DIALOG_REGISTER) { if(response) { if(strlen(inputtext) < 5 || strlen(inputtext) > 20) { SendClientMessage(playerid,0,""RED">> Twoje hasło nie jest prawidłowe, musi mieć minimum 5 znakуw, maksymalnie 20."); ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_PASSWORD,"Rejestracja","Wpisz poniżej hasło do konta ktуrego bdziesz używał podczas logowania.","Ok","Anuluj"); return 1; } Server[ServerVisits] += 1; Server[ServerPlayersRegistered] += 1; format(Player[playerid][PlayerPassword],20,"%s",inputtext); new Year,Month,Day; getdate(Year,Month,Day); format(Player[playerid][PlayerDateOfRegister],10,"%02d/%02d/%d",Day,Month,Year); Player[playerid][PlayerLoggedIn] = 1; Player[playerid][PlayerVisits] += 1; Player[playerid][PlayerMoney] += 50000; Player[playerid][PlayerRespectToNextLevel] = 100; format(String,150,""AQUA">> Gracz "DARK_AQUA"%s (%d) "AQUA"zarejestrował swoje konto, mamy już "DARK_AQUA"%d "AQUA"zarejestrowanych graczy.",Player[playerid][PlayerName],playerid,Server[ServerPlayersRegistered]); SendClientMessageToAll(0,String); format(String,150,""GREEN">> Zarejestrowałeś swoje konto, twoje hasło to "DARK_GREEN"%s"GREEN".",inputtext); SendClientMessage(playerid,0,String); } if(!response) { format(String,150,""RED">> Gracz "DARK_RED"%s (%d) "RED"został wyrzucony z serwera. Powуd: Anulowanie rejestracji.",Player[playerid][PlayerName],playerid); SendClientMessageToAll(0,String); Kick(playerid); } } return 1; } forward GlobalFunctions(); public GlobalFunctions() { for(new I,A = SLOTS; I < A; I++) { if(IsPlayerConnected(I)) { if(GetPlayerMoney(I) > Player[I][PlayerMoney] || GetPlayerMoney(I) < Player[I][PlayerMoney]) { ResetPlayerMoney(I); GivePlayerMoney(I,Player[I][PlayerMoney]); } if(GetPlayerScore(I) > Player[I][PlayerRespect] || GetPlayerScore(I) < Player[I][PlayerRespect]) SetPlayerScore(I,Player[I][PlayerRespect]); if(Player[I][PlayerRespect] > Player[I][PlayerRespectToNextLevel]) { Player[I][PlayerLevel] += 1; Player[I][PlayerRespectToNextLevel] = Player[I][PlayerRespectToNextLevel] + 100; GameTextForPlayer(I,"~B~~H~~H~~H~Nastepny ~G~~H~~H~Poziom!",3000,1); } } } return 1; }