hlmod.hu

Magyar Half-Life Mód közösség!
Pontos idő: 2024.04.27. 13:15



Jelenlévő felhasználók

Jelenleg 542 felhasználó van jelen :: 1 regisztrált, 0 rejtett és 541 vendég

A legtöbb felhasználó (1565 fő) 2020.11.21. 11:26-kor tartózkodott itt.

Regisztrált felhasználók: siska15 az elmúlt 5 percben aktív felhasználók alapján

Utoljára aktív
Ahhoz hogy lásd ki volt utoljára aktív, be kell jelentkezned.



Az oldal teljeskörű
használatához regisztrálj.

Regisztráció

Kereső


Új téma nyitása  Hozzászólás a témához  [ 23 hozzászólás ]  Oldal 1 2 3 Következő
Szerző Üzenet
 Hozzászólás témája: ZP Bank
HozzászólásElküldve: 2013.03.30. 18:13 
Offline
Félisten

Csatlakozott: 2012.06.19. 15:12
Hozzászólások: 926
Megköszönt másnak: 109 alkalommal
Megköszönték neki: 31 alkalommal
Valki zombi plague 4.3-ra tudna lineklni egy olyan bankot amiböl nem tünik el az ammó és aútómatikusan menti és ha feljön kiveszi magátol.

_________________
Kép


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: ZP Bank
HozzászólásElküldve: 2013.03.30. 18:31 
Offline
Őskövület
Avatar

Csatlakozott: 2011.12.28. 00:35
Hozzászólások: 2736
Megköszönt másnak: 56 alkalommal
Megköszönték neki: 275 alkalommal
Tomos írta:
Valki zombi plague 4.3-ra tudna lineklni egy olyan bankot amiböl nem tünik el az ammó és aútómatikusan menti és ha feljön kiveszi magátol.


Próbáld SQL-el menteni:
SMA Forráskód: [ Mindet kijelol ]
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <zombieplague>
  4.  
  5. //#define USING_SQL
  6. #if defined USING_SQL
  7. #include <sqlx>
  8. #else
  9. #include <nvault>
  10. #endif
  11.  
  12. stock const ZP_BANK_FMT[] = "^x04[ZP-BANK]^x01 %L"
  13.  
  14. new g_iAmmoPacks[33]
  15. new g_iSessionMovement[33]
  16. new g_szAuth[33][36]
  17. new cvAnnounceTime
  18. new cvBankMax
  19.  
  20. #if defined USING_SQL
  21. new g_szSQLTable[64], Handle:g_hSQLTuple, g_szQuery[128]
  22.  
  23. LoadClient(id, szAuth[])
  24. {
  25. formatex(g_szQuery, charsmax(g_szQuery),
  26. "SELECT amount FROM `%s` WHERE auth='%s'",
  27. g_szSQLTable, szAuth)
  28.  
  29. new cData[37]
  30. cData[0] = id
  31. copy(cData[1], charsmax(cData)-1, szAuth)
  32.  
  33. SQL_ThreadQuery(g_hSQLTuple, "LoadClient_QueryHandler", g_szQuery, cData, strlen(cData[1]))
  34. }
  35.  
  36. public LoadClient_QueryHandler(iFailState, Handle:hQuery, szError[], iErrnum, cData[], iSize, Float:fQueueTime)
  37. {
  38. if(iFailState != TQUERY_SUCCESS)
  39. {
  40. log_amx("LoadClient(): SQL Error #%d - %s", iErrnum, szError)
  41. return
  42. }
  43.  
  44. new id = cData[0]
  45. static szAuth[36]
  46. copy(szAuth, charsmax(szAuth), cData[1])
  47.  
  48. new iAmmoPacks = 0
  49. if(SQL_NumResults(hQuery))
  50. iAmmoPacks = SQL_ReadResult(hQuery, 0)
  51. //SQL_QueryAndIgnore("INSERT INTO `%s` SET auth='%s'", g_szSQLTable, szAuth)
  52.  
  53. g_iAmmoPacks[id] = iAmmoPacks
  54.  
  55. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_LOAD", iAmmoPacks, szAuth)
  56. }
  57.  
  58. SaveClient(id, szAuth[])
  59. {
  60. new iDifference = g_iSessionMovement[id]
  61.  
  62. formatex(g_szQuery, charsmax(g_szQuery),
  63. "INSERT INTO `%s` SET auth='%s', amount=%d ON DUPLICATE KEY UPDATE amount=amount+(%d)",
  64. g_szSQLTable, szAuth, iDifference, iDifference)
  65.  
  66. SQL_ThreadQuery(g_hSQLTuple, "SaveClient_QueryHandler", g_szQuery)
  67. }
  68.  
  69. public SaveClient_QueryHandler(iFailState, Handle:hQuery, szError[], iErrnum, iData[], iSize, Float:fQueueTime)
  70. {
  71. if(iFailState != TQUERY_SUCCESS)
  72. log_amx("SaveClient(): SQL Error #%d - %s", iErrnum, szError)
  73. }
  74.  
  75. #else
  76. new g_hVault
  77.  
  78. LoadClient(id, szAuth[])
  79. {
  80. static szValue[32], iTimestamp
  81. new iValue = 0
  82. if(nvault_lookup(g_hVault, szAuth, szValue, charsmax(szValue), iTimestamp) && is_str_num(szValue))
  83. iValue = (g_iAmmoPacks[id] = str_to_num(szValue))
  84.  
  85. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_LOAD", iValue, szAuth)
  86. }
  87.  
  88. SaveClient(id, szAuth[])
  89. {
  90. static szValue[32]
  91. num_to_str(g_iAmmoPacks[id] + g_iSessionMovement[id], szValue, charsmax(szValue))
  92.  
  93. nvault_set(g_hVault, szAuth, szValue)
  94. }
  95. #endif
  96.  
  97. public plugin_init()
  98. {
  99. register_plugin("[ZP] Ammo Bank", "1.0", "danielkza")
  100.  
  101. register_clcmd("say", "Command_Say")
  102. register_dictionary("zp_bank.txt")
  103.  
  104. cvAnnounceTime = register_cvar("zp_bank_announce_time", "180")
  105. cvBankMax = register_cvar("zp_bank_max", "10000")
  106.  
  107. Task_Announce()
  108.  
  109. #if defined USING_SQL
  110. new configsDir[64]
  111. get_configsdir(configsDir, 63)
  112.  
  113. // Declare standard SQL cvars so we don't depend on admin.amxx
  114. register_cvar("amx_sql_host", "127.0.0.1")
  115. register_cvar("amx_sql_user", "root")
  116. register_cvar("amx_sql_pass", "")
  117. register_cvar("amx_sql_db", "amx")
  118. register_cvar("amx_sql_type", "mysql")
  119.  
  120. new cvTable = register_cvar("zp_bank_table", "zp_bank")
  121. // Execute SQL configs. You must put zp_bank_table in there
  122. server_cmd("exec %s/sql.cfg", configsDir)
  123. server_exec()
  124.  
  125. get_pcvar_string(cvTable, g_szSQLTable, charsmax(g_szSQLTable))
  126. g_hSQLTuple = SQL_MakeStdTuple()
  127.  
  128. new iError, szError[256]
  129. new Handle:hSQLConnection = SQL_Connect(g_hSQLTuple, iError, szError, charsmax(szError))
  130. if(hSQLConnection != Empty_Handle)
  131. {
  132. SQL_QueryAndIgnore(hSQLConnection,
  133. "CREATE TABLE IF NOT EXISTS `%s` (\
  134. auth VARCHAR(36) NOT NULL PRIMARY KEY, \
  135. amount INT(10) UNSIGNED NOT NULL DEFAULT 0 \
  136. ) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
  137. g_szSQLTable )
  138.  
  139. SQL_FreeHandle(hSQLConnection)
  140. }
  141. else
  142. log_amx("plugin_init(): SQL Error #%d - %s", iError, szError)
  143.  
  144. #else
  145. g_hVault = nvault_open("zp_bank")
  146. if(g_hVault == INVALID_HANDLE)
  147. set_fail_state("Can't create/load vault 'zp_bank'")
  148.  
  149. #endif
  150. }
  151.  
  152. public plugin_end()
  153. {
  154. // Client's should have already been saved by now (client_disconnect is called before plugin_end).
  155. // But it costs nothing to be sure.
  156. new iPlayers[32], iNum
  157. get_players(iPlayers, iNum)
  158.  
  159. new iPlayer
  160. for(new i=0; i < iNum;i++)
  161. {
  162. iPlayer = iPlayers[i]
  163. SaveClient(iPlayer, g_szAuth[iPlayer])
  164. }
  165.  
  166. #if defined USING_SQL
  167. SQL_FreeHandle(g_hSQLTuple)
  168.  
  169. #else
  170. nvault_close(g_hVault)
  171.  
  172. #endif
  173. }
  174.  
  175. public client_putinserver(id)
  176. {
  177. static szAuth[36]
  178. get_user_authid(id, szAuth, charsmax(szAuth))
  179. copy(g_szAuth[id], charsmax(g_szAuth[]), szAuth)
  180.  
  181. LoadClient(id, szAuth)
  182. }
  183.  
  184. public client_disconnect(id)
  185. {
  186. SaveClient(id, g_szAuth[id])
  187.  
  188. g_szAuth[id][0] = 0
  189. g_iAmmoPacks[id] = 0
  190. g_iSessionMovement[id] = 0
  191. }
  192.  
  193. new msgSayText = -1
  194. stock bool:SayText(const receiver, sender, const msg[], any:...)
  195. {
  196. if(msgSayText == -1)
  197. msgSayText = get_user_msgid("SayText")
  198.  
  199. if(msgSayText)
  200. {
  201. if(!sender)
  202. sender = receiver
  203.  
  204. static buffer[512]
  205. vformat(buffer,charsmax(buffer), msg, 4)
  206.  
  207. if(receiver)
  208. message_begin(MSG_ONE_UNRELIABLE,msgSayText,_,receiver)
  209. else
  210. message_begin(MSG_BROADCAST,msgSayText)
  211.  
  212. write_byte(sender)
  213. write_string(buffer)
  214. message_end()
  215.  
  216. return true
  217. }
  218.  
  219. return false
  220. }
  221.  
  222.  
  223. public Task_Announce()
  224. {
  225. static iPlayers[32], iNum, iPlayer
  226. get_players(iPlayers, iNum)
  227.  
  228. for(new i=0; i < iNum;i++)
  229. {
  230. iPlayer = iPlayers[i]
  231. SayText(iPlayer, iPlayer, ZP_BANK_FMT, LANG_PLAYER, "ZP_BANK_ANNOUNCE")
  232. }
  233.  
  234. set_task(get_pcvar_float(cvAnnounceTime), "Task_Announce")
  235. }
  236.  
  237. enum
  238. {
  239. CMD_DEPOSIT = 1,
  240. CMD_WITHDRAW,
  241. CMD_INFO
  242. }
  243.  
  244. public Command_Say(id)
  245. {
  246. static szArgs[32]
  247. read_args(szArgs, charsmax(szArgs))
  248. remove_quotes(szArgs)
  249.  
  250. static szArg1[32], szArg2[32]
  251. parse(szArgs, szArg1, charsmax(szArg1), szArg2, charsmax(szArg2))
  252.  
  253. new iCommand = 0
  254. if(equali(szArg1, "/berak"))
  255. iCommand = CMD_DEPOSIT
  256. else if(equali(szArg1, "/kivesz"))
  257. iCommand = CMD_WITHDRAW
  258. else if(equali(szArg1, "/bank"))
  259. iCommand = CMD_INFO
  260.  
  261. if(iCommand)
  262. {
  263. if(iCommand == CMD_INFO)
  264. Command_Info(id)
  265. else
  266. {
  267. new iValue = str_to_num(szArg2)
  268. if(iValue <= 0)
  269. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_INVALID_AMOUNT")
  270.  
  271. else if(iCommand == CMD_DEPOSIT)
  272. Command_Deposit(id, iValue)
  273. else
  274. Command_Withdraw(id, iValue)
  275. }
  276.  
  277. return PLUGIN_HANDLED
  278.  
  279. }
  280.  
  281. return PLUGIN_CONTINUE
  282. }
  283.  
  284. Command_Info(id)
  285. {
  286. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_LOAD", g_iAmmoPacks[id] + g_iSessionMovement[id], g_szAuth[id])
  287. }
  288.  
  289. Command_Deposit(id, iDeposit)
  290. {
  291. new iCurrentAmount = zp_get_user_ammo_packs(id)
  292. if(!iCurrentAmount)
  293. {
  294. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_NO_AMMO")
  295. return
  296. }
  297.  
  298. if(iDeposit > iCurrentAmount)
  299. iDeposit = iCurrentAmount
  300.  
  301. new iCurrent = g_iAmmoPacks[id] + g_iSessionMovement[id]
  302. new iSum = iCurrent + iDeposit
  303. new iBankMax = get_pcvar_num(cvBankMax)
  304.  
  305. if(iBankMax && iSum > iBankMax)
  306. {
  307. iDeposit = iBankMax - iCurrent
  308. iSum = iBankMax
  309.  
  310. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_MAX", iBankMax)
  311. }
  312.  
  313. if(iDeposit)
  314. {
  315. g_iSessionMovement[id] += iDeposit
  316.  
  317. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_DEPOSIT", iDeposit, iSum) //
  318. zp_set_user_ammo_packs(id, iCurrentAmount - iDeposit)
  319. }
  320. }
  321.  
  322.  
  323. Command_Withdraw(id, iWithdraw)
  324. {
  325. new iDeposited = g_iAmmoPacks[id] + g_iSessionMovement[id]
  326. if(!iDeposited)
  327. {
  328. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_EMPTY")
  329. return
  330. }
  331.  
  332. if(iWithdraw > iDeposited)
  333. iWithdraw = iDeposited
  334.  
  335. g_iSessionMovement[id] -= iWithdraw
  336.  
  337. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_WITHDRAW", iWithdraw, iDeposited - iWithdraw)
  338. zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) + iWithdraw)
  339. }


