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

[TF2]force mele on blu team plugin, 2 errors


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
JosephOhSnap
New Member
Join Date: May 2009
Old 01-12-2010 , 21:36   [TF2]force mele on blu team plugin, 2 errors
Reply With Quote #1

Hello. I am just starting my first plugin, and i got to the point where i need some help. What i am trying to do is make everybody on blu team switch to their mellee weapon, then remove all non-mellee weapons. If the following code will do that, then i would like help fixing these errors. If it will not do that, then i would like help coding the first version. I have read all of the documentation that seemed like it would help, but i still can't figure this one out. Thank you for helping out yet another noob

error 100: function prototypes do not match
i got this error for line 16, where i used hookevent.
I have no idea how to fix it.
Any help would be appreciated.

PHP Code:
#include <sourcemod>
#include <tf2_stocks>
#include <sdktools>

public Plugin:myinfo 
{
    
name "top secret",
    
author "JosephOhSnap",
    
description "top secret",
    
version "1.0",
    
url "http://www.vulgardisplayclan.com"
}

public 
OnPluginStart()
{
        
HookEvent("player_spawn"event_PlayerSpawn);
}
public 
Action:event_PlayerSpawn(Handle:event)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    new 
team GetClientTeam(client);
    if (
team == 3)
    {
        
ClientCommand(client"slot3");
        
TF2_RemoveWeaponSlot(client1);
        
TF2_RemoveWeaponSlot(client2);
    }


Last edited by JosephOhSnap; 01-12-2010 at 22:26.
JosephOhSnap is offline
=MaTi=
Member
Join Date: Jan 2008
Old 01-12-2010 , 22:53   Re: [TF2]force mele on blu team plugin, 2 errors
Reply With Quote #2

You need to keep in mind that players can get their weapons back by touching the resupply cabinet. Something like that should work:

PHP Code:
public OnPluginStart()
{
    
HookEvent("player_spawn",PlayerSpawnEventEventHookMode_Post);
    
AddNormalSoundHook(NormalSHook:Hook_Sound);
}


public 
PlayerSpawnEvent(Handle:event,const String:name[],bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event,"userid"));
    
    
RemoveEdict(GetPlayerWeaponSlot(client0));
    
RemoveEdict(GetPlayerWeaponSlot(client1));
}

public 
Action:Hook_Sound(iClients[64], &iNumClientsString:strSample[PLATFORM_MAX_PATH], &entity
{
    if (
StrEqual(strSample"items/regenerate.wav"true)) //detect resupply cabinet opening sound
    
{
        
RemoveEdict(GetPlayerWeaponSlot(entity0));
        
RemoveEdict(GetPlayerWeaponSlot(entity1));
    }

Alternatively, you can use SDKHooks to simply block switching to any other weapon. Your choice.
=MaTi= is offline
pheadxdll
AlliedModders Donor
Join Date: Jun 2008
Old 01-12-2010 , 23:29   Re: [TF2]force mele on blu team plugin, 2 errors
Reply With Quote #3

You don't have the correct function prototype:

Code:
public Action:event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
As for the post above, I would just hook the event post_inventory_application because its fired whenever a player touches an ammo cabinet.
pheadxdll is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 01-13-2010 , 00:19   Re: [TF2]force mele on blu team plugin, 2 errors
Reply With Quote #4

Actually his prototype was correct. You only need to add the "Action:" tag if you need to return anything but Plugin_Continued at any point in the function.
bl4nk is offline
Dragonshadow
BANNED
Join Date: Jun 2008
Old 01-13-2010 , 09:22   Re: [TF2]force mele on blu team plugin, 2 errors
Reply With Quote #5

Using SM 1.3 its really easy.

PHP Code:
public Action:OnPlayerRunCmd(client, &buttons, &impulseFloat:vel[3], Float:angles[3], &weapon)
{
    if(
IsClientInGame(client) && IsPlayerAlive(client) && GetClientTeam(client) == && weapon 0)
    {
        new 
melee GetPlayerWeaponSlot(client2);
        if (
melee > -&& weapon != melee)
        {
            
weapon melee;
        }
    }

Dragonshadow 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 06:55.


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