Raised This Month: $ Target: $400
 0% 

Need help with plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kuzjma
Junior Member
Join Date: May 2007
Old 05-20-2007 , 06:06   Need help with plugin
Reply With Quote #1

Hi, I need help with my first plugin. When i play with it in "New game" (lan) it work fine . But wen I open server with it Server got too many lags . If some one can help me - HELP PLZ
Attached Files
File Type: rar models.rar (2.89 MB, 103 views)
File Type: sma Get Plugin or Get Source (agent.sma - 664 views - 6.6 KB)
__________________
Sorry for my bag english
I am rus
kuzjma is offline
_Master_
Senior Member
Join Date: Dec 2006
Old 05-21-2007 , 16:38   Re: Need help with plugin
Reply With Quote #2

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 ....
_Master_ is offline
kuzjma
Junior Member
Join Date: May 2007
Old 05-22-2007 , 11:52   Re: Need help with plugin
Reply With Quote #3

It don't help
Attached Files
File Type: sma Get Plugin or Get Source (agent.sma - 653 views - 4.0 KB)
__________________
Sorry for my bag english
I am rus
kuzjma is offline
pRED*
Join Date: Dec 2006
Old 05-22-2007 , 17:10   Re: Need help with plugin
Reply With Quote #4

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.
pRED* is offline
kuzjma
Junior Member
Join Date: May 2007
Old 05-23-2007 , 09:42   Re: Need help with plugin
Reply With Quote #5

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
__________________
Sorry for my bag english
I am rus
kuzjma is offline
regalis
Veteran Member
Join Date: Jan 2007
Location: F*cking Germany
Old 05-23-2007 , 09:48   Re: Need help with plugin
Reply With Quote #6

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! ;)
__________________

Last edited by regalis; 05-23-2007 at 09:52.
regalis is offline
kuzjma
Junior Member
Join Date: May 2007
Old 05-23-2007 , 10:17   Re: Need help with plugin
Reply With Quote #7

Too difficultly for me
__________________
Sorry for my bag english
I am rus
kuzjma is offline
regalis
Veteran Member
Join Date: Jan 2007
Location: F*cking Germany
Old 05-23-2007 , 10:26   Re: Need help with plugin
Reply With Quote #8

Quote:
Originally Posted by kuzjma View Post
Too difficultly for me
What is too difficult? The tutorial or to change the code that nothing is in preThink!?
__________________
regalis is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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