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)