AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Need help with plugin (https://forums.alliedmods.net/showthread.php?t=55356)

kuzjma 05-20-2007 06:06

Need help with plugin
 
2 Attachment(s)
Hi, I need help with my first plugin. When i play with it in "New game" (lan) it work fine :up: . But wen I open server with it :shock: :shock: Server got too many lags :| :cry: . If some one can help me - HELP PLZ :o

_Master_ 05-21-2007 16:38

Re: Need help with plugin
 
The set_task() are set to be repeted forever at interval of 0.1 seconds. Server killers.

Too tired to fix it now... it can be done without those tasks ....

kuzjma 05-22-2007 11:52

Re: Need help with plugin
 
1 Attachment(s)
It don't help :| :?

pRED* 05-22-2007 17:10

Re: Need help with plugin
 
Ok..

set_lights is global. You only need to set it once i think (not every client connect)

In startround you set two server_cmds. They won't get reset every round and you definately don't need to set them for every player. Just call these once along with set_lights on plugin_cfg or similar.

Your main problem appears to be client_prethink. This gets run around 60 times per second per player and having that many things to do in there is what's causing your problems.

Things to Change:

- Add an is_user_alive(id) check to the start of prethink and return PLUGIN_HANDLED if they are dead.
- The three terrorist client commands should be run on client_connect instead.
-Pretty much everything else for terrorists can be run under curweapon (toggleclaws) as they will only change when weapon is changed/fired
-Same with the ct thing. Curweapon will do fine.

kuzjma 05-23-2007 09:42

Re: Need help with plugin
 
Code:
//---------------[INCLUDES]---------------//  #include <amxmodx>  #include <cstrike>  #include <engine>  #include <fun> //----------------[MODELS & SOUNDS]-------//  public plugin_precache()  {  precache_model("models/player/predator/predator.mdl")  precache_model("models/player/agent/agent.mdl")  precache_model("models/claws.mdl")    precache_sound("agvspr/t-end.wav")    precache_sound("agvspr/ct-end.wav")  } //----------------[INIT]-----------------//  public plugin_init()  {  register_plugin("Agents vs Predators","1.0","Kuzjma")  register_event("ResetHUD","startround","be")  register_event("CurWeapon", "toggleclaws", "be", "1=1")    register_event("SendAudio", "t_win", "a", "2&%!MRAD_terwin")    register_event("SendAudio", "ct_win", "a", "2&%!MRAD_ctwin")  set_lights("b")  }  //---------------[PREDATOR CLAWS]-------//  public toggleclaws(id)  {  if(get_user_team(id)==CS_TEAM_T) {  new model[32]  entity_get_string(id,EV_SZ_viewmodel,model,31)  entity_set_string(id, EV_SZ_viewmodel,"models/claws.mdl")  }  } //----------------[...]-------------------// public client_PreThink(id) {  if(!is_user_alive(id)) {   PLUGIN_HANDLED  }  if(cs_get_user_team(id) == CS_TEAM_T) {   set_user_maxspeed(id,500.0)   new clip, ammo   if(get_user_weapon(id,clip,ammo) != CSW_KNIFE || cs_get_user_shield(id))   {    strip_user_weapons(id)    give_item(id,"weapon_knife")   }  }  if(cs_get_user_team(id) == CS_TEAM_CT) {   if(cs_get_user_nvg(id) == 1) {    cs_set_user_nvg(id,0)    cs_set_user_money(id,cs_get_user_money(id)+1250)   }  } }  //---------------[START ROUND]-------------//  public startround(id)  {  if(cs_get_user_team(id) == CS_TEAM_T) {   cs_set_user_armor(id,300,CS_ARMOR_VESTHELM)   cs_set_user_model(id,"predator")   set_user_gravity(id,0.5)   set_user_health(id,500)   cs_set_user_nvg(id,0) //for don't see msg "You alredy have one" ;)   cs_set_user_nvg(id,1)   server_cmd("sv_maxspeed 100000")   server_cmd("sv_airaccelerate 500")  }  if(cs_get_user_team(id) == CS_TEAM_CT) {   cs_set_user_armor(id,100,CS_ARMOR_VESTHELM)   cs_set_user_model(id,"agent")  }  } //------------------[END ROUND]------------------// public t_win() {   client_cmd(0,"stopsound")   client_cmd(0,"spk agvspr/t-end") } public ct_win() {   client_cmd(0,"stopsound")   client_cmd(0,"spk agvspr/ct-end") }

Thx, but is still laging :roll:

regalis 05-23-2007 09:48

Re: Need help with plugin
 
You do This:
Code:

public client_PreThink(id)
{
 if(!is_user_alive(id)) {
  PLUGIN_HANDLED
 }
 if(cs_get_user_team(id) == CS_TEAM_T) {
  set_user_maxspeed(id,500.0)
  new clip, ammo
  if(get_user_weapon(id,clip,ammo) != CSW_KNIFE || cs_get_user_shield(id))
  {
  strip_user_weapons(id)
  give_item(id,"weapon_knife")
  }
 }
 if(cs_get_user_team(id) == CS_TEAM_CT) {
  if(cs_get_user_nvg(id) == 1) {
  cs_set_user_nvg(id,0)
  cs_set_user_money(id,cs_get_user_money(id)+1250)
  }
 }
}

every player think...ca 60 times per second...why?

wouldn't it be better to do this if player spawns or also in roundstart?
Btw.: for the correct hook on rountstart see VENs tutorial :http://forums.alliedmods.net/showthread.php?t=42159
Very nice tut! ;)

kuzjma 05-23-2007 10:17

Re: Need help with plugin
 
:shock: Too difficultly for me :shock:

regalis 05-23-2007 10:26

Re: Need help with plugin
 
Quote:

Originally Posted by kuzjma (Post 479697)
:shock: Too difficultly for me :shock:

What is too difficult? The tutorial or to change the code that nothing is in preThink!?


All times are GMT -4. The time now is 10:35.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.