register_cvar("amx_sql_host", "127.0.0.1")
register_cvar("amx_sql_user", "root")
register_cvar("amx_sql_pass", "")
register_cvar("amx_sql_db", "amx")
register_cvar("amx_sql_type", "mysql")

_________________
****


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: ZP Bank
HozzászólásElküldve: 2013.03.30. 18:38 
Offline
Félisten

Csatlakozott: 2012.06.19. 15:12
Hozzászólások: 926
Megköszönt másnak: 109 alkalommal
Megköszönték neki: 31 alkalommal
pixxa112 írta:
Tomos írta:
Valki zombi plague 4.3-ra tudna lineklni egy olyan bankot amiböl nem tünik el az ammó és aútómatikusan menti és ha feljön kiveszi magátol.


Próbáld SQL-el menteni:
SMA Forráskód: [ Mindet kijelol ]
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <zombieplague>
  4.  
  5. //#define USING_SQL
  6. #if defined USING_SQL
  7. #include <sqlx>
  8. #else
  9. #include <nvault>
  10. #endif
  11.  
  12. stock const ZP_BANK_FMT[] = "^x04[ZP-BANK]^x01 %L"
  13.  
  14. new g_iAmmoPacks[33]
  15. new g_iSessionMovement[33]
  16. new g_szAuth[33][36]
  17. new cvAnnounceTime
  18. new cvBankMax
  19.  
  20. #if defined USING_SQL
  21. new g_szSQLTable[64], Handle:g_hSQLTuple, g_szQuery[128]
  22.  
  23. LoadClient(id, szAuth[])
  24. {
  25. formatex(g_szQuery, charsmax(g_szQuery),
  26. "SELECT amount FROM `%s` WHERE auth='%s'",
  27. g_szSQLTable, szAuth)
  28.  
  29. new cData[37]
  30. cData[0] = id
  31. copy(cData[1], charsmax(cData)-1, szAuth)
  32.  
  33. SQL_ThreadQuery(g_hSQLTuple, "LoadClient_QueryHandler", g_szQuery, cData, strlen(cData[1]))
  34. }
  35.  
  36. public LoadClient_QueryHandler(iFailState, Handle:hQuery, szError[], iErrnum, cData[], iSize, Float:fQueueTime)
  37. {
  38. if(iFailState != TQUERY_SUCCESS)
  39. {
  40. log_amx("LoadClient(): SQL Error #%d - %s", iErrnum, szError)
  41. return
  42. }
  43.  
  44. new id = cData[0]
  45. static szAuth[36]
  46. copy(szAuth, charsmax(szAuth), cData[1])
  47.  
  48. new iAmmoPacks = 0
  49. if(SQL_NumResults(hQuery))
  50. iAmmoPacks = SQL_ReadResult(hQuery, 0)
  51. //SQL_QueryAndIgnore("INSERT INTO `%s` SET auth='%s'", g_szSQLTable, szAuth)
  52.  
  53. g_iAmmoPacks[id] = iAmmoPacks
  54.  
  55. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_LOAD", iAmmoPacks, szAuth)
  56. }
  57.  
  58. SaveClient(id, szAuth[])
  59. {
  60. new iDifference = g_iSessionMovement[id]
  61.  
  62. formatex(g_szQuery, charsmax(g_szQuery),
  63. "INSERT INTO `%s` SET auth='%s', amount=%d ON DUPLICATE KEY UPDATE amount=amount+(%d)",
  64. g_szSQLTable, szAuth, iDifference, iDifference)
  65.  
  66. SQL_ThreadQuery(g_hSQLTuple, "SaveClient_QueryHandler", g_szQuery)
  67. }
  68.  
  69. public SaveClient_QueryHandler(iFailState, Handle:hQuery, szError[], iErrnum, iData[], iSize, Float:fQueueTime)
  70. {
  71. if(iFailState != TQUERY_SUCCESS)
  72. log_amx("SaveClient(): SQL Error #%d - %s", iErrnum, szError)
  73. }
  74.  
  75. #else
  76. new g_hVault
  77.  
  78. LoadClient(id, szAuth[])
  79. {
  80. static szValue[32], iTimestamp
  81. new iValue = 0
  82. if(nvault_lookup(g_hVault, szAuth, szValue, charsmax(szValue), iTimestamp) && is_str_num(szValue))
  83. iValue = (g_iAmmoPacks[id] = str_to_num(szValue))
  84.  
  85. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_LOAD", iValue, szAuth)
  86. }
  87.  
  88. SaveClient(id, szAuth[])
  89. {
  90. static szValue[32]
  91. num_to_str(g_iAmmoPacks[id] + g_iSessionMovement[id], szValue, charsmax(szValue))
  92.  
  93. nvault_set(g_hVault, szAuth, szValue)
  94. }
  95. #endif
  96.  
  97. public plugin_init()
  98. {
  99. register_plugin("[ZP] Ammo Bank", "1.0", "danielkza")
  100.  
  101. register_clcmd("say", "Command_Say")
  102. register_dictionary("zp_bank.txt")
  103.  
  104. cvAnnounceTime = register_cvar("zp_bank_announce_time", "180")
  105. cvBankMax = register_cvar("zp_bank_max", "10000")
  106.  
  107. Task_Announce()
  108.  
  109. #if defined USING_SQL
  110. new configsDir[64]
  111. get_configsdir(configsDir, 63)
  112.  
  113. // Declare standard SQL cvars so we don't depend on admin.amxx
  114. register_cvar("amx_sql_host", "127.0.0.1")
  115. register_cvar("amx_sql_user", "root")
  116. register_cvar("amx_sql_pass", "")
  117. register_cvar("amx_sql_db", "amx")
  118. register_cvar("amx_sql_type", "mysql")
  119.  
  120. new cvTable = register_cvar("zp_bank_table", "zp_bank")
  121. // Execute SQL configs. You must put zp_bank_table in there
  122. server_cmd("exec %s/sql.cfg", configsDir)
  123. server_exec()
  124.  
  125. get_pcvar_string(cvTable, g_szSQLTable, charsmax(g_szSQLTable))
  126. g_hSQLTuple = SQL_MakeStdTuple()
  127.  
  128. new iError, szError[256]
  129. new Handle:hSQLConnection = SQL_Connect(g_hSQLTuple, iError, szError, charsmax(szError))
  130. if(hSQLConnection != Empty_Handle)
  131. {
  132. SQL_QueryAndIgnore(hSQLConnection,
  133. "CREATE TABLE IF NOT EXISTS `%s` (\
  134. auth VARCHAR(36) NOT NULL PRIMARY KEY, \
  135. amount INT(10) UNSIGNED NOT NULL DEFAULT 0 \
  136. ) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
  137. g_szSQLTable )
  138.  
  139. SQL_FreeHandle(hSQLConnection)
  140. }
  141. else
  142. log_amx("plugin_init(): SQL Error #%d - %s", iError, szError)
  143.  
  144. #else
  145. g_hVault = nvault_open("zp_bank")
  146. if(g_hVault == INVALID_HANDLE)
  147. set_fail_state("Can't create/load vault 'zp_bank'")
  148.  
  149. #endif
  150. }
  151.  
  152. public plugin_end()
  153. {
  154. // Client's should have already been saved by now (client_disconnect is called before plugin_end).
  155. // But it costs nothing to be sure.
  156. new iPlayers[32], iNum
  157. get_players(iPlayers, iNum)
  158.  
  159. new iPlayer
  160. for(new i=0; i < iNum;i++)
  161. {
  162. iPlayer = iPlayers[i]
  163. SaveClient(iPlayer, g_szAuth[iPlayer])
  164. }
  165.  
  166. #if defined USING_SQL
  167. SQL_FreeHandle(g_hSQLTuple)
  168.  
  169. #else
  170. nvault_close(g_hVault)
  171.  
  172. #endif
  173. }
  174.  
  175. public client_putinserver(id)
  176. {
  177. static szAuth[36]
  178. get_user_authid(id, szAuth, charsmax(szAuth))
  179. copy(g_szAuth[id], charsmax(g_szAuth[]), szAuth)
  180.  
  181. LoadClient(id, szAuth)
  182. }
  183.  
  184. public client_disconnect(id)
  185. {
  186. SaveClient(id, g_szAuth[id])
  187.  
  188. g_szAuth[id][0] = 0
  189. g_iAmmoPacks[id] = 0
  190. g_iSessionMovement[id] = 0
  191. }
  192.  
  193. new msgSayText = -1
  194. stock bool:SayText(const receiver, sender, const msg[], any:...)
  195. {
  196. if(msgSayText == -1)
  197. msgSayText = get_user_msgid("SayText")
  198.  
  199. if(msgSayText)
  200. {
  201. if(!sender)
  202. sender = receiver
  203.  
  204. static buffer[512]
  205. vformat(buffer,charsmax(buffer), msg, 4)
  206.  
  207. if(receiver)
  208. message_begin(MSG_ONE_UNRELIABLE,msgSayText,_,receiver)
  209. else
  210. message_begin(MSG_BROADCAST,msgSayText)
  211.  
  212. write_byte(sender)
  213. write_string(buffer)
  214. message_end()
  215.  
  216. return true
  217. }
  218.  
  219. return false
  220. }
  221.  
  222.  
  223. public Task_Announce()
  224. {
  225. static iPlayers[32], iNum, iPlayer
  226. get_players(iPlayers, iNum)
  227.  
  228. for(new i=0; i < iNum;i++)
  229. {
  230. iPlayer = iPlayers[i]
  231. SayText(iPlayer, iPlayer, ZP_BANK_FMT, LANG_PLAYER, "ZP_BANK_ANNOUNCE")
  232. }
  233.  
  234. set_task(get_pcvar_float(cvAnnounceTime), "Task_Announce")
  235. }
  236.  
  237. enum
  238. {
  239. CMD_DEPOSIT = 1,
  240. CMD_WITHDRAW,
  241. CMD_INFO
  242. }
  243.  
  244. public Command_Say(id)
  245. {
  246. static szArgs[32]
  247. read_args(szArgs, charsmax(szArgs))
  248. remove_quotes(szArgs)
  249.  
  250. static szArg1[32], szArg2[32]
  251. parse(szArgs, szArg1, charsmax(szArg1), szArg2, charsmax(szArg2))
  252.  
  253. new iCommand = 0
  254. if(equali(szArg1, "/berak"))
  255. iCommand = CMD_DEPOSIT
  256. else if(equali(szArg1, "/kivesz"))
  257. iCommand = CMD_WITHDRAW
  258. else if(equali(szArg1, "/bank"))
  259. iCommand = CMD_INFO
  260.  
  261. if(iCommand)
  262. {
  263. if(iCommand == CMD_INFO)
  264. Command_Info(id)
  265. else
  266. {
  267. new iValue = str_to_num(szArg2)
  268. if(iValue <= 0)
  269. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_INVALID_AMOUNT")
  270.  
  271. else if(iCommand == CMD_DEPOSIT)
  272. Command_Deposit(id, iValue)
  273. else
  274. Command_Withdraw(id, iValue)
  275. }
  276.  
  277. return PLUGIN_HANDLED
  278.  
  279. }
  280.  
  281. return PLUGIN_CONTINUE
  282. }
  283.  
  284. Command_Info(id)
  285. {
  286. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_LOAD", g_iAmmoPacks[id] + g_iSessionMovement[id], g_szAuth[id])
  287. }
  288.  
  289. Command_Deposit(id, iDeposit)
  290. {
  291. new iCurrentAmount = zp_get_user_ammo_packs(id)
  292. if(!iCurrentAmount)
  293. {
  294. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_NO_AMMO")
  295. return
  296. }
  297.  
  298. if(iDeposit > iCurrentAmount)
  299. iDeposit = iCurrentAmount
  300.  
  301. new iCurrent = g_iAmmoPacks[id] + g_iSessionMovement[id]
  302. new iSum = iCurrent + iDeposit
  303. new iBankMax = get_pcvar_num(cvBankMax)
  304.  
  305. if(iBankMax && iSum > iBankMax)
  306. {
  307. iDeposit = iBankMax - iCurrent
  308. iSum = iBankMax
  309.  
  310. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_MAX", iBankMax)
  311. }
  312.  
  313. if(iDeposit)
  314. {
  315. g_iSessionMovement[id] += iDeposit
  316.  
  317. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_DEPOSIT", iDeposit, iSum) //
  318. zp_set_user_ammo_packs(id, iCurrentAmount - iDeposit)
  319. }
  320. }
  321.  
  322.  
  323. Command_Withdraw(id, iWithdraw)
  324. {
  325. new iDeposited = g_iAmmoPacks[id] + g_iSessionMovement[id]
  326. if(!iDeposited)
  327. {
  328. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_EMPTY")
  329. return
  330. }
  331.  
  332. if(iWithdraw > iDeposited)
  333. iWithdraw = iDeposited
  334.  
  335. g_iSessionMovement[id] -= iWithdraw
  336.  
  337. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_WITHDRAW", iWithdraw, iDeposited - iWithdraw)
  338. zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) + iWithdraw)
  339. }


