hlmod.hu

Magyar Half-Life Mód közösség!
Pontos idő: 2025.06.17. 11:03



Jelenlévő felhasználók

Jelenleg 359 felhasználó van jelen :: 2 regisztrált, 0 rejtett és 357 vendég

A legtöbb felhasználó (2761 fő) 2025.01.09. 20:06-kor tartózkodott itt.

Regisztrált felhasználók: Bing [Bot], Google [Bot]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  [1 hozzászólás ] 
Szerző Üzenet
 Hozzászólás témája: Furien shop
HozzászólásElküldve:2013.07.14. 18:39 
Offline
Jómunkásember
Avatar

Csatlakozott:2012.11.14. 15:20
Hozzászólások:449
Megköszönt másnak: 80 alkalommal
Megköszönték neki: 19 alkalommal
Hi!
Ezt a plugint valaki megírná nekem úgy hogy pontért kelljen vásárolni, pontot pedig úgy lehet szerezni hogy ölsz.
Sima ölés = 1pont
Hs ölés = 2pont

előre is köszi :)
SMA Forráskód: [ Mindet kijelol ]
  1. /* Formatright © 2010, ConnorMcLeod
  2.  
  3. Furien Shop is free software;
  4. you can redistribute it and/or modify it under the terms of the
  5. GNU General Public License as published by the Free Software Foundation.
  6.  
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11.  
  12. You should have received a copy of the GNU General Public License
  13. along with Furien Shop; if not, write to the
  14. Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  15. Boston, MA 02111-1307, USA.
  16. */
  17.  
  18. #define ITEMS_PER_PAGE 7 // 7 max
  19.  
  20. #include <amxmodx>
  21. #include <cstrike>
  22.  
  23. #include "furien.inc"
  24. #include "furien_shop.inc"
  25.  
  26. #define szPickAmmoSound "items/9mmclip1.wav"
  27.  
  28. enum _:ItemDatas {
  29. szItemFurienName[32],
  30. iItemFurienCost,
  31. szItemAntiName[32],
  32. iItemAntiCost,
  33. iItemForwardIndex,
  34. iItemExtraArg
  35. }
  36.  
  37. enum ( <<= 1 )
  38. {
  39. ShouldBeInBuyZone = 1,
  40. ShouldBeInBuyTime
  41. }
  42.  
  43. #define HUD_PRINTCENTER 4
  44.  
  45. new g_iBlinkAcct, g_iTextMsg, g_iShowMenu
  46.  
  47. new Array:g_aItems
  48.  
  49. //new CsTeams:g_iFurienTeam = CS_TEAM_T
  50.  
  51. #define MAX_PLAYERS 32
  52. new g_iMenuPage[MAX_PLAYERS+1]
  53.  
  54. new g_iBuyType, g_pCvarBuyTime
  55.  
  56. new g_iShopMenu
  57.  
  58. new bool:g_bFreezeTime = true, bool:g_bBuyTime = true
  59. new bool:g_bSwitchTime
  60. new Float:g_flRoundStartGameTime
  61.  
  62. public plugin_init()
  63. {
  64. register_plugin("Furien Shop", FURIEN_VERSION, "ConnorMcLeod")
  65.  
  66. register_dictionary("common.txt")
  67.  
  68. new pCvar = register_cvar("furien_shop_version", FURIEN_VERSION, FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_SPONLY)
  69. set_pcvar_string(pCvar, FURIEN_VERSION)
  70.  
  71. ReadCfgFile()
  72.  
  73. if( g_iBuyType & ShouldBeInBuyZone )
  74. {
  75. register_event("StatusIcon", "Event_StatusIcon_OutOfBuyZone", "b", "1=0", "2=buyzone")
  76. }
  77.  
  78. register_event("HLTV", "Event_HLTV_New_Round", "a", "1=0", "2=0")
  79. register_logevent("LogEvent_Round_Start", 2, "1=Round_Start")
  80.  
  81. register_clcmd("shop", "ClientCommand_Shop")
  82. register_clcmd("say shop", "ClientCommand_Shop")
  83. register_clcmd("say_team shop", "ClientCommand_Shop")
  84. register_clcmd("buy", "ClientCommand_Shop")
  85.  
  86. register_menucmd( (g_iShopMenu = register_menuid("Furien Shop")) , 1023, "ShopMenuAction")
  87.  
  88. g_iBlinkAcct = get_user_msgid("BlinkAcct")
  89. g_iTextMsg = get_user_msgid("TextMsg")
  90. g_iShowMenu = get_user_msgid("ShowMenu")
  91. g_pCvarBuyTime = get_cvar_pointer("mp_buytime")
  92. }
  93.  
  94. ReadCfgFile()
  95. {
  96. new szConfigFile[128]
  97. get_localinfo("amxx_configsdir", szConfigFile, charsmax(szConfigFile))
  98. format(szConfigFile, charsmax(szConfigFile), "%s/furien/shop.ini", szConfigFile);
  99.  
  100. new fp = fopen(szConfigFile, "rt")
  101. if( !fp )
  102. {
  103. return
  104. }
  105.  
  106. new szDatas[32], szKey[16], szValue[16]
  107. while( !feof(fp) )
  108. {
  109. fgets(fp, szDatas, charsmax(szDatas))
  110. trim(szDatas)
  111. if(!szDatas[0] || szDatas[0] == ';' || szDatas[0] == '#' || (szDatas[0] == '/' && szDatas[1] == '/'))
  112. {
  113. continue
  114. }
  115.  
  116. parse(szDatas, szKey, charsmax(szKey), szValue, charsmax(szValue))
  117.  
  118. switch( szKey[0] )
  119. {
  120. case 'B':
  121. {
  122. if( equal(szKey, "BUY_TYPE" ) )
  123. {
  124. g_iBuyType = str_to_num(szValue)
  125. }
  126. }
  127. }
  128. }
  129. fclose( fp )
  130. }
  131.  
  132. public plugin_precache()
  133. {
  134. precache_sound(szPickAmmoSound)
  135. }
  136.  
  137. public Event_HLTV_New_Round()
  138. {
  139. g_bFreezeTime = true
  140. g_bBuyTime = true
  141. g_bSwitchTime = false
  142. }
  143.  
  144. public LogEvent_Round_Start()
  145. {
  146. g_bFreezeTime = false
  147. g_bBuyTime = true
  148. g_bSwitchTime = false
  149. g_flRoundStartGameTime = get_gametime()
  150. }
  151.  
  152. bool:bIsBuyTime( id = 0 )
  153. {
  154. new Float:flBuyTime
  155. if( !g_bFreezeTime
  156. && ( !g_bBuyTime || !(g_bBuyTime = get_gametime() < g_flRoundStartGameTime + (flBuyTime = get_buytime_value() * 60.0)) ) )
  157. {
  158. if( id )
  159. {
  160. new szBuyTime[3]
  161. float_to_str(flBuyTime, szBuyTime, charsmax(szBuyTime))
  162. Util_ClientPrint(id, HUD_PRINTCENTER, "#Cant_buy", szBuyTime)
  163. }
  164. return false
  165. }
  166. return true
  167. }
  168.  
  169. Float:get_buytime_value()
  170. {
  171. new Float:flBuyTime = get_pcvar_float(g_pCvarBuyTime)
  172. if( flBuyTime < 0.25 )
  173. {
  174. set_pcvar_float(g_pCvarBuyTime, 0.25)
  175. flBuyTime = 0.25
  176. }
  177. if( flBuyTime > 1.5 )
  178. {
  179. set_pcvar_float(g_pCvarBuyTime, 1.5)
  180. flBuyTime = 1.5
  181. }
  182. return flBuyTime
  183. }
  184.  
  185. public furien_team_change(/* iNewTeam */)
  186. {
  187. g_bSwitchTime = true
  188. // g_iFurienTeam = CsTeams:iNewTeam
  189.  
  190. new iPlayers[32], iNum
  191. get_players(iPlayers, iNum, "a")
  192. for(new i; i<iNum; i++)
  193. {
  194. CheckMenuClose(iPlayers[i])
  195. }
  196. }
  197.  
  198. public Event_StatusIcon_OutOfBuyZone( id )
  199. {
  200. CheckMenuClose(id)
  201. }
  202.  
  203. CheckMenuClose(id)
  204. {
  205. new iMenu, iKeys
  206. get_user_menu(id, iMenu, iKeys)
  207. if( iMenu == g_iShopMenu )
  208. {
  209. message_begin(MSG_ONE, g_iShowMenu, .player=id)
  210. {
  211. write_short(0)
  212. write_char(0)
  213. write_byte(0)
  214. write_string("")
  215. }
  216. message_end()
  217. }
  218. }
  219.  
  220. public plugin_end()
  221. {
  222. if( g_aItems != Invalid_Array )
  223. {
  224. ArrayDestroy( g_aItems )
  225. }
  226. }
  227.  
  228. public plugin_natives()
  229. {
  230. register_library("furien_shop")
  231. register_native("furien_register_item", "fr_register_item")
  232. register_native("furien_try_buy", "fr_try_buy")
  233. }
  234.  
  235. public fr_register_item(iPlugin/*, iParams*/)
  236. {
  237. CheckArrayExists()
  238.  
  239. new mDatas[ItemDatas], szCallBack[32]
  240.  
  241. get_string(1, mDatas[szItemFurienName], charsmax(mDatas[szItemFurienName]))
  242. mDatas[iItemFurienCost] = get_param(2)
  243.  
  244. get_string(3, mDatas[szItemAntiName], charsmax(mDatas[szItemAntiName]))
  245. mDatas[iItemAntiCost] = get_param(4)
  246.  
  247. get_string(5, szCallBack, charsmax(szCallBack))
  248. mDatas[iItemForwardIndex] = CreateOneForward(iPlugin, szCallBack, FP_CELL, FP_CELL)
  249.  
  250. mDatas[iItemExtraArg] = get_param(6)
  251. /*
  252. server_print("%s %d | %s %d | %s | %d",
  253. mDatas[szItemFurienName], mDatas[iItemFurienCost],
  254. mDatas[szItemAntiName], mDatas[iItemAntiCost],
  255. szCallBack, mDatas[iItemExtraArg])
  256. */
  257. ArrayPushArray(g_aItems, mDatas)
  258.  
  259. return mDatas[iItemForwardIndex]
  260. }
  261.  
  262. public fr_try_buy(/*iPlugin, iParams*/)
  263. {
  264. new id = get_param(1)
  265. new iCost = get_param(2)
  266.  
  267. new iNewMoney = cs_get_user_money(id) - iCost
  268.  
  269. if( iNewMoney < 0 )
  270. {
  271. return 0
  272. }
  273.  
  274. cs_set_user_money(id, iNewMoney, 1)
  275. return 1
  276. }
  277.  
  278. CheckArrayExists()
  279. {
  280. if( g_aItems == Invalid_Array )
  281. {
  282. g_aItems = ArrayCreate(ItemDatas)
  283. }
  284. }
  285.  
  286. public ClientCommand_Shop( id )
  287. {
  288. if( !g_bSwitchTime && is_user_alive(id) )
  289. {
  290. if( !bCanBuy( id ) )
  291. {
  292. return PLUGIN_HANDLED_MAIN
  293. }
  294.  
  295. g_iMenuPage[id] = 0
  296. ShowShopMenu(id)
  297. return PLUGIN_CONTINUE
  298. }
  299.  
  300. return PLUGIN_HANDLED_MAIN
  301. }
  302.  
  303. bCanBuy( id )
  304. {
  305. if( ( g_iBuyType & ShouldBeInBuyZone && !cs_get_user_buyzone(id) )
  306. || ( g_iBuyType & ShouldBeInBuyTime && !bIsBuyTime(id) ) )
  307. {
  308. return false
  309. }
  310.  
  311. return true
  312. }
  313.  
  314. ShowShopMenu(id)
  315. {
  316. new iTeam = furien_get_user_team(id)
  317. new iItemNums = ArraySize(g_aItems)
  318. new iPage = g_iMenuPage[id]
  319. new iPages = (iItemNums / ITEMS_PER_PAGE) + _:!!(iItemNums % ITEMS_PER_PAGE) - 1
  320. new iStart = ITEMS_PER_PAGE * iPage
  321. new iStop = min(iStart + ITEMS_PER_PAGE, iItemNums)
  322.  
  323. new szMenu[1024], n, mDatas[ItemDatas], iKeys
  324.  
  325. n += formatex(szMenu[n], charsmax(szMenu)-n, "\rFurien Shop\w^n^n")
  326.  
  327. new i, iCost
  328. for(i=iStart; i<iStop; i++)
  329. {
  330. ArrayGetArray(g_aItems, i, mDatas)
  331. iCost = mDatas[iTeam == Furien ? iItemFurienCost : iItemAntiCost]
  332. if( iCost <= 0 )
  333. {
  334. n += formatex(szMenu[n], charsmax(szMenu)-n, "\d-. %s\w^n", mDatas[iTeam == Furien ? szItemFurienName : szItemAntiName])
  335. }
  336. else
  337. // if( iCost > 0 )
  338. {
  339. iKeys |= 1<<(i-iStart)
  340. n += formatex(szMenu[n], charsmax(szMenu)-n, "%d. %s \R\y$%d\w^n", i+1-iStart, mDatas[iTeam == Furien ? szItemFurienName : szItemAntiName], iCost)
  341. }
  342. }
  343.  
  344. new j = iStop - iStart
  345. while( j++ < ITEMS_PER_PAGE )
  346. {
  347. n += formatex(szMenu[n], charsmax(szMenu)-n, "^n")
  348. }
  349.  
  350. if( i+1-iStart == 1 )
  351. {
  352. n += formatex(szMenu[n], charsmax(szMenu)-n, "^n")
  353. }
  354.  
  355. if( iPage > 0 )
  356. {
  357. iKeys |= 1<<7
  358. n += formatex(szMenu[n], charsmax(szMenu)-n, "^n8. %L", id, "BACK")
  359. }
  360. else
  361. {
  362. n += formatex(szMenu[n], charsmax(szMenu)-n, "^n")
  363. }
  364.  
  365. if( iPages > iPage )
  366. {
  367. iKeys |= 1<<8
  368. n += formatex(szMenu[n], charsmax(szMenu)-n, "^n9. %L", id, "MORE")
  369. }
  370. else
  371. {
  372. n += formatex(szMenu[n], charsmax(szMenu)-n, "^n")
  373. }
  374.  
  375. iKeys |= 1<<9
  376. n += formatex(szMenu[n], charsmax(szMenu)-n, "^n^n0. %L", id, "EXIT")
  377.  
  378. show_menu(id, iKeys, szMenu, -1, "Furien Shop")
  379. }
  380.  
  381. public ShopMenuAction(id, iKey)
  382. {
  383. if( is_user_alive(id) )
  384. {
  385. if( !bCanBuy( id ) )
  386. {
  387. return PLUGIN_HANDLED
  388. }
  389.  
  390. new iItemNums = ArraySize(g_aItems)
  391. new iPages = (iItemNums / ITEMS_PER_PAGE) + (iItemNums % ITEMS_PER_PAGE) - 1
  392.  
  393. switch( iKey )
  394. {
  395. case 7:
  396. {
  397. if( --g_iMenuPage[id] < 0 )
  398. {
  399. g_iMenuPage[id] = 0
  400. }
  401. ShowShopMenu(id)
  402. }
  403. case 8:
  404. {
  405. if( ++g_iMenuPage[id] > iPages )
  406. {
  407. g_iMenuPage[id] = iPages
  408. }
  409. ShowShopMenu(id)
  410. }
  411. case 9:
  412. {
  413. return PLUGIN_HANDLED
  414. }
  415. default:
  416. {
  417. iKey += ( g_iMenuPage[id] * ITEMS_PER_PAGE )
  418. new mDatas[ItemDatas]
  419. ArrayGetArray(g_aItems, iKey, mDatas)
  420.  
  421. new iRet
  422. ExecuteForward(mDatas[iItemForwardIndex], iRet, id, mDatas[iItemExtraArg])
  423. switch( iRet )
  424. {
  425. case ShopBought:
  426. {
  427. emit_sound(id, CHAN_ITEM, szPickAmmoSound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  428. return PLUGIN_HANDLED
  429. }
  430. case ShopTeamNotAvail:
  431. {
  432. Util_ClientPrint
  433. (
  434. id,
  435. HUD_PRINTCENTER,
  436. "#Alias_Not_Avail",
  437. mDatas[ furien_get_user_team(id) == Furien ? szItemFurienName : szItemAntiName ]
  438. )
  439. }
  440. case ShopNotEnoughMoney:
  441. {
  442. client_print(id, print_center, "#Cstrike_TitlesTXT_Not_Enough_Money")
  443.  
  444. message_begin(MSG_ONE_UNRELIABLE, g_iBlinkAcct, .player=id)
  445. {
  446. write_byte(2)
  447. }
  448. message_end()
  449. }
  450. case ShopAlreadyHaveOne:
  451. {
  452. client_print(id, print_center, "#Cstrike_TitlesTXT_Already_Have_One")
  453. }
  454. case ShopCantCarryAnymore:
  455. {
  456. client_print(id, print_center, "#Cstrike_TitlesTXT_Cannot_Carry_Anymore")
  457. }
  458. case ShopCannotBuyThis:
  459. {
  460. client_print(id, print_center, "#Cstrike_TitlesTXT_Cannot_Buy_This")
  461. }
  462. case ShopCloseMenu:
  463. {
  464. return PLUGIN_HANDLED
  465. }
  466. }
  467. ShowShopMenu(id)
  468. }
  469. }
  470. }
  471. return PLUGIN_HANDLED
  472. }
  473.  
  474. // Only submessage1 is used but fully implemented for example.
  475. // Based on HLSDK ClientPrint and UTIL_ClientPrintAll from util.cpp
  476. Util_ClientPrint(id, iMsgDest, szMessage[], szSubMessage1[] = "", szSubMessage2[] = "", szSubMessage3[] = "", szSubMessage4[] = "")
  477. {
  478. message_begin(id ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, g_iTextMsg, .player=id)
  479. {
  480. write_byte(iMsgDest)
  481. write_string(szMessage)
  482. if( szSubMessage1[0] )
  483. {
  484. write_string(szSubMessage1)
  485. }
  486. if( szSubMessage2[0] )
  487. {
  488. write_string(szSubMessage2)
  489. }
  490. if( szSubMessage3[0] )
  491. {
  492. write_string(szSubMessage3)
  493. }
  494. if( szSubMessage4[0] )
  495. {
  496. write_string(szSubMessage4)
  497. }
  498. }
  499. message_end()
  500. }
  501.  
  502. ////// client_print //////
  503. // #Cstrike_TitlesTXT_Cannot_Buy_This "You cannot buy this item!"
  504. // #Cstrike_TitlesTXT_Cannot_Carry_Anymore "You cannot carry anymore!"
  505. // #Cstrike_Already_Own_Weapon "You already own that weapon."
  506. // #Cstrike_TitlesTXT_Weapon_Not_Available "This weapon is not available to you!"
  507. // #Cstrike_TitlesTXT_Not_Enough_Money "You have insufficient funds!"
  508. // #Cstrike_TitlesTXT_CT_cant_buy "CTs aren't allowed to buy"
  509. // #Cstrike_TitlesTXT_Terrorist_cant_buy "Terrorists aren't allowed to buy anything on this map!"
  510. // #Cstrike_TitlesTXT_VIP_cant_buy "You are the VIP. You can't buy anything!"
  511.  
  512. ////// Util_ClientPrint ///////
  513. // #Cstrike_TitlesTXT_Alias_Not_Avail + szWeapon "The \"%s1\"is not available for your team to buy."
  514. // #Cstrike_TitlesTXT_Cant_buy + szSeconds "%s1 seconds have passed. You can't buy anything now!"
  515.  


*edit: a pontokat vaultba mentse

_________________
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  [1 hozzászólás ] 


Ki van itt

Jelenlévő fórumozók: nincs regisztrált felhasználó valamint 4 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