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

Errors Compiling


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Peoples Army
SourceMod Donor
Join Date: Mar 2007
Old 07-10-2010 , 04:05   Errors Compiling
Reply With Quote #1

Ok well I have no idea what the problem here is

PHP Code:





/////////////////////////////////////////////////////////
/// 
///     This plugin will block shots from bots every 3rd shot and every headshot
///
///
/////////////////////////////////////////////////////////

#include <sourcemod>
#include <sdktools>



public Plugin:myinfo 
{
    
name "Shot Block",
    
author "Peopels Army",
    
description "Blocks 3rd shot from bot & makes palyer nto die from headshot",
    
version "1.0",
    
url "www.sourcemod.net"
}

////////////////////////////////////////////////////////
///
///
///     Register convars & events 
///
///////////////////////////////////////////////////////


public OnPluginStart()
{
    
CreateConVar("shot_block_on","1""Turns the plugin on and off");
    
CreateConVar("shot_block_count","3""Sets how many shtos are needed by bots before there blocked");
    
HookEvent("player_hurt",BlockHurtEventHookMode_Pre);
}


//////////////////////////////////////////////////////////////
///
///     hook player hurt event and check if attacker is a bot 
///        then count hits and then give god mode if more then 2
///
//////////////////////////////////////////////////////////////////

public Action:BlockHurt(Handleevent, const Stringname[], bool:dontBroadcast)
{
    new 
clientID GetEventInt(event,"userid");
    new 
client GetClientOfUserId(clientID);
    new 
attackerID GetEventInt(event"attacker");
    new 
attacker GetClientOfUserId(attackerID);
    new 
hitGroup GetEventInt(event"hitgroup");
    new 
botShot;
    
    
// if player is alive , plugin is on and was attacked by a bot
    
if(GetConVarInt("shot_block_on") && IsFakeClient(attacker))
    {
        ++
botShot;
        
// if the shot count is larger then the amount convar or the hitgruop is headshot 
        
if(botShot GetConVarInt("shot_block_count") || hitGroup == 1)
        {
            
SetEntProp(clientProp_Data"m_takedamage"1);
            return 
0;
        }
    }


PHP Code:


SourcePawn Compiler 1.3.3
Copyright 
(c1997-2006ITB CompuPhase, (C)2004-2008 AlliedModdersLLC

\sourcemod\sps\shot_block.sp(55) : error 035argument type mismatch (argument 1)
\
sourcemod\sps\shot_block.sp(59) : error 035argument type mismatch (argument 1)
\
sourcemod\sps\shot_block.sp(62) : warning 213tag mismatch
\sourcemod\sps\shot_block.sp(65) : warning 209: function "BlockHurt" should return a value

2 Errors
.

Compilation Time0.77 sec 
__________________
Peoples Army is offline
Lboongon123
New Member
Join Date: Jul 2010
Old 07-10-2010 , 04:36   Re: Errors Compiling
Reply With Quote #2

Hey I get this kind of problems too... Have you solved them already?








Type of Service Agreements
Lboongon123 is offline
Scone
Senior Member
Join Date: Apr 2010
Location: England
Old 07-10-2010 , 04:59   Re: Errors Compiling
Reply With Quote #3

GetConVarInt doesn't take a string, it takes the handle to a cvar. You need to save the handles of the two cvars you create, then use them in the calls to GetConVarInt.

You can also remove "return 0;" from the BlockHurt function, and replace it with a "return Plugin_Continue;" at the end.
__________________
Scone is offline
Peoples Army
SourceMod Donor
Join Date: Mar 2007
Old 07-10-2010 , 06:44   Re: Errors Compiling
Reply With Quote #4

lol return 0 and return plugin continue are the same thing , return 0 is the enum number associated with return plugin continue

return 1 is return handled

theres no way to get a convar with out a handle?
__________________
Peoples Army is offline
Scone
Senior Member
Join Date: Apr 2010
Location: England
Old 07-10-2010 , 07:05   Re: Errors Compiling
Reply With Quote #5

I wasn't saying changing the return value would fix the warning - putting the return statement at the end of the function means that something is returned in all cases. I only suggested the change to "Plugin_Continue" for readability.

You can get a cvar's handle using a string (FindConVar), but seeing as you already have the handles (from CreateConVar), you should just save them in a pair of global variables.
__________________
Scone is offline
dirka_dirka
Veteran Member
Join Date: Nov 2009
Old 07-10-2010 , 10:09   Re: Errors Compiling
Reply With Quote #6

instead of GetConVarInt("shot_block_count")
useGetConVarInt(FindConVar("shot_block_count"))

but that would only be worthwhile for a game convar that you need to access once.
this is one you created.. all you have to do is add a handle to it as scone says.
dirka_dirka is offline
Peoples Army
SourceMod Donor
Join Date: Mar 2007
Old 07-10-2010 , 17:43   Re: Errors Compiling
Reply With Quote #7

and alocate memory for a handle that only gets used once kinda stupid
__________________
Peoples Army is offline
Dr. Greg House
Professional Troll,
Part-Time Asshole
Join Date: Jun 2010
Old 07-10-2010 , 18:29   Re: Errors Compiling
Reply With Quote #8

You have to return a value in every case, so there has to be a return below the ifs at the end of your function.
Dr. Greg House is offline
Scone
Senior Member
Join Date: Apr 2010
Location: England
Old 07-11-2010 , 04:27   Re: Errors Compiling
Reply With Quote #9

Quote:
Originally Posted by Peoples Army View Post
and alocate memory for a handle that only gets used once kinda stupid
A pair of handles consume 8 bytes of memory. The two strings "shot_block_count" and "shot_block_on" consume 31 bytes of memory together. In trying to save a lofty 8 bytes of RAM, you end up using nearly four times that much.
__________________
Scone is offline
Greyscale
SourceMod Plugin Approver
Join Date: Dec 2007
Location: strYoMommasHouse[you];
Old 07-11-2010 , 05:23   Re: Errors Compiling
Reply With Quote #10

Not to mention these handles are already in memory. You're just looking it up based off a string.

The best method is to look up these handles in OnPluginStart and cache them. Then you can use them anytime in your plugin without doing work every time.
__________________
Greyscale 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 10:42.


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