register_cvar("amx_sql_host", "127.0.0.1")
register_cvar("amx_sql_user", "root")
register_cvar("amx_sql_pass", "")
register_cvar("amx_sql_db", "amx")
register_cvar("amx_sql_type", "mysql")

Ehez több fájl nincs?

_________________
Kép


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: ZP Bank
HozzászólásElküldve: 2013.03.30. 18:55 
Offline
Veterán

Csatlakozott: 2012.11.01. 20:49
Hozzászólások: 1837
Megköszönt másnak: 25 alkalommal
Megköszönték neki: 78 alkalommal
Tomos írta:
pixxa112 írta:
Tomos írta:
Valki zombi plague 4.3-ra tudna lineklni egy olyan bankot amiböl nem tünik el az ammó és aútómatikusan menti és ha feljön kiveszi magátol.


Próbáld SQL-el menteni:
SMA Forráskód: [ Mindet kijelol ]
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <zombieplague>
  4.  
  5. //#define USING_SQL
  6. #if defined USING_SQL
  7. #include <sqlx>
  8. #else
  9. #include <nvault>
  10. #endif
  11.  
  12. stock const ZP_BANK_FMT[] = "^x04[ZP-BANK]^x01 %L"
  13.  
  14. new g_iAmmoPacks[33]
  15. new g_iSessionMovement[33]
  16. new g_szAuth[33][36]
  17. new cvAnnounceTime
  18. new cvBankMax
  19.  
  20. #if defined USING_SQL
  21. new g_szSQLTable[64], Handle:g_hSQLTuple, g_szQuery[128]
  22.  
  23. LoadClient(id, szAuth[])
  24. {
  25. formatex(g_szQuery, charsmax(g_szQuery),
  26. "SELECT amount FROM `%s` WHERE auth='%s'",
  27. g_szSQLTable, szAuth)
  28.  
  29. new cData[37]
  30. cData[0] = id
  31. copy(cData[1], charsmax(cData)-1, szAuth)
  32.  
  33. SQL_ThreadQuery(g_hSQLTuple, "LoadClient_QueryHandler", g_szQuery, cData, strlen(cData[1]))
  34. }
  35.  
  36. public LoadClient_QueryHandler(iFailState, Handle:hQuery, szError[], iErrnum, cData[], iSize, Float:fQueueTime)
  37. {
  38. if(iFailState != TQUERY_SUCCESS)
  39. {
  40. log_amx("LoadClient(): SQL Error #%d - %s", iErrnum, szError)
  41. return
  42. }
  43.  
  44. new id = cData[0]
  45. static szAuth[36]
  46. copy(szAuth, charsmax(szAuth), cData[1])
  47.  
  48. new iAmmoPacks = 0
  49. if(SQL_NumResults(hQuery))
  50. iAmmoPacks = SQL_ReadResult(hQuery, 0)
  51. //SQL_QueryAndIgnore("INSERT INTO `%s` SET auth='%s'", g_szSQLTable, szAuth)
  52.  
  53. g_iAmmoPacks[id] = iAmmoPacks
  54.  
  55. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_LOAD", iAmmoPacks, szAuth)
  56. }
  57.  
  58. SaveClient(id, szAuth[])
  59. {
  60. new iDifference = g_iSessionMovement[id]
  61.  
  62. formatex(g_szQuery, charsmax(g_szQuery),
  63. "INSERT INTO `%s` SET auth='%s', amount=%d ON DUPLICATE KEY UPDATE amount=amount+(%d)",
  64. g_szSQLTable, szAuth, iDifference, iDifference)
  65.  
  66. SQL_ThreadQuery(g_hSQLTuple, "SaveClient_QueryHandler", g_szQuery)
  67. }
  68.  
  69. public SaveClient_QueryHandler(iFailState, Handle:hQuery, szError[], iErrnum, iData[], iSize, Float:fQueueTime)
  70. {
  71. if(iFailState != TQUERY_SUCCESS)
  72. log_amx("SaveClient(): SQL Error #%d - %s", iErrnum, szError)
  73. }
  74.  
  75. #else
  76. new g_hVault
  77.  
  78. LoadClient(id, szAuth[])
  79. {
  80. static szValue[32], iTimestamp
  81. new iValue = 0
  82. if(nvault_lookup(g_hVault, szAuth, szValue, charsmax(szValue), iTimestamp) && is_str_num(szValue))
  83. iValue = (g_iAmmoPacks[id] = str_to_num(szValue))
  84.  
  85. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_LOAD", iValue, szAuth)
  86. }
  87.  
  88. SaveClient(id, szAuth[])
  89. {
  90. static szValue[32]
  91. num_to_str(g_iAmmoPacks[id] + g_iSessionMovement[id], szValue, charsmax(szValue))
  92.  
  93. nvault_set(g_hVault, szAuth, szValue)
  94. }
  95. #endif
  96.  
  97. public plugin_init()
  98. {
  99. register_plugin("[ZP] Ammo Bank", "1.0", "danielkza")
  100.  
  101. register_clcmd("say", "Command_Say")
  102. register_dictionary("zp_bank.txt")
  103.  
  104. cvAnnounceTime = register_cvar("zp_bank_announce_time", "180")
  105. cvBankMax = register_cvar("zp_bank_max", "10000")
  106.  
  107. Task_Announce()
  108.  
  109. #if defined USING_SQL
  110. new configsDir[64]
  111. get_configsdir(configsDir, 63)
  112.  
  113. // Declare standard SQL cvars so we don't depend on admin.amxx
  114. register_cvar("amx_sql_host", "127.0.0.1")
  115. register_cvar("amx_sql_user", "root")
  116. register_cvar("amx_sql_pass", "")
  117. register_cvar("amx_sql_db", "amx")
  118. register_cvar("amx_sql_type", "mysql")
  119.  
  120. new cvTable = register_cvar("zp_bank_table", "zp_bank")
  121. // Execute SQL configs. You must put zp_bank_table in there
  122. server_cmd("exec %s/sql.cfg", configsDir)
  123. server_exec()
  124.  
  125. get_pcvar_string(cvTable, g_szSQLTable, charsmax(g_szSQLTable))
  126. g_hSQLTuple = SQL_MakeStdTuple()
  127.  
  128. new iError, szError[256]
  129. new Handle:hSQLConnection = SQL_Connect(g_hSQLTuple, iError, szError, charsmax(szError))
  130. if(hSQLConnection != Empty_Handle)
  131. {
  132. SQL_QueryAndIgnore(hSQLConnection,
  133. "CREATE TABLE IF NOT EXISTS `%s` (\
  134. auth VARCHAR(36) NOT NULL PRIMARY KEY, \
  135. amount INT(10) UNSIGNED NOT NULL DEFAULT 0 \
  136. ) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
  137. g_szSQLTable )
  138.  
  139. SQL_FreeHandle(hSQLConnection)
  140. }
  141. else
  142. log_amx("plugin_init(): SQL Error #%d - %s", iError, szError)
  143.  
  144. #else
  145. g_hVault = nvault_open("zp_bank")
  146. if(g_hVault == INVALID_HANDLE)
  147. set_fail_state("Can't create/load vault 'zp_bank'")
  148.  
  149. #endif
  150. }
  151.  
  152. public plugin_end()
  153. {
  154. // Client's should have already been saved by now (client_disconnect is called before plugin_end).
  155. // But it costs nothing to be sure.
  156. new iPlayers[32], iNum
  157. get_players(iPlayers, iNum)
  158.  
  159. new iPlayer
  160. for(new i=0; i < iNum;i++)
  161. {
  162. iPlayer = iPlayers[i]
  163. SaveClient(iPlayer, g_szAuth[iPlayer])
  164. }
  165.  
  166. #if defined USING_SQL
  167. SQL_FreeHandle(g_hSQLTuple)
  168.  
  169. #else
  170. nvault_close(g_hVault)
  171.  
  172. #endif
  173. }
  174.  
  175. public client_putinserver(id)
  176. {
  177. static szAuth[36]
  178. get_user_authid(id, szAuth, charsmax(szAuth))
  179. copy(g_szAuth[id], charsmax(g_szAuth[]), szAuth)
  180.  
  181. LoadClient(id, szAuth)
  182. }
  183.  
  184. public client_disconnect(id)
  185. {
  186. SaveClient(id, g_szAuth[id])
  187.  
  188. g_szAuth[id][0] = 0
  189. g_iAmmoPacks[id] = 0
  190. g_iSessionMovement[id] = 0
  191. }
  192.  
  193. new msgSayText = -1
  194. stock bool:SayText(const receiver, sender, const msg[], any:...)
  195. {
  196. if(msgSayText == -1)
  197. msgSayText = get_user_msgid("SayText")
  198.  
  199. if(msgSayText)
  200. {
  201. if(!sender)
  202. sender = receiver
  203.  
  204. static buffer[512]
  205. vformat(buffer,charsmax(buffer), msg, 4)
  206.  
  207. if(receiver)
  208. message_begin(MSG_ONE_UNRELIABLE,msgSayText,_,receiver)
  209. else
  210. message_begin(MSG_BROADCAST,msgSayText)
  211.  
  212. write_byte(sender)
  213. write_string(buffer)
  214. message_end()
  215.  
  216. return true
  217. }
  218.  
  219. return false
  220. }
  221.  
  222.  
  223. public Task_Announce()
  224. {
  225. static iPlayers[32], iNum, iPlayer
  226. get_players(iPlayers, iNum)
  227.  
  228. for(new i=0; i < iNum;i++)
  229. {
  230. iPlayer = iPlayers[i]
  231. SayText(iPlayer, iPlayer, ZP_BANK_FMT, LANG_PLAYER, "ZP_BANK_ANNOUNCE")
  232. }
  233.  
  234. set_task(get_pcvar_float(cvAnnounceTime), "Task_Announce")
  235. }
  236.  
  237. enum
  238. {
  239. CMD_DEPOSIT = 1,
  240. CMD_WITHDRAW,
  241. CMD_INFO
  242. }
  243.  
  244. public Command_Say(id)
  245. {
  246. static szArgs[32]
  247. read_args(szArgs, charsmax(szArgs))
  248. remove_quotes(szArgs)
  249.  
  250. static szArg1[32], szArg2[32]
  251. parse(szArgs, szArg1, charsmax(szArg1), szArg2, charsmax(szArg2))
  252.  
  253. new iCommand = 0
  254. if(equali(szArg1, "/berak"))
  255. iCommand = CMD_DEPOSIT
  256. else if(equali(szArg1, "/kivesz"))
  257. iCommand = CMD_WITHDRAW
  258. else if(equali(szArg1, "/bank"))
  259. iCommand = CMD_INFO
  260.  
  261. if(iCommand)
  262. {
  263. if(iCommand == CMD_INFO)
  264. Command_Info(id)
  265. else
  266. {
  267. new iValue = str_to_num(szArg2)
  268. if(iValue <= 0)
  269. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_INVALID_AMOUNT")
  270.  
  271. else if(iCommand == CMD_DEPOSIT)
  272. Command_Deposit(id, iValue)
  273. else
  274. Command_Withdraw(id, iValue)
  275. }
  276.  
  277. return PLUGIN_HANDLED
  278.  
  279. }
  280.  
  281. return PLUGIN_CONTINUE
  282. }
  283.  
  284. Command_Info(id)
  285. {
  286. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_LOAD", g_iAmmoPacks[id] + g_iSessionMovement[id], g_szAuth[id])
  287. }
  288.  
  289. Command_Deposit(id, iDeposit)
  290. {
  291. new iCurrentAmount = zp_get_user_ammo_packs(id)
  292. if(!iCurrentAmount)
  293. {
  294. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_NO_AMMO")
  295. return
  296. }
  297.  
  298. if(iDeposit > iCurrentAmount)
  299. iDeposit = iCurrentAmount
  300.  
  301. new iCurrent = g_iAmmoPacks[id] + g_iSessionMovement[id]
  302. new iSum = iCurrent + iDeposit
  303. new iBankMax = get_pcvar_num(cvBankMax)
  304.  
  305. if(iBankMax && iSum > iBankMax)
  306. {
  307. iDeposit = iBankMax - iCurrent
  308. iSum = iBankMax
  309.  
  310. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_MAX", iBankMax)
  311. }
  312.  
  313. if(iDeposit)
  314. {
  315. g_iSessionMovement[id] += iDeposit
  316.  
  317. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_DEPOSIT", iDeposit, iSum) //
  318. zp_set_user_ammo_packs(id, iCurrentAmount - iDeposit)
  319. }
  320. }
  321.  
  322.  
  323. Command_Withdraw(id, iWithdraw)
  324. {
  325. new iDeposited = g_iAmmoPacks[id] + g_iSessionMovement[id]
  326. if(!iDeposited)
  327. {
  328. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_EMPTY")
  329. return
  330. }
  331.  
  332. if(iWithdraw > iDeposited)
  333. iWithdraw = iDeposited
  334.  
  335. g_iSessionMovement[id] -= iWithdraw
  336.  
  337. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_WITHDRAW", iWithdraw, iDeposited - iWithdraw)
  338. zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) + iWithdraw)
  339. }


