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

[TF2] Block ammo pickup


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Nursik
Senior Member
Join Date: Jul 2016
Location: In TF2
Old 08-07-2016 , 15:00   [TF2] Block ammo pickup
Reply With Quote #1

So, i found this thread: https://forums.alliedmods.net/showth...ht=Ammo+pickup But it gives not enough information on how to do it, i tried doing what ddhoward said, but i had some problems with returning Plugin_Handled:
PHP Code:
public OnEntityCreated(entity, const String:classname[])
{
    if(
IsValidEntity(entity))
    {
        if 
StrContains(classname"item_ammopack_full"false) != -1)
        {
            
SDKHook(entitySDKHook_StartTouchOnStartTouch);
            
SDKHook(entitySDKHook_TouchOnTouch);
        }
    }
}

public 
OnStartTouch(entityother)
{
    if(!(
<= other <= MaxClients))
        return;

    if(!
IsClientInGame(other))
        return;

    if(!
IsPlayerAlive(other))
        return;
    new 
ClientHealth GetClientHealth(other);
    new 
ClientMaxHealth GetClientMaxHealth(other);
    new 
index GetIndexOfWeaponSlot(otherTFWeaponSlot_Melee);
    if (
index == 404)
    if (
ClientHealth ClientMaxHealth)
    return 
Plugin_Handled;
}

public 
OnTouch(entityother)
{
    if(!(
<= other <= MaxClients))
        return;

    if(!
IsClientInGame(other))
        return;

    if(!
IsPlayerAlive(other))
        return;
    new 
ClientHealth GetClientHealth(other);
    new 
ClientMaxHealth GetClientMaxHealth(other);
    new 
index GetIndexOfWeaponSlot(otherTFWeaponSlot_Melee);
    if (
index == 404)
    if (
ClientHealth ClientMaxHealth)
    return 
Plugin_Handled;

PHP Code:
/home/groups/sourcemod/upload_tmp/phpkxUUNu.sp(11) : error 001expected token"*then"but found ")"
/home/groups/sourcemod/upload_tmp/phpkxUUNu.sp(11) : error 029invalid expressionassumed zero
/home/groups/sourcemod/upload_tmp/phpkxUUNu.sp(26) : warning 213tag mismatch
/home/groups/sourcemod/upload_tmp/phpkxUUNu.sp(27) : warning 209: function "OnStartTouch" should return a value
/home/groups/sourcemod/upload_tmp/phpkxUUNu.sp(36) : warning 213tag mismatch
/home/groups/sourcemod/upload_tmp/phpkxUUNu.sp(37) : warning 209: function "OnTouch" should return a value 
I wanted to ask them, but the thread is dead and they're all probably dead too.

Last edited by Nursik; 08-08-2016 at 00:34.
Nursik is offline
nosoop
Veteran Member
Join Date: Aug 2014
Old 08-08-2016 , 06:11   Re: [TF2] Block ammo pickup
Reply With Quote #2

Please post compile logs of the source posted; the line numbers are off.

Also, according to the compile log, you're missing a left parenthesis on the line that causes a compile error (before StrContains). There's more past that: the return value of On*Touch should be one of the Plugin_* values and there should also be a default return value past the index and player health tests.
__________________
I do TF2, TF2 servers, and TF2 plugins.
I don't do DMs over Discord -- PM me on the forums regarding inquiries.
AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)

Last edited by nosoop; 08-08-2016 at 06:48.
nosoop 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 15:57.


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