HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /*
  2.   Fordította: BBk
  3. */
  4.  
  5. #include <sourcemod>
  6.  
  7. public Plugin:myinfo = {
  8. name = "Infinite Ammo",
  9. author = "twistedeuphoria",
  10. description = "A jatekosoknak vegtelen loszer adas.",
  11. version = "0.5",
  12. url = "http://forums.alliedmods.net/showthread.php?t=55381"
  13. };
  14.  
  15. new ammo[128];
  16.  
  17. new activeoffset = 1896
  18. new clipoffset = 1204
  19. new maxclients = 0;
  20.  
  21. new Handle:enablecvar;
  22.  
  23. public OnPluginStart()
  24. {
  25. LoadTranslations("common.phrases")
  26. enablecvar = CreateConVar("sm_iammo_enable", "1", "<0|1|2> 0 = vegtelen loszer inaktivalasa; 1 = vegtelen loszer engedelyezese parancs hasznalataval; 2 = a vegtelen loszer automatikusan aktivalodik minden jatekosnak");
  27. CreateConVar("sm_iammo_version", "0.4", "Infinite Ammo Version", FCVAR_REPLICATED|FCVAR_NOTIFY);
  28. HookConVarChange(enablecvar, EnableChanged);
  29. RegAdminCmd("sm_iammo",unlimit, ADMFLAG_KICK,"<felhasznalo id | nev> <0|1> - Vegtelen loszert adni vagy megvonni a jatekosoktol.", "",0);
  30. new off = FindSendPropOffs("CAI_BaseNPC", "m_hActiveWeapon");
  31. if(off != -1)
  32. {
  33. activeoffset = off;
  34. }
  35. off = -1;
  36. off = FindSendPropOffs("CBaseCombatWeapon", "m_iClip1");
  37. if(off != -1)
  38. {
  39. clipoffset = off;
  40. }
  41. maxclients = GetMaxClients();
  42. }
  43.  
  44. public EnableChanged(Handle:convar, const String:oldValue[], const String:newValue[])
  45. {
  46. if(convar == enablecvar)
  47. {
  48. new oldval = StringToInt(oldValue);
  49. new newval = StringToInt(newValue);
  50.  
  51. if(newval == oldval) return;
  52.  
  53. if( (newval != 0) && (newval != 1) && (newval != 2) )
  54. {
  55. PrintToServer("nem ervenyes ertek: sm_iammo_enable %s, valtsd vissza erre: %s", newValue, oldValue);
  56. SetConVarInt(enablecvar, oldval);
  57. }
  58. else
  59. {
  60.  
  61. if(oldval == 2)
  62. {
  63. PrintToChatAll("A Vegtelen Loszer mindenkitol megvonva!");
  64. for(new i=1;i<maxclients;i++)
  65. {
  66. if(IsValidEntity(i) && IsClientConnected(i))
  67. {
  68. ammo[i] = 0;
  69. }
  70. }
  71. }
  72.  
  73. if(newval == 2)
  74. {
  75. PrintToChatAll("A Vegtelen Loszer mindenkinel engedelyezve!");
  76. for(new i=1;i<maxclients;i++)
  77. {
  78. if(IsValidEntity(i) && IsClientConnected(i))
  79. {
  80. ammo[i] = 1;
  81. }
  82. }
  83. }
  84. }
  85. }
  86. }
  87.  
  88. public bool:OnClientConnect(client, String:rejectmsg[], maxlen)
  89. {
  90. if(GetConVarInt(enablecvar) == 2)
  91. {
  92. ammo[client] = 1;
  93. }
  94.  
  95. return true;
  96. }
  97.  
  98. public OnClientDisconnect(client)
  99. {
  100. ammo[client] = 0;
  101. }
  102.  
  103. public Action:unlimit(client,args)
  104. {
  105.  
  106. new curval = GetConVarInt(enablecvar);
  107.  
  108. if(curval == 0)
  109. {
  110. PrintToConsole(client, "Vegtelen Loszer jelenleg kikapcsolva.");
  111. return Plugin_Handled;
  112. }
  113.  
  114. new aid = client;
  115. if(args != 2)
  116. {
  117. PrintToConsole(aid, "Hasznalat: <felhasznalo id | nev> <0|1>");
  118. return Plugin_Handled;
  119. }
  120. new String:idstr[50];
  121. GetCmdArg(1,idstr,50);
  122. new String:switchstr[2];
  123. GetCmdArg(2,switchstr,2);
  124.  
  125. new targets[1];
  126. new tgtname[50];
  127. new bool:ml;
  128.  
  129. if(ProcessTargetString(idstr, client, targets, 1, 0, tgtname, 50, ml) != 1)
  130. {
  131. PrintToConsole(client, "A cel nem talalhato.");
  132. return Plugin_Handled;
  133. }
  134.  
  135. new onoff = StringToInt(switchstr);
  136. ammo[targets[0]] = onoff;
  137. // new String:name[50]
  138. // GetClientName(id, name, 50);
  139. if(onoff)
  140. {
  141. PrintToConsole(aid,"%s vegtelen loszert kapott.",tgtname);
  142. PrintToConsole(targets[0], "Vegtelen loszert kaptal.");
  143. }
  144. else
  145. {
  146. PrintToConsole(aid,"%s vegtelen loszert megvontak.",tgtname);
  147. PrintToConsole(targets[0],"A vegtelen loszered megvontak.");
  148. }
  149. return Plugin_Handled;
  150. }
  151.  
  152. public OnGameFrame()
  153. {
  154. new zomg;
  155. for(new i=0;i<maxclients;i++)
  156. {
  157. if( (ammo[i] == 1) && IsClientInGame(i))
  158. {
  159. zomg = GetEntDataEnt2(i, activeoffset);
  160. if(IsValidEntity(zomg))
  161. SetEntData(zomg, clipoffset, 50, 4, true);
  162. }
  163. }
  164. }