register_cvar("amx_sql_host", "127.0.0.1")
register_cvar("amx_sql_user", "root")
register_cvar("amx_sql_pass", "")
register_cvar("amx_sql_db", "amx")
register_cvar("amx_sql_type", "mysql")

Ehez több fájl nincs?

minek?


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: ZP Bank
HozzászólásElküldve: 2013.03.30. 19:04 
Offline
Félisten

Csatlakozott: 2012.06.19. 15:12
Hozzászólások: 926
Megköszönt másnak: 109 alkalommal
Megköszönték neki: 31 alkalommal
m0csy652 írta:
Tomos írta:
pixxa112 írta:
Tomos írta:
Valki zombi plague 4.3-ra tudna lineklni egy olyan bankot amiböl nem tünik el az ammó és aútómatikusan menti és ha feljön kiveszi magátol.


Próbáld SQL-el menteni:
SMA Forráskód: [ Mindet kijelol ]
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <zombieplague>
  4.  
  5. //#define USING_SQL
  6. #if defined USING_SQL
  7. #include <sqlx>
  8. #else
  9. #include <nvault>
  10. #endif
  11.  
  12. stock const ZP_BANK_FMT[] = "^x04[ZP-BANK]^x01 %L"
  13.  
  14. new g_iAmmoPacks[33]
  15. new g_iSessionMovement[33]
  16. new g_szAuth[33][36]
  17. new cvAnnounceTime
  18. new cvBankMax
  19.  
  20. #if defined USING_SQL
  21. new g_szSQLTable[64], Handle:g_hSQLTuple, g_szQuery[128]
  22.  
  23. LoadClient(id, szAuth[])
  24. {
  25. formatex(g_szQuery, charsmax(g_szQuery),
  26. "SELECT amount FROM `%s` WHERE auth='%s'",
  27. g_szSQLTable, szAuth)
  28.  
  29. new cData[37]
  30. cData[0] = id
  31. copy(cData[1], charsmax(cData)-1, szAuth)
  32.  
  33. SQL_ThreadQuery(g_hSQLTuple, "LoadClient_QueryHandler", g_szQuery, cData, strlen(cData[1]))
  34. }
  35.  
  36. public LoadClient_QueryHandler(iFailState, Handle:hQuery, szError[], iErrnum, cData[], iSize, Float:fQueueTime)
  37. {
  38. if(iFailState != TQUERY_SUCCESS)
  39. {
  40. log_amx("LoadClient(): SQL Error #%d - %s", iErrnum, szError)
  41. return
  42. }
  43.  
  44. new id = cData[0]
  45. static szAuth[36]
  46. copy(szAuth, charsmax(szAuth), cData[1])
  47.  
  48. new iAmmoPacks = 0
  49. if(SQL_NumResults(hQuery))
  50. iAmmoPacks = SQL_ReadResult(hQuery, 0)
  51. //SQL_QueryAndIgnore("INSERT INTO `%s` SET auth='%s'", g_szSQLTable, szAuth)
  52.  
  53. g_iAmmoPacks[id] = iAmmoPacks
  54.  
  55. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_LOAD", iAmmoPacks, szAuth)
  56. }
  57.  
  58. SaveClient(id, szAuth[])
  59. {
  60. new iDifference = g_iSessionMovement[id]
  61.  
  62. formatex(g_szQuery, charsmax(g_szQuery),
  63. "INSERT INTO `%s` SET auth='%s', amount=%d ON DUPLICATE KEY UPDATE amount=amount+(%d)",
  64. g_szSQLTable, szAuth, iDifference, iDifference)
  65.  
  66. SQL_ThreadQuery(g_hSQLTuple, "SaveClient_QueryHandler", g_szQuery)
  67. }
  68.  
  69. public SaveClient_QueryHandler(iFailState, Handle:hQuery, szError[], iErrnum, iData[], iSize, Float:fQueueTime)
  70. {
  71. if(iFailState != TQUERY_SUCCESS)
  72. log_amx("SaveClient(): SQL Error #%d - %s", iErrnum, szError)
  73. }
  74.  
  75. #else
  76. new g_hVault
  77.  
  78. LoadClient(id, szAuth[])
  79. {
  80. static szValue[32], iTimestamp
  81. new iValue = 0
  82. if(nvault_lookup(g_hVault, szAuth, szValue, charsmax(szValue), iTimestamp) && is_str_num(szValue))
  83. iValue = (g_iAmmoPacks[id] = str_to_num(szValue))
  84.  
  85. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_LOAD", iValue, szAuth)
  86. }
  87.  
  88. SaveClient(id, szAuth[])
  89. {
  90. static szValue[32]
  91. num_to_str(g_iAmmoPacks[id] + g_iSessionMovement[id], szValue, charsmax(szValue))
  92.  
  93. nvault_set(g_hVault, szAuth, szValue)
  94. }
  95. #endif
  96.  
  97. public plugin_init()
  98. {
  99. register_plugin("[ZP] Ammo Bank", "1.0", "danielkza")
  100.  
  101. register_clcmd("say", "Command_Say")
  102. register_dictionary("zp_bank.txt")
  103.  
  104. cvAnnounceTime = register_cvar("zp_bank_announce_time", "180")
  105. cvBankMax = register_cvar("zp_bank_max", "10000")
  106.  
  107. Task_Announce()
  108.  
  109. #if defined USING_SQL
  110. new configsDir[64]
  111. get_configsdir(configsDir, 63)
  112.  
  113. // Declare standard SQL cvars so we don't depend on admin.amxx
  114. register_cvar("amx_sql_host", "127.0.0.1")
  115. register_cvar("amx_sql_user", "root")
  116. register_cvar("amx_sql_pass", "")
  117. register_cvar("amx_sql_db", "amx")
  118. register_cvar("amx_sql_type", "mysql")
  119.  
  120. new cvTable = register_cvar("zp_bank_table", "zp_bank")
  121. // Execute SQL configs. You must put zp_bank_table in there
  122. server_cmd("exec %s/sql.cfg", configsDir)
  123. server_exec()
  124.  
  125. get_pcvar_string(cvTable, g_szSQLTable, charsmax(g_szSQLTable))
  126. g_hSQLTuple = SQL_MakeStdTuple()
  127.  
  128. new iError, szError[256]
  129. new Handle:hSQLConnection = SQL_Connect(g_hSQLTuple, iError, szError, charsmax(szError))
  130. if(hSQLConnection != Empty_Handle)
  131. {
  132. SQL_QueryAndIgnore(hSQLConnection,
  133. "CREATE TABLE IF NOT EXISTS `%s` (\
  134. auth VARCHAR(36) NOT NULL PRIMARY KEY, \
  135. amount INT(10) UNSIGNED NOT NULL DEFAULT 0 \
  136. ) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
  137. g_szSQLTable )
  138.  
  139. SQL_FreeHandle(hSQLConnection)
  140. }
  141. else
  142. log_amx("plugin_init(): SQL Error #%d - %s", iError, szError)
  143.  
  144. #else
  145. g_hVault = nvault_open("zp_bank")
  146. if(g_hVault == INVALID_HANDLE)
  147. set_fail_state("Can't create/load vault 'zp_bank'")
  148.  
  149. #endif
  150. }
  151.  
  152. public plugin_end()
  153. {
  154. // Client's should have already been saved by now (client_disconnect is called before plugin_end).
  155. // But it costs nothing to be sure.
  156. new iPlayers[32], iNum
  157. get_players(iPlayers, iNum)
  158.  
  159. new iPlayer
  160. for(new i=0; i < iNum;i++)
  161. {
  162. iPlayer = iPlayers[i]
  163. SaveClient(iPlayer, g_szAuth[iPlayer])
  164. }
  165.  
  166. #if defined USING_SQL
  167. SQL_FreeHandle(g_hSQLTuple)
  168.  
  169. #else
  170. nvault_close(g_hVault)
  171.  
  172. #endif
  173. }
  174.  
  175. public client_putinserver(id)
  176. {
  177. static szAuth[36]
  178. get_user_authid(id, szAuth, charsmax(szAuth))
  179. copy(g_szAuth[id], charsmax(g_szAuth[]), szAuth)
  180.  
  181. LoadClient(id, szAuth)
  182. }
  183.  
  184. public client_disconnect(id)
  185. {
  186. SaveClient(id, g_szAuth[id])
  187.  
  188. g_szAuth[id][0] = 0
  189. g_iAmmoPacks[id] = 0
  190. g_iSessionMovement[id] = 0
  191. }
  192.  
  193. new msgSayText = -1
  194. stock bool:SayText(const receiver, sender, const msg[], any:...)
  195. {
  196. if(msgSayText == -1)
  197. msgSayText = get_user_msgid("SayText")
  198.  
  199. if(msgSayText)
  200. {
  201. if(!sender)
  202. sender = receiver
  203.  
  204. static buffer[512]
  205. vformat(buffer,charsmax(buffer), msg, 4)
  206.  
  207. if(receiver)
  208. message_begin(MSG_ONE_UNRELIABLE,msgSayText,_,receiver)
  209. else
  210. message_begin(MSG_BROADCAST,msgSayText)
  211.  
  212. write_byte(sender)
  213. write_string(buffer)
  214. message_end()
  215.  
  216. return true
  217. }
  218.  
  219. return false
  220. }
  221.  
  222.  
  223. public Task_Announce()
  224. {
  225. static iPlayers[32], iNum, iPlayer
  226. get_players(iPlayers, iNum)
  227.  
  228. for(new i=0; i < iNum;i++)
  229. {
  230. iPlayer = iPlayers[i]
  231. SayText(iPlayer, iPlayer, ZP_BANK_FMT, LANG_PLAYER, "ZP_BANK_ANNOUNCE")
  232. }
  233.  
  234. set_task(get_pcvar_float(cvAnnounceTime), "Task_Announce")
  235. }
  236.  
  237. enum
  238. {
  239. CMD_DEPOSIT = 1,
  240. CMD_WITHDRAW,
  241. CMD_INFO
  242. }
  243.  
  244. public Command_Say(id)
  245. {
  246. static szArgs[32]
  247. read_args(szArgs, charsmax(szArgs))
  248. remove_quotes(szArgs)
  249.  
  250. static szArg1[32], szArg2[32]
  251. parse(szArgs, szArg1, charsmax(szArg1), szArg2, charsmax(szArg2))
  252.  
  253. new iCommand = 0
  254. if(equali(szArg1, "/berak"))
  255. iCommand = CMD_DEPOSIT
  256. else if(equali(szArg1, "/kivesz"))
  257. iCommand = CMD_WITHDRAW
  258. else if(equali(szArg1, "/bank"))
  259. iCommand = CMD_INFO
  260.  
  261. if(iCommand)
  262. {
  263. if(iCommand == CMD_INFO)
  264. Command_Info(id)
  265. else
  266. {
  267. new iValue = str_to_num(szArg2)
  268. if(iValue <= 0)
  269. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_INVALID_AMOUNT")
  270.  
  271. else if(iCommand == CMD_DEPOSIT)
  272. Command_Deposit(id, iValue)
  273. else
  274. Command_Withdraw(id, iValue)
  275. }
  276.  
  277. return PLUGIN_HANDLED
  278.  
  279. }
  280.  
  281. return PLUGIN_CONTINUE
  282. }
  283.  
  284. Command_Info(id)
  285. {
  286. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_LOAD", g_iAmmoPacks[id] + g_iSessionMovement[id], g_szAuth[id])
  287. }
  288.  
  289. Command_Deposit(id, iDeposit)
  290. {
  291. new iCurrentAmount = zp_get_user_ammo_packs(id)
  292. if(!iCurrentAmount)
  293. {
  294. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_NO_AMMO")
  295. return
  296. }
  297.  
  298. if(iDeposit > iCurrentAmount)
  299. iDeposit = iCurrentAmount
  300.  
  301. new iCurrent = g_iAmmoPacks[id] + g_iSessionMovement[id]
  302. new iSum = iCurrent + iDeposit
  303. new iBankMax = get_pcvar_num(cvBankMax)
  304.  
  305. if(iBankMax && iSum > iBankMax)
  306. {
  307. iDeposit = iBankMax - iCurrent
  308. iSum = iBankMax
  309.  
  310. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_MAX", iBankMax)
  311. }
  312.  
  313. if(iDeposit)
  314. {
  315. g_iSessionMovement[id] += iDeposit
  316.  
  317. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_DEPOSIT", iDeposit, iSum) //
  318. zp_set_user_ammo_packs(id, iCurrentAmount - iDeposit)
  319. }
  320. }
  321.  
  322.  
  323. Command_Withdraw(id, iWithdraw)
  324. {
  325. new iDeposited = g_iAmmoPacks[id] + g_iSessionMovement[id]
  326. if(!iDeposited)
  327. {
  328. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_EMPTY")
  329. return
  330. }
  331.  
  332. if(iWithdraw > iDeposited)
  333. iWithdraw = iDeposited
  334.  
  335. g_iSessionMovement[id] -= iWithdraw
  336.  
  337. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_WITHDRAW", iWithdraw, iDeposited - iWithdraw)
  338. zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) + iWithdraw)
  339. }


