hlmod.hu
https://hlmod.hu/

Mysql mentés.
https://hlmod.hu/viewtopic.php?f=9&t=21546
Oldal: 1 / 1

Szerző:  Zeu|Sz [2015.07.17. 12:44 ]
Hozzászólás témája:  Mysql mentés.

Helló.Ezt valaki javítaná?

SMA Forráskód: [ Mindet kijelol ]
  1. public Save(id)
  2. {
  3. new szNev[32], szTemp[512]
  4. get_user_name(id, szNev, charsmax(szNev))
  5.  
  6. format(szTemp,charsmax(szTemp),"UPDATE `Save` SET `ARANY` = '%i',\
  7. `Oles` = '%i',\
  8. `Szint` = '%i',\
  9. `Fegyver1` = '%i',\
  10. `Fegyver2` = '%i',\
  11. `Fegyver3` = '%i',\
  12. `Fegyver4` = '%i',\
  13. `Fegyver5` = '%i',\
  14. `Fegyver6` = '%i',\
  15. `Fegyver7` = '%i',\
  16. `Fegyver8` = '%i',\
  17. `Fegyver9` = '%i',\
  18. `Fegyver10` = '%i',\
  19. `Fegyver11` = '%i',\
  20. `Fegyver12` = '%i',\
  21. `Fegyver13` = '%i',\
  22. `Fegyver14` = '%i',\
  23. `Fegyver15` = '%i',\
  24. `Fegyver16` = '%i',\
  25. `Fegyver17` = '%i'\
  26. WHERE `Save`.`nev` = '%s';", Gold[id], Kill[id], GoSkins[0][id], GoSkins[1][id], GoSkins[2][id], GoSkins[3][id], GoSkins[4][id], GoSkins[5][id], GoSkins[6][id], GoSkins[7][id], GoSkins[8][id], GoSkins[9][id], GoSkins[10][id], GoSkins[11][id], GoSkins[12][id], GoSkins[13][id], GoSkins[14][id], GoSkins[15][id], GoSkins[16][id], szNev)
  27. SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szTemp)
  28. }

Szerző:  kiki [2015.07.17. 13:41 ]
Hozzászólás témája:  Re: Myql mentés.

Mi a baj vele?

Szerző:  Zeu|Sz [2015.07.17. 14:46 ]
Hozzászólás témája:  Re: Myql mentés.

Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2013 ITB CompuPhase, AMX Mod X Team

Warning: Loose indentation on line 236
Error: Input line too long (after substitutions) on line 350

1 Error.
Could not locate output file D:\Scripting\globaloffensive.amx (compile failed).

Szerző:  kiki [2015.07.17. 14:53 ]
Hozzászólás témája:  Re: Myql mentés.

szTemp[512]

->

szTemp[1024]

s próbáld meg lefordítani.

Szerző:  Zeu|Sz [2015.07.17. 15:26 ]
Hozzászólás témája:  Re: Myql mentés.

Nem jó.

Teljes mentés:

