Raised This Month: $ Target: $400
 0% 

Getting a weapons ent index


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
wgooch
Member
Join Date: Dec 2008
Old 05-02-2009 , 20:47   Re: Getting a weapons ent index
Reply With Quote #2

I've got this code up for equipping a player with a weapon
Code:
public Action:EquipPlayer(client, args)
{
    if (args < 2)
    {
        ReplyToCommand(client, "[SM] Usage: sm_equip <#userid|name> <Item>");
        return Plugin_Handled;
    }
    decl String:target_name[MAX_TARGET_LENGTH];
    decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
    
    decl String:arg[65], String:itemclass[82];
    GetCmdArg(1, arg, sizeof(arg) );
    GetCmdArg(2, itemclass, sizeof(itemclass) );
    
    new item = CreateEntityByName(itemclass[82], -1);
    DispatchSpawn(item)
    if ((target_count = ProcessTargetString(
            arg,
            client,
            target_list,
            MAXPLAYERS,
            0,
            target_name,
            sizeof(target_name),
            tn_is_ml)) <= 0)
    {
        ReplyToTargetError(client, target_count);
        return Plugin_Handled;
    }
    
    for (new i = 0; i < target_count; i++)
    {
        PerformEquip(client, target_list[i], target_name, item);
    }
    
    return Plugin_Handled;
}
stock PerformEquip(client, target, const String:target_name[], item)
{
        EquipPlayerWeapon(target, item);
        ShowActivity2(client, TAG, "Equiped %s with weapon", target_name);
}
But when I run it I get this error
Code:
[SM] Native "DispatchSpawn" reported: NULL not allowed
[SM] Displaying call stack trace for plugin "itemgive.smx":
[SM]   [0]  Line 74, C:\Program Files\Steam\steamapps\common\left 4 dead\left4dead\_addons\sourcemod\scripting\itemgive.sp::EquipPlayer()
Line 74 reads DispatchSpawn(item)
wgooch is offline
 



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 21:28.


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