register_cvar("amx_sql_host", "127.0.0.1")
register_cvar("amx_sql_user", "root")
register_cvar("amx_sql_pass", "")
register_cvar("amx_sql_db", "amx")
register_cvar("amx_sql_type", "mysql")

Ehez több fájl nincs?

minek?

Ezt kell módositanom
register_cvar("amx_sql_host", "127.0.0.1")
register_cvar("amx_sql_user", "root")
register_cvar("amx_sql_pass", "")
register_cvar("amx_sql_db", "amx")
register_cvar("amx_sql_type", "mysql")?

_________________
Kép


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: ZP Bank
HozzászólásElküldve: 2013.03.30. 19:12 
Offline
Őskövület
Avatar

Csatlakozott: 2011.12.28. 00:35
Hozzászólások: 2736
Megköszönt másnak: 56 alkalommal
Megköszönték neki: 275 alkalommal
Tomos írta:
m0csy652 írta:
Tomos írta:
pixxa112 írta:
Tomos írta:
Valki zombi plague 4.3-ra tudna lineklni egy olyan bankot amiböl nem tünik el az ammó és aútómatikusan menti és ha feljön kiveszi magátol.


Próbáld SQL-el menteni:
SMA Forráskód: [ Mindet kijelol ]
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <zombieplague>
  4.  
  5. //#define USING_SQL
  6. #if defined USING_SQL
  7. #include <sqlx>
  8. #else
  9. #include <nvault>
  10. #endif
  11.  
  12. stock const ZP_BANK_FMT[] = "^x04[ZP-BANK]^x01 %L"
  13.  
  14. new g_iAmmoPacks[33]
  15. new g_iSessionMovement[33]
  16. new g_szAuth[33][36]
  17. new cvAnnounceTime
  18. new cvBankMax
  19.  
  20. #if defined USING_SQL
  21. new g_szSQLTable[64], Handle:g_hSQLTuple, g_szQuery[128]
  22.  
  23. LoadClient(id, szAuth[])
  24. {
  25. formatex(g_szQuery, charsmax(g_szQuery),
  26. "SELECT amount FROM `%s` WHERE auth='%s'",
  27. g_szSQLTable, szAuth)
  28.  
  29. new cData[37]
  30. cData[0] = id
  31. copy(cData[1], charsmax(cData)-1, szAuth)
  32.  
  33. SQL_ThreadQuery(g_hSQLTuple, "LoadClient_QueryHandler", g_szQuery, cData, strlen(cData[1]))
  34. }
  35.  
  36. public LoadClient_QueryHandler(iFailState, Handle:hQuery, szError[], iErrnum, cData[], iSize, Float:fQueueTime)
  37. {
  38. if(iFailState != TQUERY_SUCCESS)
  39. {
  40. log_amx("LoadClient(): SQL Error #%d - %s", iErrnum, szError)
  41. return
  42. }
  43.  
  44. new id = cData[0]
  45. static szAuth[36]
  46. copy(szAuth, charsmax(szAuth), cData[1])
  47.  
  48. new iAmmoPacks = 0
  49. if(SQL_NumResults(hQuery))
  50. iAmmoPacks = SQL_ReadResult(hQuery, 0)
  51. //SQL_QueryAndIgnore("INSERT INTO `%s` SET auth='%s'", g_szSQLTable, szAuth)
  52.  
  53. g_iAmmoPacks[id] = iAmmoPacks
  54.  
  55. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_LOAD", iAmmoPacks, szAuth)
  56. }
  57.  
  58. SaveClient(id, szAuth[])
  59. {
  60. new iDifference = g_iSessionMovement[id]
  61.  
  62. formatex(g_szQuery, charsmax(g_szQuery),
  63. "INSERT INTO `%s` SET auth='%s', amount=%d ON DUPLICATE KEY UPDATE amount=amount+(%d)",
  64. g_szSQLTable, szAuth, iDifference, iDifference)
  65.  
  66. SQL_ThreadQuery(g_hSQLTuple, "SaveClient_QueryHandler", g_szQuery)
  67. }
  68.  
  69. public SaveClient_QueryHandler(iFailState, Handle:hQuery, szError[], iErrnum, iData[], iSize, Float:fQueueTime)
  70. {
  71. if(iFailState != TQUERY_SUCCESS)
  72. log_amx("SaveClient(): SQL Error #%d - %s", iErrnum, szError)
  73. }
  74.  
  75. #else
  76. new g_hVault
  77.  
  78. LoadClient(id, szAuth[])
  79. {
  80. static szValue[32], iTimestamp
  81. new iValue = 0
  82. if(nvault_lookup(g_hVault, szAuth, szValue, charsmax(szValue), iTimestamp) && is_str_num(szValue))
  83. iValue = (g_iAmmoPacks[id] = str_to_num(szValue))
  84.  
  85. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_LOAD", iValue, szAuth)
  86. }
  87.  
  88. SaveClient(id, szAuth[])
  89. {
  90. static szValue[32]
  91. num_to_str(g_iAmmoPacks[id] + g_iSessionMovement[id], szValue, charsmax(szValue))
  92.  
  93. nvault_set(g_hVault, szAuth, szValue)
  94. }
  95. #endif
  96.  
  97. public plugin_init()
  98. {
  99. register_plugin("[ZP] Ammo Bank", "1.0", "danielkza")
  100.  
  101. register_clcmd("say", "Command_Say")
  102. register_dictionary("zp_bank.txt")
  103.  
  104. cvAnnounceTime = register_cvar("zp_bank_announce_time", "180")
  105. cvBankMax = register_cvar("zp_bank_max", "10000")
  106.  
  107. Task_Announce()
  108.  
  109. #if defined USING_SQL
  110. new configsDir[64]
  111. get_configsdir(configsDir, 63)
  112.  
  113. // Declare standard SQL cvars so we don't depend on admin.amxx
  114. register_cvar("amx_sql_host", "127.0.0.1")
  115. register_cvar("amx_sql_user", "root")
  116. register_cvar("amx_sql_pass", "")
  117. register_cvar("amx_sql_db", "amx")
  118. register_cvar("amx_sql_type", "mysql")
  119.  
  120. new cvTable = register_cvar("zp_bank_table", "zp_bank")
  121. // Execute SQL configs. You must put zp_bank_table in there
  122. server_cmd("exec %s/sql.cfg", configsDir)
  123. server_exec()
  124.  
  125. get_pcvar_string(cvTable, g_szSQLTable, charsmax(g_szSQLTable))
  126. g_hSQLTuple = SQL_MakeStdTuple()
  127.  
  128. new iError, szError[256]
  129. new Handle:hSQLConnection = SQL_Connect(g_hSQLTuple, iError, szError, charsmax(szError))
  130. if(hSQLConnection != Empty_Handle)
  131. {
  132. SQL_QueryAndIgnore(hSQLConnection,
  133. "CREATE TABLE IF NOT EXISTS `%s` (\
  134. auth VARCHAR(36) NOT NULL PRIMARY KEY, \
  135. amount INT(10) UNSIGNED NOT NULL DEFAULT 0 \
  136. ) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
  137. g_szSQLTable )
  138.  
  139. SQL_FreeHandle(hSQLConnection)
  140. }
  141. else
  142. log_amx("plugin_init(): SQL Error #%d - %s", iError, szError)
  143.  
  144. #else
  145. g_hVault = nvault_open("zp_bank")
  146. if(g_hVault == INVALID_HANDLE)
  147. set_fail_state("Can't create/load vault 'zp_bank'")
  148.  
  149. #endif
  150. }
  151.  
  152. public plugin_end()
  153. {
  154. // Client's should have already been saved by now (client_disconnect is called before plugin_end).
  155. // But it costs nothing to be sure.
  156. new iPlayers[32], iNum
  157. get_players(iPlayers, iNum)
  158.  
  159. new iPlayer
  160. for(new i=0; i < iNum;i++)
  161. {
  162. iPlayer = iPlayers[i]
  163. SaveClient(iPlayer, g_szAuth[iPlayer])
  164. }
  165.  
  166. #if defined USING_SQL
  167. SQL_FreeHandle(g_hSQLTuple)
  168.  
  169. #else
  170. nvault_close(g_hVault)
  171.  
  172. #endif
  173. }
  174.  
  175. public client_putinserver(id)
  176. {
  177. static szAuth[36]
  178. get_user_authid(id, szAuth, charsmax(szAuth))
  179. copy(g_szAuth[id], charsmax(g_szAuth[]), szAuth)
  180.  
  181. LoadClient(id, szAuth)
  182. }
  183.  
  184. public client_disconnect(id)
  185. {
  186. SaveClient(id, g_szAuth[id])
  187.  
  188. g_szAuth[id][0] = 0
  189. g_iAmmoPacks[id] = 0
  190. g_iSessionMovement[id] = 0
  191. }
  192.  
  193. new msgSayText = -1
  194. stock bool:SayText(const receiver, sender, const msg[], any:...)
  195. {
  196. if(msgSayText == -1)
  197. msgSayText = get_user_msgid("SayText")
  198.  
  199. if(msgSayText)
  200. {
  201. if(!sender)
  202. sender = receiver
  203.  
  204. static buffer[512]
  205. vformat(buffer,charsmax(buffer), msg, 4)
  206.  
  207. if(receiver)
  208. message_begin(MSG_ONE_UNRELIABLE,msgSayText,_,receiver)
  209. else
  210. message_begin(MSG_BROADCAST,msgSayText)
  211.  
  212. write_byte(sender)
  213. write_string(buffer)
  214. message_end()
  215.  
  216. return true
  217. }
  218.  
  219. return false
  220. }
  221.  
  222.  
  223. public Task_Announce()
  224. {
  225. static iPlayers[32], iNum, iPlayer
  226. get_players(iPlayers, iNum)
  227.  
  228. for(new i=0; i < iNum;i++)
  229. {
  230. iPlayer = iPlayers[i]
  231. SayText(iPlayer, iPlayer, ZP_BANK_FMT, LANG_PLAYER, "ZP_BANK_ANNOUNCE")
  232. }
  233.  
  234. set_task(get_pcvar_float(cvAnnounceTime), "Task_Announce")
  235. }
  236.  
  237. enum
  238. {
  239. CMD_DEPOSIT = 1,
  240. CMD_WITHDRAW,
  241. CMD_INFO
  242. }
  243.  
  244. public Command_Say(id)
  245. {
  246. static szArgs[32]
  247. read_args(szArgs, charsmax(szArgs))
  248. remove_quotes(szArgs)
  249.  
  250. static szArg1[32], szArg2[32]
  251. parse(szArgs, szArg1, charsmax(szArg1), szArg2, charsmax(szArg2))
  252.  
  253. new iCommand = 0
  254. if(equali(szArg1, "/berak"))
  255. iCommand = CMD_DEPOSIT
  256. else if(equali(szArg1, "/kivesz"))
  257. iCommand = CMD_WITHDRAW
  258. else if(equali(szArg1, "/bank"))
  259. iCommand = CMD_INFO
  260.  
  261. if(iCommand)
  262. {
  263. if(iCommand == CMD_INFO)
  264. Command_Info(id)
  265. else
  266. {
  267. new iValue = str_to_num(szArg2)
  268. if(iValue <= 0)
  269. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_INVALID_AMOUNT")
  270.  
  271. else if(iCommand == CMD_DEPOSIT)
  272. Command_Deposit(id, iValue)
  273. else
  274. Command_Withdraw(id, iValue)
  275. }
  276.  
  277. return PLUGIN_HANDLED
  278.  
  279. }
  280.  
  281. return PLUGIN_CONTINUE
  282. }
  283.  
  284. Command_Info(id)
  285. {
  286. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_LOAD", g_iAmmoPacks[id] + g_iSessionMovement[id], g_szAuth[id])
  287. }
  288.  
  289. Command_Deposit(id, iDeposit)
  290. {
  291. new iCurrentAmount = zp_get_user_ammo_packs(id)
  292. if(!iCurrentAmount)
  293. {
  294. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_NO_AMMO")
  295. return
  296. }
  297.  
  298. if(iDeposit > iCurrentAmount)
  299. iDeposit = iCurrentAmount
  300.  
  301. new iCurrent = g_iAmmoPacks[id] + g_iSessionMovement[id]
  302. new iSum = iCurrent + iDeposit
  303. new iBankMax = get_pcvar_num(cvBankMax)
  304.  
  305. if(iBankMax && iSum > iBankMax)
  306. {
  307. iDeposit = iBankMax - iCurrent
  308. iSum = iBankMax
  309.  
  310. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_MAX", iBankMax)
  311. }
  312.  
  313. if(iDeposit)
  314. {
  315. g_iSessionMovement[id] += iDeposit
  316.  
  317. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_DEPOSIT", iDeposit, iSum) //
  318. zp_set_user_ammo_packs(id, iCurrentAmount - iDeposit)
  319. }
  320. }
  321.  
  322.  
  323. Command_Withdraw(id, iWithdraw)
  324. {
  325. new iDeposited = g_iAmmoPacks[id] + g_iSessionMovement[id]
  326. if(!iDeposited)
  327. {
  328. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_EMPTY")
  329. return
  330. }
  331.  
  332. if(iWithdraw > iDeposited)
  333. iWithdraw = iDeposited
  334.  
  335. g_iSessionMovement[id] -= iWithdraw
  336.  
  337. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_WITHDRAW", iWithdraw, iDeposited - iWithdraw)
  338. zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) + iWithdraw)
  339. }