SMA Forráskód: [ Mindet kijelol ]
  1. new Handle:g_SqlTuple
  2. new g_Error[512]
  3.  
  4. new Host[] = "localhost"
  5. new User[] = "root"
  6. new Pass[] = "jelszo"
  7. new Db[] = "adatbazis"
  8.  
  9. set_task(1.0, "MySql_Init")
  10.  
  11. public MySql_Init()
  12. {
  13. g_SqlTuple = SQL_MakeDbTuple(Host,User,Pass,Db)
  14. new ErrorCode,Handle:SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,charsmax(g_Error))
  15. if(SqlConnection == Empty_Handle)
  16. set_fail_state(g_Error)
  17. new Handle:Queries
  18. Queries = SQL_PrepareQuery(SqlConnection,"CREATE TABLE IF NOT EXISTS Save (nev varchar(32),\
  19. ARANY INT(11),\
  20. Oles INT(11)),\
  21. Szint INT(11)),\
  22. Fegyver1 INT(11)),\
  23. Fegyver2 INT(11)),\
  24. Fegyver3 INT(11)),\
  25. Fegyver4 INT(11)),\
  26. Fegyver5 INT(11)),\
  27. Fegyver6 INT(11)),\
  28. Fegyver7 INT(11)),\
  29. Fegyver8 INT(11)),\
  30. Fegyver9 INT(11)),\
  31. Fegyver10 INT(11)),\
  32. Fegyver11 INT(11)),\
  33. Fegyver12 INT(11)),\
  34. Fegyver13 INT(11)),\
  35. Fegyver14 INT(11)),\
  36. Fegyver15 INT(11)),\
  37. Fegyver16 INT(11)),\
  38. Fegyver17 INT(11))")
  39.  
  40. if(!SQL_Execute(Queries))
  41. {
  42. SQL_QueryError(Queries,g_Error,charsmax(g_Error))
  43. set_fail_state(g_Error)
  44. }
  45. SQL_FreeHandle(Queries)
  46. SQL_FreeHandle(SqlConnection)
  47. }
  48. public Load(id)
  49. {
  50. new szNev[32], szTemp[512]
  51. get_user_name(id, szNev, charsmax(szNev))
  52.  
  53. new Data[1]
  54. Data[0] = id
  55. format(szTemp,charsmax(szTemp),"SELECT * FROM `ProbaMentes` WHERE (`Save`.`nev` = '%s')", szNev)
  56. SQL_ThreadQuery(g_SqlTuple,"register_client",szTemp,Data,1)
  57. }
  58. public register_client(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
  59. {
  60. if(FailState == TQUERY_CONNECT_FAILED)
  61. {
  62. log_amx("Kapcsolodas sikertelen. [%d] %s", Errcode, Error)
  63. }
  64. else if(FailState == TQUERY_QUERY_FAILED)
  65. {
  66. log_amx("A QUERY betoltese sikertelen.[%d] %s", Errcode, Error)
  67. }
  68.  
  69. new id
  70. id = Data[0]
  71.  
  72. if(SQL_NumResults(Query) < 1)
  73. {
  74.  
  75. new szNev[32]
  76. get_user_name(id, szNev, charsmax(szNev))
  77.  
  78. new szTemp[512]
  79.  
  80. format(szTemp,charsmax(szTemp),"INSERT INTO `Save` ( `nev` ,\
  81. `ARANY`,\
  82. `Oles`,\
  83. `Szint`,\
  84. `Fegyver1`,\
  85. `Fegyver2`,\
  86. `Fegyver3`,\
  87. `Fegyver4`,\
  88. `Fegyver5`,\
  89. `Fegyver6`,\
  90. `Fegyver7`,\
  91. `Fegyver8`,\
  92. `Fegyver9`,\
  93. `Fegyver10`,\
  94. `Fegyver11`,\
  95. `Fegyver12`,\
  96. `Fegyver13`,\
  97. `Fegyver14`,\
  98. `Fegyver15`,\
  99. `Fegyver16`,\
  100. `Fegyver17`)VALUES ('%s','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');",szNev)
  101. SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szTemp)
  102. }
  103. else
  104. {
  105. Gold[id] = SQL_ReadResult(Query, 1)
  106. Kill[id] = SQL_ReadResult(Query, 2)
  107. Rang[id] = SQL_ReadResult(Query, 3)
  108. GoSkins[0][id] = SQL_ReadResult(Query, 4)
  109. GoSkins[1][id] = SQL_ReadResult(Query, 5)
  110. GoSkins[2][id] = SQL_ReadResult(Query, 6)
  111. GoSkins[3][id] = SQL_ReadResult(Query, 7)
  112. GoSkins[4][id] = SQL_ReadResult(Query, 8)
  113. GoSkins[5][id] = SQL_ReadResult(Query, 9)
  114. GoSkins[6][id] = SQL_ReadResult(Query, 10)
  115. GoSkins[7][id] = SQL_ReadResult(Query, 11)
  116. GoSkins[8][id] = SQL_ReadResult(Query, 12)
  117. GoSkins[9][id] = SQL_ReadResult(Query, 13)
  118. GoSkins[10][id] = SQL_ReadResult(Query, 14)
  119. GoSkins[11][id] = SQL_ReadResult(Query, 15)
  120. GoSkins[12][id] = SQL_ReadResult(Query, 16)
  121. GoSkins[13][id] = SQL_ReadResult(Query, 17)
  122. GoSkins[14][id] = SQL_ReadResult(Query, 18)
  123. GoSkins[15][id] = SQL_ReadResult(Query, 19)
  124. GoSkins[16][id] = SQL_ReadResult(Query, 20)
  125. }
  126. return PLUGIN_HANDLED
  127. }
  128. public Save(id)
  129. {
  130. new szNev[32], szTemp[1024]
  131. get_user_name(id, szNev, charsmax(szNev))
  132.  
  133. format(szTemp,charsmax(szTemp),"UPDATE `Save` SET `ARANY` = '%i',\
  134. `Oles` = '%i',\
  135. `Szint` = '%i',\
  136. `Fegyver1` = '%i',\
  137. `Fegyver2` = '%i',\
  138. `Fegyver3` = '%i',\
  139. `Fegyver4` = '%i',\
  140. `Fegyver5` = '%i',\
  141. `Fegyver6` = '%i',\
  142. `Fegyver7` = '%i',\
  143. `Fegyver8` = '%i',\
  144. `Fegyver9` = '%i',\
  145. `Fegyver10` = '%i',\
  146. `Fegyver11` = '%i',\
  147. `Fegyver12` = '%i',\
  148. `Fegyver13` = '%i',\
  149. `Fegyver14` = '%i',\
  150. `Fegyver15` = '%i',\
  151. `Fegyver16` = '%i',\
  152. `Fegyver17` = '%i'\
  153. WHERE `Save`.`nev` = '%s';", Gold[id], Kill[id], GoSkins[0][id], GoSkins[1][id], GoSkins[2][id], GoSkins[3][id], GoSkins[4][id], GoSkins[5][id], GoSkins[6][id], GoSkins[7][id], GoSkins[8][id], GoSkins[9][id], GoSkins[10][id], GoSkins[11][id], GoSkins[12][id], GoSkins[13][id], GoSkins[14][id], GoSkins[15][id], GoSkins[16][id], szNev)
  154. SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szTemp)
  155. }
  156. public IgnoreHandle(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
  157. {
  158. SQL_FreeHandle(Query)
  159. return PLUGIN_HANDLED
  160. }
  161. public plugin_end()
  162. {
  163. SQL_FreeHandle(g_SqlTuple)
  164. }

Szerző:  CrB [2015.07.17. 16:12 ]
Hozzászólás témája:  Re: Myql mentés.

írd át úgy az updatet mint az insert into nál van.

Szerző:  kiki [2015.07.17. 16:46 ]
Hozzászólás témája:  Re: Myql mentés.

WHERE `Save`.`nev`

helyett is elég szerintem a

WHERE `nev`

Szerző:  Zeu|Sz [2015.07.17. 16:50 ]
Hozzászólás témája:  Re: Myql mentés.

Így sem jó.Ezzel van valami baja:
SMA Forráskód: [ Mindet kijelol ]
  1. get_user_name(id, szNev, charsmax(szNev))

Oldal: 1 / 1 Minden időpont UTC+02:00 időzóna szerinti
Powered by phpBB® Forum Software © phpBB Limited
https://www.phpbb.com/