Raised This Month: $51 Target: $400
 12% 

Crashing the server?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Aviram1994
Member
Join Date: Jan 2007
Old 05-22-2008 , 11:32   Crashing the server?
Reply With Quote #1

Hello,
I tried to code a Melee Only plugin for TF2,
I wonder why it crashes the server when I change the cvar to 1..?
Attached Files
File Type: sp Get Plugin or Get Source (MeleeOnly.sp - 576 views - 2.8 KB)
Aviram1994 is offline
kirewv
Senior Member
Join Date: Oct 2007
Old 05-22-2008 , 11:49   Re: Crashing the server?
Reply With Quote #2

PHP Code:
public Action:Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
 new 
MeleeOnlyOn GetConVarInt(g_meleeonly
Are you trying to limit melee per player if so:
you need to devise a way to set the variable (random, by admin choice ... etc.)
make a global

PHP Code:
new bool:MeleeOnly[MAXPLAYERS +1]; 
and then

PHP Code:
public Action:Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
MeleeOnly[client] = //make it 1 if you want it on 
But seeing as you have a "shared" CVAR that is server wide you are not making it player specific and you should just
make MeleeOnlyOn global -
then move "MeleeOnlyOn = GetConVarInt(g_meleeonly)"

to OnMapStart or hook the round and put it in round_start.

Last edited by kirewv; 05-22-2008 at 11:53.
kirewv is offline
kirewv
Senior Member
Join Date: Oct 2007
Old 05-22-2008 , 12:58   Re: Crashing the server?
Reply With Quote #3

on another note why have all the specific remove functions and class checking?

You could just use the following code:

PHP Code:
public Action:Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
  if (
MeleeOnlyOn == 1)
 {
    
RemoveWeaponSlot(client);
 }
}
stock RemoveWeaponSlot(client)
{
 new 
weaponIndex;
 
// Iterate through weapon slots
 
for( new 04i++ )
 {
  while( ( 
weaponIndex GetPlayerWeaponSlotclient) ) != -)
  {
   
RemovePlayerItemclientweaponIndex );
  }
 }

kirewv is offline
Aviram1994
Member
Join Date: Jan 2007
Old 05-23-2008 , 05:40   Re: Crashing the server?
Reply With Quote #4

I cant use it because,
Some classes have their weapons at 1-2
some classes have weapons in 1,2,4,5
so I cant use loop,
I thought about something like that..
Aviram1994 is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 05-23-2008 , 06:44   Re: Crashing the server?
Reply With Quote #5

Sure you can, you're checking if there is a weapon in that slot anyway. If there's not, then it won't attempt to remove it either. You have to do i < 5 though, not 4.

Code:
stock RemoveWeaponSlot(client) {   new weaponIndex;   // Iterate through weapon slots   for ( new i = 0; i < 5; i++ )   {     // Do not remove melee weapon slot     if ( ( weaponIndex = GetPlayerWeaponSlot( client, i ) ) != -1 && i != 2 )     {       RemovePlayerItem( client, weaponIndex );       RemoveEdict( weaponIndex );     }   } }
Also you can't remove their weapons immediately on spawn, because they get their weapons the frame after that. So you have to make a timer with a 0.1 second interval, and call that stock in that timer callback. I would suggest you just look at the source of TF2 Sudden Death Melee Redux, everything you need is right there.
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.

Last edited by DJ Tsunami; 05-23-2008 at 07:10.
DJ Tsunami is offline
Reply



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 18:33.


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