register_cvar("amx_sql_host", "127.0.0.1")
register_cvar("amx_sql_user", "root")
register_cvar("amx_sql_pass", "")
register_cvar("amx_sql_db", "amx")
register_cvar("amx_sql_type", "mysql")

Ehez több fájl nincs?

minek?

Ezt kell módositanom
register_cvar("amx_sql_host", "127.0.0.1")
register_cvar("amx_sql_user", "root")
register_cvar("amx_sql_pass", "")
register_cvar("amx_sql_db", "amx")
register_cvar("amx_sql_type", "mysql")?


Igen
de azt be is írhatod az amxx.cfgbe:
amx_sql_host "ip"
amx_sql_user felhasználó név")
amx_sql_pass "jelszó"
amx_sql_db "adatbázis"
amx_sql_type "mysql"

_________________
****


A hozzászólást 1 alkalommal szerkesztették, utoljára pixxa112 2013.03.30. 19:15-kor.

Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: ZP Bank
HozzászólásElküldve: 2013.03.30. 19:14 
Offline
Félisten

Csatlakozott: 2012.06.19. 15:12
Hozzászólások: 926
Megköszönt másnak: 109 alkalommal
Megköszönték neki: 31 alkalommal
pixxa112 írta:
Tomos írta:
m0csy652 írta:
Tomos írta:
pixxa112 írta:
Tomos írta:
Valki zombi plague 4.3-ra tudna lineklni egy olyan bankot amiböl nem tünik el az ammó és aútómatikusan menti és ha feljön kiveszi magátol.


