hlmod.hu
https://hlmod.hu/

Fegyver lőszermennyiségének módosítása
https://hlmod.hu/viewtopic.php?f=46&t=10884
Oldal: 1 / 1

Szerző:  Alnilam [ 2013.09.15. 11:24 ]
Hozzászólás témája:  Fegyver lőszermennyiségének módosítása

Megtaláltam a plugint amivel meglehet változtatni az egyszerre kitunkolható lőszer mennyiséget.
Csatolom a topickhoz.
Tehát pl. egy M4-ben 50/130 golyó van.
Viszont van egy olyan hibája, hogy az 50/130 az csak egy tárcseréig működik :(
Ergo, ha kilövőm azt az 50 golyót vagy töltök egyet utána már csak 30/110 töltény van benne és nem 50/80.
Ezt kellene kiküszöbölni, hogy töltés után is annyi lőszer legyen benne amennyit én beállítok.

Kép:
[ablak]Kép[/ablak]

Csatolmányok:
weapon_ammo.zip [1.85 KiB]
Letöltve 26 alkalommal.

Szerző:  CrB [ 2013.09.15. 20:37 ]
Hozzászólás témája:  Re: Fegyver lőszermennyiségének módosítása

teszteld
SMX Forráskód: [ Mindet kijelol ]
  1. #pragma semicolon 1
  2.  
  3. #include <sourcemod>
  4. #include <sdktools_functions>
  5.  
  6. public Plugin:myinfo =
  7. {
  8. name = "weapon_ammo",
  9. author = "wS / Schmidt",
  10. description = "",
  11. version = "1.0",
  12. url = "http://world-source.ru/"
  13. };
  14.  
  15. new Handle:g_Trie = INVALID_HANDLE;
  16.  
  17. public OnPluginStart()
  18. {
  19.  
  20. new Handle:kv = CreateKeyValues("weapon_ammo");
  21. if (!FileToKeyValues(kv, "cfg/weapon_ammo.txt") || !KvGotoFirstSubKey(kv))
  22. {
  23. CloseHandle(kv);
  24. SetFailState("cfg/weapon_ammo.txt not found or empty (or bad syntax / charset)");
  25. return;
  26. }
  27. HookEvent("weapon_reload", ClientWeaponReload);
  28. g_Trie = CreateTrie();
  29. decl String:item[20], ammo[2];
  30. do
  31. {
  32. if (KvGetSectionName(kv, item, 20))
  33. {
  34. ammo[0] = KvGetNum(kv, "ammo"); ammo[1] = KvGetNum(kv, "reserve");
  35. SetTrieArray(g_Trie, item, ammo, 2);
  36. }
  37. }
  38. while (KvGotoNextKey(kv));
  39. CloseHandle(kv);
  40.  
  41. if (GetTrieSize(g_Trie) < 1) SetFailState("cfg/weapon_ammo.txt empty");
  42. }
  43.  
  44. public Action:CS_OnBuyCommand(client, const String:item[])
  45. {
  46. decl ammo[2];
  47. if (GetTrieArray(g_Trie, item, ammo, 2))
  48. {
  49. new Handle:pack;
  50. CreateDataTimer(0.1, wS_Function, pack);
  51. WritePackCell(pack, client);
  52. WritePackString(pack, item);
  53. WritePackCell(pack, ammo[0]);
  54. WritePackCell(pack, ammo[1]);
  55. }
  56. return Plugin_Continue;
  57. }
  58.  
  59. public ClientWeaponReload(Handle:event, const String:name[], bool:dontBroadcast)
  60. {
  61. new Handle:pack;
  62. CreateDataTimer(0.1, wS_Function, pack);
  63. }
  64.  
  65. public Action:wS_Function(Handle:timer, Handle:pack)
  66. {
  67. ResetPack(pack);
  68. new client = ReadPackCell(pack);
  69. if (IsClientInGame(client) && IsPlayerAlive(client))
  70. {
  71. decl String:weapon[25], String:class[25], index;
  72. ReadPackString(pack, weapon, 25);
  73. Format(weapon, 25, "weapon_%s", weapon);
  74.  
  75. for (new slot = 0; slot < 2; slot++)
  76. {
  77. if ((index = GetPlayerWeaponSlot(client, slot)) > 0 && GetEntityClassname(index, class, 25) && strcmp(class, weapon) == 0)
  78. {
  79. new m_iPrimaryAmmoType = -1;
  80. if ((m_iPrimaryAmmoType = GetEntProp(index, Prop_Send, "m_iPrimaryAmmoType")) != -1)
  81. {
  82. SetEntProp(index, Prop_Send, "m_iClip1", ReadPackCell(pack));
  83. SetEntProp(client, Prop_Send, "m_iAmmo", ReadPackCell(pack), _, m_iPrimaryAmmoType);
  84. }
  85. break;
  86. }
  87. }
  88. }
  89. }

Szerző:  Alnilam [ 2013.09.15. 21:30 ]
Hozzászólás témája:  Re: Fegyver lőszermennyiségének módosítása

Sajnos a probléma továbbra is fent áll.
Annyi különbséggel, hogy csinál egy ilyen ronda error-t.
[ablak]
SMX Forráskód: [ Mindet kijelol ]
  1. L 09/15/2013 - 21:16:23: [SM] [0] Line 68, loszer.sp::wS_Function()
  2. L 09/15/2013 - 21:16:23: [SM] Native "ReadPackCell" reported: DataPack operation is out of bounds.
[/ablak]

Szerző:  CrB [ 2013.09.17. 21:16 ]
Hozzászólás témája:  Re: Fegyver lőszermennyiségének módosítása

Ha így se jó akkor sajnos nemtudom :S
SMX Forráskód: [ Mindet kijelol ]
  1. #pragma semicolon 1
  2.  
  3. #include <sourcemod>
  4. #include <sdktools_functions>
  5.  
  6. public Plugin:myinfo =
  7. {
  8. name = "weapon_ammo",
  9. author = "wS / Schmidt",
  10. description = "",
  11. version = "1.0",
  12. url = "http://world-source.ru/"
  13. };
  14.  
  15. new Handle:g_Trie = INVALID_HANDLE;
  16.  
  17. public OnPluginStart()
  18. {
  19.  
  20. new Handle:kv = CreateKeyValues("weapon_ammo");
  21. if (!FileToKeyValues(kv, "cfg/weapon_ammo.txt") || !KvGotoFirstSubKey(kv))
  22. {
  23. CloseHandle(kv);
  24. SetFailState("cfg/weapon_ammo.txt not found or empty (or bad syntax / charset)");
  25. return;
  26. }
  27. HookEvent("weapon_reload", ClientWeaponReload);
  28. g_Trie = CreateTrie();
  29. decl String:item[20], ammo[2];
  30. do
  31. {
  32. if (KvGetSectionName(kv, item, 20))
  33. {
  34. ammo[0] = KvGetNum(kv, "ammo"); ammo[1] = KvGetNum(kv, "reserve");
  35. SetTrieArray(g_Trie, item, ammo, 2);
  36. }
  37. }
  38. while (KvGotoNextKey(kv));
  39. CloseHandle(kv);
  40.  
  41. if (GetTrieSize(g_Trie) < 1) SetFailState("cfg/weapon_ammo.txt empty");
  42. }
  43.  
  44. public Action:CS_OnBuyCommand(client, const String:item[])
  45. {
  46. decl ammo[2];
  47. if (GetTrieArray(g_Trie, item, ammo, 2))
  48. {
  49. new Handle:pack;
  50. CreateDataTimer(0.1, wS_Function, pack);
  51. WritePackCell(pack, client);
  52. WritePackString(pack, item);
  53. WritePackCell(pack, ammo[0]);
  54. WritePackCell(pack, ammo[1]);
  55. }
  56. return Plugin_Continue;
  57. }
  58.  
  59. public ClientWeaponReload(Handle:event, const String:name[], bool:dontBroadcast)
  60. {
  61. decl String:item[20], ammo[2];
  62. new Client = GetClientOfUserId(GetEventInt(event, "userid"));
  63. new Handle:pack;
  64. CreateDataTimer(0.1, wS_Function, pack);
  65. WritePackCell(pack, Client);
  66. WritePackString(pack, item);
  67. WritePackCell(pack, ammo[0]);
  68. WritePackCell(pack, ammo[1]);
  69.  
  70. }
  71.  
  72. public Action:wS_Function(Handle:timer, Handle:pack)
  73. {
  74. ResetPack(pack);
  75. new client = ReadPackCell(pack);
  76. if (IsClientInGame(client) && IsPlayerAlive(client))
  77. {
  78. decl String:weapon[25], String:class[25], index;
  79. ReadPackString(pack, weapon, 25);
  80. Format(weapon, 25, "weapon_%s", weapon);
  81.  
  82. for (new slot = 0; slot < 2; slot++)
  83. {
  84. if ((index = GetPlayerWeaponSlot(client, slot)) > 0 && GetEntityClassname(index, class, 25) && strcmp(class, weapon) == 0)
  85. {
  86. new m_iPrimaryAmmoType = -1;
  87. if ((m_iPrimaryAmmoType = GetEntProp(index, Prop_Send, "m_iPrimaryAmmoType")) != -1)
  88. {
  89. SetEntProp(index, Prop_Send, "m_iClip1", ReadPackCell(pack));
  90. SetEntProp(client, Prop_Send, "m_iAmmo", ReadPackCell(pack), _, m_iPrimaryAmmoType);
  91. }
  92. break;
  93. }
  94. }
  95. }
  96. }

Szerző:  Alnilam [ 2013.09.17. 21:26 ]
Hozzászólás témája:  Re: Fegyver lőszermennyiségének módosítása

Sajnos nem működik.

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