Próbáld SQL-el menteni:
SMA Forráskód: [ Mindet kijelol ]
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <zombieplague>
  4.  
  5. //#define USING_SQL
  6. #if defined USING_SQL
  7. #include <sqlx>
  8. #else
  9. #include <nvault>
  10. #endif
  11.  
  12. stock const ZP_BANK_FMT[] = "^x04[ZP-BANK]^x01 %L"
  13.  
  14. new g_iAmmoPacks[33]
  15. new g_iSessionMovement[33]
  16. new g_szAuth[33][36]
  17. new cvAnnounceTime
  18. new cvBankMax
  19.  
  20. #if defined USING_SQL
  21. new g_szSQLTable[64], Handle:g_hSQLTuple, g_szQuery[128]
  22.  
  23. LoadClient(id, szAuth[])
  24. {
  25. formatex(g_szQuery, charsmax(g_szQuery),
  26. "SELECT amount FROM `%s` WHERE auth='%s'",
  27. g_szSQLTable, szAuth)
  28.  
  29. new cData[37]
  30. cData[0] = id
  31. copy(cData[1], charsmax(cData)-1, szAuth)
  32.  
  33. SQL_ThreadQuery(g_hSQLTuple, "LoadClient_QueryHandler", g_szQuery, cData, strlen(cData[1]))
  34. }
  35.  
  36. public LoadClient_QueryHandler(iFailState, Handle:hQuery, szError[], iErrnum, cData[], iSize, Float:fQueueTime)
  37. {
  38. if(iFailState != TQUERY_SUCCESS)
  39. {
  40. log_amx("LoadClient(): SQL Error #%d - %s", iErrnum, szError)
  41. return
  42. }
  43.  
  44. new id = cData[0]
  45. static szAuth[36]
  46. copy(szAuth, charsmax(szAuth), cData[1])
  47.  
  48. new iAmmoPacks = 0
  49. if(SQL_NumResults(hQuery))
  50. iAmmoPacks = SQL_ReadResult(hQuery, 0)
  51. //SQL_QueryAndIgnore("INSERT INTO `%s` SET auth='%s'", g_szSQLTable, szAuth)
  52.  
  53. g_iAmmoPacks[id] = iAmmoPacks
  54.  
  55. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_LOAD", iAmmoPacks, szAuth)
  56. }
  57.  
  58. SaveClient(id, szAuth[])
  59. {
  60. new iDifference = g_iSessionMovement[id]
  61.  
  62. formatex(g_szQuery, charsmax(g_szQuery),
  63. "INSERT INTO `%s` SET auth='%s', amount=%d ON DUPLICATE KEY UPDATE amount=amount+(%d)",
  64. g_szSQLTable, szAuth, iDifference, iDifference)
  65.  
  66. SQL_ThreadQuery(g_hSQLTuple, "SaveClient_QueryHandler", g_szQuery)
  67. }
  68.  
  69. public SaveClient_QueryHandler(iFailState, Handle:hQuery, szError[], iErrnum, iData[], iSize, Float:fQueueTime)
  70. {
  71. if(iFailState != TQUERY_SUCCESS)
  72. log_amx("SaveClient(): SQL Error #%d - %s", iErrnum, szError)
  73. }
  74.  
  75. #else
  76. new g_hVault
  77.  
  78. LoadClient(id, szAuth[])
  79. {
  80. static szValue[32], iTimestamp
  81. new iValue = 0
  82. if(nvault_lookup(g_hVault, szAuth, szValue, charsmax(szValue), iTimestamp) && is_str_num(szValue))
  83. iValue = (g_iAmmoPacks[id] = str_to_num(szValue))
  84.  
  85. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_LOAD", iValue, szAuth)
  86. }
  87.  
  88. SaveClient(id, szAuth[])
  89. {
  90. static szValue[32]
  91. num_to_str(g_iAmmoPacks[id] + g_iSessionMovement[id], szValue, charsmax(szValue))
  92.  
  93. nvault_set(g_hVault, szAuth, szValue)
  94. }
  95. #endif
  96.  
  97. public plugin_init()
  98. {
  99. register_plugin("[ZP] Ammo Bank", "1.0", "danielkza")
  100.  
  101. register_clcmd("say", "Command_Say")
  102. register_dictionary("zp_bank.txt")
  103.  
  104. cvAnnounceTime = register_cvar("zp_bank_announce_time", "180")
  105. cvBankMax = register_cvar("zp_bank_max", "10000")
  106.  
  107. Task_Announce()
  108.  
  109. #if defined USING_SQL
  110. new configsDir[64]
  111. get_configsdir(configsDir, 63)
  112.  
  113. // Declare standard SQL cvars so we don't depend on admin.amxx
  114. register_cvar("amx_sql_host", "127.0.0.1")
  115. register_cvar("amx_sql_user", "root")
  116. register_cvar("amx_sql_pass", "")
  117. register_cvar("amx_sql_db", "amx")
  118. register_cvar("amx_sql_type", "mysql")
  119.  
  120. new cvTable = register_cvar("zp_bank_table", "zp_bank")
  121. // Execute SQL configs. You must put zp_bank_table in there
  122. server_cmd("exec %s/sql.cfg", configsDir)
  123. server_exec()
  124.  
  125. get_pcvar_string(cvTable, g_szSQLTable, charsmax(g_szSQLTable))
  126. g_hSQLTuple = SQL_MakeStdTuple()
  127.  
  128. new iError, szError[256]
  129. new Handle:hSQLConnection = SQL_Connect(g_hSQLTuple, iError, szError, charsmax(szError))
  130. if(hSQLConnection != Empty_Handle)
  131. {
  132. SQL_QueryAndIgnore(hSQLConnection,
  133. "CREATE TABLE IF NOT EXISTS `%s` (\
  134. auth VARCHAR(36) NOT NULL PRIMARY KEY, \
  135. amount INT(10) UNSIGNED NOT NULL DEFAULT 0 \
  136. ) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
  137. g_szSQLTable )
  138.  
  139. SQL_FreeHandle(hSQLConnection)
  140. }
  141. else
  142. log_amx("plugin_init(): SQL Error #%d - %s", iError, szError)
  143.  
  144. #else
  145. g_hVault = nvault_open("zp_bank")
  146. if(g_hVault == INVALID_HANDLE)
  147. set_fail_state("Can't create/load vault 'zp_bank'")
  148.  
  149. #endif
  150. }
  151.  
  152. public plugin_end()
  153. {
  154. // Client's should have already been saved by now (client_disconnect is called before plugin_end).
  155. // But it costs nothing to be sure.
  156. new iPlayers[32], iNum
  157. get_players(iPlayers, iNum)
  158.  
  159. new iPlayer
  160. for(new i=0; i < iNum;i++)
  161. {
  162. iPlayer = iPlayers[i]
  163. SaveClient(iPlayer, g_szAuth[iPlayer])
  164. }
  165.  
  166. #if defined USING_SQL
  167. SQL_FreeHandle(g_hSQLTuple)
  168.  
  169. #else
  170. nvault_close(g_hVault)
  171.  
  172. #endif
  173. }
  174.  
  175. public client_putinserver(id)
  176. {
  177. static szAuth[36]
  178. get_user_authid(id, szAuth, charsmax(szAuth))
  179. copy(g_szAuth[id], charsmax(g_szAuth[]), szAuth)
  180.  
  181. LoadClient(id, szAuth)
  182. }
  183.  
  184. public client_disconnect(id)
  185. {
  186. SaveClient(id, g_szAuth[id])
  187.  
  188. g_szAuth[id][0] = 0
  189. g_iAmmoPacks[id] = 0
  190. g_iSessionMovement[id] = 0
  191. }
  192.  
  193. new msgSayText = -1
  194. stock bool:SayText(const receiver, sender, const msg[], any:...)
  195. {
  196. if(msgSayText == -1)
  197. msgSayText = get_user_msgid("SayText")
  198.  
  199. if(msgSayText)
  200. {
  201. if(!sender)
  202. sender = receiver
  203.  
  204. static buffer[512]
  205. vformat(buffer,charsmax(buffer), msg, 4)
  206.  
  207. if(receiver)
  208. message_begin(MSG_ONE_UNRELIABLE,msgSayText,_,receiver)
  209. else
  210. message_begin(MSG_BROADCAST,msgSayText)
  211.  
  212. write_byte(sender)
  213. write_string(buffer)
  214. message_end()
  215.  
  216. return true
  217. }
  218.  
  219. return false
  220. }
  221.  
  222.  
  223. public Task_Announce()
  224. {
  225. static iPlayers[32], iNum, iPlayer
  226. get_players(iPlayers, iNum)
  227.  
  228. for(new i=0; i < iNum;i++)
  229. {
  230. iPlayer = iPlayers[i]
  231. SayText(iPlayer, iPlayer, ZP_BANK_FMT, LANG_PLAYER, "ZP_BANK_ANNOUNCE")
  232. }
  233.  
  234. set_task(get_pcvar_float(cvAnnounceTime), "Task_Announce")
  235. }
  236.  
  237. enum
  238. {
  239. CMD_DEPOSIT = 1,
  240. CMD_WITHDRAW,
  241. CMD_INFO
  242. }
  243.  
  244. public Command_Say(id)
  245. {
  246. static szArgs[32]
  247. read_args(szArgs, charsmax(szArgs))
  248. remove_quotes(szArgs)
  249.  
  250. static szArg1[32], szArg2[32]
  251. parse(szArgs, szArg1, charsmax(szArg1), szArg2, charsmax(szArg2))
  252.  
  253. new iCommand = 0
  254. if(equali(szArg1, "/berak"))
  255. iCommand = CMD_DEPOSIT
  256. else if(equali(szArg1, "/kivesz"))
  257. iCommand = CMD_WITHDRAW
  258. else if(equali(szArg1, "/bank"))
  259. iCommand = CMD_INFO
  260.  
  261. if(iCommand)
  262. {
  263. if(iCommand == CMD_INFO)
  264. Command_Info(id)
  265. else
  266. {
  267. new iValue = str_to_num(szArg2)
  268. if(iValue <= 0)
  269. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_INVALID_AMOUNT")
  270.  
  271. else if(iCommand == CMD_DEPOSIT)
  272. Command_Deposit(id, iValue)
  273. else
  274. Command_Withdraw(id, iValue)
  275. }
  276.  
  277. return PLUGIN_HANDLED
  278.  
  279. }
  280.  
  281. return PLUGIN_CONTINUE
  282. }
  283.  
  284. Command_Info(id)
  285. {
  286. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_LOAD", g_iAmmoPacks[id] + g_iSessionMovement[id], g_szAuth[id])
  287. }
  288.  
  289. Command_Deposit(id, iDeposit)
  290. {
  291. new iCurrentAmount = zp_get_user_ammo_packs(id)
  292. if(!iCurrentAmount)
  293. {
  294. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_NO_AMMO")
  295. return
  296. }
  297.  
  298. if(iDeposit > iCurrentAmount)
  299. iDeposit = iCurrentAmount
  300.  
  301. new iCurrent = g_iAmmoPacks[id] + g_iSessionMovement[id]
  302. new iSum = iCurrent + iDeposit
  303. new iBankMax = get_pcvar_num(cvBankMax)
  304.  
  305. if(iBankMax && iSum > iBankMax)
  306. {
  307. iDeposit = iBankMax - iCurrent
  308. iSum = iBankMax
  309.  
  310. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_MAX", iBankMax)
  311. }
  312.  
  313. if(iDeposit)
  314. {
  315. g_iSessionMovement[id] += iDeposit
  316.  
  317. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_DEPOSIT", iDeposit, iSum) //
  318. zp_set_user_ammo_packs(id, iCurrentAmount - iDeposit)
  319. }
  320. }
  321.  
  322.  
  323. Command_Withdraw(id, iWithdraw)
  324. {
  325. new iDeposited = g_iAmmoPacks[id] + g_iSessionMovement[id]
  326. if(!iDeposited)
  327. {
  328. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_EMPTY")
  329. return
  330. }
  331.  
  332. if(iWithdraw > iDeposited)
  333. iWithdraw = iDeposited
  334.  
  335. g_iSessionMovement[id] -= iWithdraw
  336.  
  337. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_WITHDRAW", iWithdraw, iDeposited - iWithdraw)
  338. zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) + iWithdraw)
  339. }


register_cvar("amx_sql_host", "127.0.0.1")
register_cvar("amx_sql_user", "root")
register_cvar("amx_sql_pass", "")
register_cvar("amx_sql_db", "amx")
register_cvar("amx_sql_type", "mysql")

Ehez több fájl nincs?

minek?

Ezt kell módositanom
register_cvar("amx_sql_host", "127.0.0.1")
register_cvar("amx_sql_user", "root")
register_cvar("amx_sql_pass", "")
register_cvar("amx_sql_db", "amx")
register_cvar("amx_sql_type", "mysql")?


Igen
de azt be is írhatod az amxx.cfg.


És már próbáltam ilyet de sql en nem kell létrehozni valamit amibe menti?

_________________
Kép


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: ZP Bank
HozzászólásElküldve: 2013.03.30. 19:16 
Offline
Őskövület
Avatar

Csatlakozott: 2011.12.28. 00:35
Hozzászólások: 2736
Megköszönt másnak: 56 alkalommal
Megköszönték neki: 275 alkalommal
Tomos írta:
pixxa112 írta:
Tomos írta:
m0csy652 írta:
Tomos írta:
pixxa112 írta:
Tomos írta:
Valki zombi plague 4.3-ra tudna lineklni egy olyan bankot amiböl nem tünik el az ammó és aútómatikusan menti és ha feljön kiveszi magátol.


Próbáld SQL-el menteni:
SMA Forráskód: [ Mindet kijelol ]
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <zombieplague>
  4.  
  5. //#define USING_SQL
  6. #if defined USING_SQL
  7. #include <sqlx>
  8. #else
  9. #include <nvault>
  10. #endif
  11.  
  12. stock const ZP_BANK_FMT[] = "^x04[ZP-BANK]^x01 %L"
  13.  
  14. new g_iAmmoPacks[33]
  15. new g_iSessionMovement[33]
  16. new g_szAuth[33][36]
  17. new cvAnnounceTime
  18. new cvBankMax
  19.  
  20. #if defined USING_SQL
  21. new g_szSQLTable[64], Handle:g_hSQLTuple, g_szQuery[128]
  22.  
  23. LoadClient(id, szAuth[])
  24. {
  25. formatex(g_szQuery, charsmax(g_szQuery),
  26. "SELECT amount FROM `%s` WHERE auth='%s'",
  27. g_szSQLTable, szAuth)
  28.  
  29. new cData[37]
  30. cData[0] = id
  31. copy(cData[1], charsmax(cData)-1, szAuth)
  32.  
  33. SQL_ThreadQuery(g_hSQLTuple, "LoadClient_QueryHandler", g_szQuery, cData, strlen(cData[1]))
  34. }
  35.  
  36. public LoadClient_QueryHandler(iFailState, Handle:hQuery, szError[], iErrnum, cData[], iSize, Float:fQueueTime)
  37. {
  38. if(iFailState != TQUERY_SUCCESS)
  39. {
  40. log_amx("LoadClient(): SQL Error #%d - %s", iErrnum, szError)
  41. return
  42. }
  43.  
  44. new id = cData[0]
  45. static szAuth[36]
  46. copy(szAuth, charsmax(szAuth), cData[1])
  47.  
  48. new iAmmoPacks = 0
  49. if(SQL_NumResults(hQuery))
  50. iAmmoPacks = SQL_ReadResult(hQuery, 0)
  51. //SQL_QueryAndIgnore("INSERT INTO `%s` SET auth='%s'", g_szSQLTable, szAuth)
  52.  
  53. g_iAmmoPacks[id] = iAmmoPacks
  54.  
  55. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_LOAD", iAmmoPacks, szAuth)
  56. }
  57.  
  58. SaveClient(id, szAuth[])
  59. {
  60. new iDifference = g_iSessionMovement[id]
  61.  
  62. formatex(g_szQuery, charsmax(g_szQuery),
  63. "INSERT INTO `%s` SET auth='%s', amount=%d ON DUPLICATE KEY UPDATE amount=amount+(%d)",
  64. g_szSQLTable, szAuth, iDifference, iDifference)
  65.  
  66. SQL_ThreadQuery(g_hSQLTuple, "SaveClient_QueryHandler", g_szQuery)
  67. }
  68.  
  69. public SaveClient_QueryHandler(iFailState, Handle:hQuery, szError[], iErrnum, iData[], iSize, Float:fQueueTime)
  70. {
  71. if(iFailState != TQUERY_SUCCESS)
  72. log_amx("SaveClient(): SQL Error #%d - %s", iErrnum, szError)
  73. }
  74.  
  75. #else
  76. new g_hVault
  77.  
  78. LoadClient(id, szAuth[])
  79. {
  80. static szValue[32], iTimestamp
  81. new iValue = 0
  82. if(nvault_lookup(g_hVault, szAuth, szValue, charsmax(szValue), iTimestamp) && is_str_num(szValue))
  83. iValue = (g_iAmmoPacks[id] = str_to_num(szValue))
  84.  
  85. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_LOAD", iValue, szAuth)
  86. }
  87.  
  88. SaveClient(id, szAuth[])
  89. {
  90. static szValue[32]
  91. num_to_str(g_iAmmoPacks[id] + g_iSessionMovement[id], szValue, charsmax(szValue))
  92.  
  93. nvault_set(g_hVault, szAuth, szValue)
  94. }
  95. #endif
  96.  
  97. public plugin_init()
  98. {
  99. register_plugin("[ZP] Ammo Bank", "1.0", "danielkza")
  100.  
  101. register_clcmd("say", "Command_Say")
  102. register_dictionary("zp_bank.txt")
  103.  
  104. cvAnnounceTime = register_cvar("zp_bank_announce_time", "180")
  105. cvBankMax = register_cvar("zp_bank_max", "10000")
  106.  
  107. Task_Announce()
  108.  
  109. #if defined USING_SQL
  110. new configsDir[64]
  111. get_configsdir(configsDir, 63)
  112.  
  113. // Declare standard SQL cvars so we don't depend on admin.amxx
  114. register_cvar("amx_sql_host", "127.0.0.1")
  115. register_cvar("amx_sql_user", "root")
  116. register_cvar("amx_sql_pass", "")
  117. register_cvar("amx_sql_db", "amx")
  118. register_cvar("amx_sql_type", "mysql")
  119.  
  120. new cvTable = register_cvar("zp_bank_table", "zp_bank")
  121. // Execute SQL configs. You must put zp_bank_table in there
  122. server_cmd("exec %s/sql.cfg", configsDir)
  123. server_exec()
  124.  
  125. get_pcvar_string(cvTable, g_szSQLTable, charsmax(g_szSQLTable))
  126. g_hSQLTuple = SQL_MakeStdTuple()
  127.  
  128. new iError, szError[256]
  129. new Handle:hSQLConnection = SQL_Connect(g_hSQLTuple, iError, szError, charsmax(szError))
  130. if(hSQLConnection != Empty_Handle)
  131. {
  132. SQL_QueryAndIgnore(hSQLConnection,
  133. "CREATE TABLE IF NOT EXISTS `%s` (\
  134. auth VARCHAR(36) NOT NULL PRIMARY KEY, \
  135. amount INT(10) UNSIGNED NOT NULL DEFAULT 0 \
  136. ) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
  137. g_szSQLTable )
  138.  
  139. SQL_FreeHandle(hSQLConnection)
  140. }
  141. else
  142. log_amx("plugin_init(): SQL Error #%d - %s", iError, szError)
  143.  
  144. #else
  145. g_hVault = nvault_open("zp_bank")
  146. if(g_hVault == INVALID_HANDLE)
  147. set_fail_state("Can't create/load vault 'zp_bank'")
  148.  
  149. #endif
  150. }
  151.  
  152. public plugin_end()
  153. {
  154. // Client's should have already been saved by now (client_disconnect is called before plugin_end).
  155. // But it costs nothing to be sure.
  156. new iPlayers[32], iNum
  157. get_players(iPlayers, iNum)
  158.  
  159. new iPlayer
  160. for(new i=0; i < iNum;i++)
  161. {
  162. iPlayer = iPlayers[i]
  163. SaveClient(iPlayer, g_szAuth[iPlayer])
  164. }
  165.  
  166. #if defined USING_SQL
  167. SQL_FreeHandle(g_hSQLTuple)
  168.  
  169. #else
  170. nvault_close(g_hVault)
  171.  
  172. #endif
  173. }
  174.  
  175. public client_putinserver(id)
  176. {
  177. static szAuth[36]
  178. get_user_authid(id, szAuth, charsmax(szAuth))
  179. copy(g_szAuth[id], charsmax(g_szAuth[]), szAuth)
  180.  
  181. LoadClient(id, szAuth)
  182. }
  183.  
  184. public client_disconnect(id)
  185. {
  186. SaveClient(id, g_szAuth[id])
  187.  
  188. g_szAuth[id][0] = 0
  189. g_iAmmoPacks[id] = 0
  190. g_iSessionMovement[id] = 0
  191. }
  192.  
  193. new msgSayText = -1
  194. stock bool:SayText(const receiver, sender, const msg[], any:...)
  195. {
  196. if(msgSayText == -1)
  197. msgSayText = get_user_msgid("SayText")
  198.  
  199. if(msgSayText)
  200. {
  201. if(!sender)
  202. sender = receiver
  203.  
  204. static buffer[512]
  205. vformat(buffer,charsmax(buffer), msg, 4)
  206.  
  207. if(receiver)
  208. message_begin(MSG_ONE_UNRELIABLE,msgSayText,_,receiver)
  209. else
  210. message_begin(MSG_BROADCAST,msgSayText)
  211.  
  212. write_byte(sender)
  213. write_string(buffer)
  214. message_end()
  215.  
  216. return true
  217. }
  218.  
  219. return false
  220. }
  221.  
  222.  
  223. public Task_Announce()
  224. {
  225. static iPlayers[32], iNum, iPlayer
  226. get_players(iPlayers, iNum)
  227.  
  228. for(new i=0; i < iNum;i++)
  229. {
  230. iPlayer = iPlayers[i]
  231. SayText(iPlayer, iPlayer, ZP_BANK_FMT, LANG_PLAYER, "ZP_BANK_ANNOUNCE")
  232. }
  233.  
  234. set_task(get_pcvar_float(cvAnnounceTime), "Task_Announce")
  235. }
  236.  
  237. enum
  238. {
  239. CMD_DEPOSIT = 1,
  240. CMD_WITHDRAW,
  241. CMD_INFO
  242. }
  243.  
  244. public Command_Say(id)
  245. {
  246. static szArgs[32]
  247. read_args(szArgs, charsmax(szArgs))
  248. remove_quotes(szArgs)
  249.  
  250. static szArg1[32], szArg2[32]
  251. parse(szArgs, szArg1, charsmax(szArg1), szArg2, charsmax(szArg2))
  252.  
  253. new iCommand = 0
  254. if(equali(szArg1, "/berak"))
  255. iCommand = CMD_DEPOSIT
  256. else if(equali(szArg1, "/kivesz"))
  257. iCommand = CMD_WITHDRAW
  258. else if(equali(szArg1, "/bank"))
  259. iCommand = CMD_INFO
  260.  
  261. if(iCommand)
  262. {
  263. if(iCommand == CMD_INFO)
  264. Command_Info(id)
  265. else
  266. {
  267. new iValue = str_to_num(szArg2)
  268. if(iValue <= 0)
  269. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_INVALID_AMOUNT")
  270.  
  271. else if(iCommand == CMD_DEPOSIT)
  272. Command_Deposit(id, iValue)
  273. else
  274. Command_Withdraw(id, iValue)
  275. }
  276.  
  277. return PLUGIN_HANDLED
  278.  
  279. }
  280.  
  281. return PLUGIN_CONTINUE
  282. }
  283.  
  284. Command_Info(id)
  285. {
  286. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_LOAD", g_iAmmoPacks[id] + g_iSessionMovement[id], g_szAuth[id])
  287. }
  288.  
  289. Command_Deposit(id, iDeposit)
  290. {
  291. new iCurrentAmount = zp_get_user_ammo_packs(id)
  292. if(!iCurrentAmount)
  293. {
  294. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_NO_AMMO")
  295. return
  296. }
  297.  
  298. if(iDeposit > iCurrentAmount)
  299. iDeposit = iCurrentAmount
  300.  
  301. new iCurrent = g_iAmmoPacks[id] + g_iSessionMovement[id]
  302. new iSum = iCurrent + iDeposit
  303. new iBankMax = get_pcvar_num(cvBankMax)
  304.  
  305. if(iBankMax && iSum > iBankMax)
  306. {
  307. iDeposit = iBankMax - iCurrent
  308. iSum = iBankMax
  309.  
  310. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_MAX", iBankMax)
  311. }
  312.  
  313. if(iDeposit)
  314. {
  315. g_iSessionMovement[id] += iDeposit
  316.  
  317. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_DEPOSIT", iDeposit, iSum) //
  318. zp_set_user_ammo_packs(id, iCurrentAmount - iDeposit)
  319. }
  320. }
  321.  
  322.  
  323. Command_Withdraw(id, iWithdraw)
  324. {
  325. new iDeposited = g_iAmmoPacks[id] + g_iSessionMovement[id]
  326. if(!iDeposited)
  327. {
  328. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_EMPTY")
  329. return
  330. }
  331.  
  332. if(iWithdraw > iDeposited)
  333. iWithdraw = iDeposited
  334.  
  335. g_iSessionMovement[id] -= iWithdraw
  336.  
  337. SayText(id, id, ZP_BANK_FMT, id, "ZP_BANK_WITHDRAW", iWithdraw, iDeposited - iWithdraw)
  338. zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) + iWithdraw)
  339. }


register_cvar("amx_sql_host", "127.0.0.1")
register_cvar("amx_sql_user", "root")
register_cvar("amx_sql_pass", "")
register_cvar("amx_sql_db", "amx")
register_cvar("amx_sql_type", "mysql")

Ehez több fájl nincs?

minek?

Ezt kell módositanom
register_cvar("amx_sql_host", "127.0.0.1")
register_cvar("amx_sql_user", "root")
register_cvar("amx_sql_pass", "")
register_cvar("amx_sql_db", "amx")
register_cvar("amx_sql_type", "mysql")?


Igen
de azt be is írhatod az amxx.cfg.


És már próbáltam ilyet de sql en nem kell létrehozni valamit amibe menti?


Nem tudok róla.

_________________
****


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: ZP Bank
HozzászólásElküldve: 2013.03.30. 21:10 
Offline
Minden6ó
Avatar

Csatlakozott: 2011.01.19. 12:14
Hozzászólások: 4280
Megköszönt másnak: 218 alkalommal
Megköszönték neki: 285 alkalommal
De létre kell hozni egy táblát, de valamelyik magától létre hoza a táblát.

_________________
<<eb@>>Team Website - Közösség
17Buddies - Általam készített pályák.
GameBanana - Általam készített pályák/vágott hangok.

Kép
Kép


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: ZP Bank
HozzászólásElküldve: 2013.03.30. 21:16 
Offline
Félisten

Csatlakozott: 2012.06.19. 15:12
Hozzászólások: 926
Megköszönt másnak: 109 alkalommal
Megköszönték neki: 31 alkalommal
norbee.16 írta:
De létre kell hozni egy táblát, de valamelyik magától létre hoza a táblát.

Azt hogy kell létre hozni?

_________________
Kép


Hozzászólás jelentése
Vissza a tetejére
   
Hozzászólások megjelenítése:  Rendezés  
Új téma nyitása  Hozzászólás a témához  [ 23 hozzászólás ]  Oldal 1 2 3 Következő


Ki van itt

Jelenlévő fórumozók: nincs regisztrált felhasználó valamint 70 vendég


Nyithatsz új témákat ebben a fórumban.
Válaszolhatsz egy témára ebben a fórumban.
Nem szerkesztheted a hozzászólásaidat ebben a fórumban.
Nem törölheted a hozzászólásaidat ebben a fórumban.
Nem küldhetsz csatolmányokat ebben a fórumban.

Keresés:
Ugrás:  
Powered by phpBB® Forum Software © phpBB Limited
Magyar fordítás © Magyar phpBB Közösség
Portal: Kiss Portal Extension © Michael O'Toole