AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Undefined Symbol Error (https://forums.alliedmods.net/showthread.php?t=183741)

mackid 04-26-2012 00:30

Undefined Symbol Error
 
I searched on here and on google and I couldn't find a fix that worked for me so I'm posting this here. I'm going through the tutorial for getting started with plugins and I'm getting the following error

/home/groups/sourcemod/upload_tmp/phpiJRzEt.sp(43) : error 017: undefined symbol "SlapPlayer"

I'm not sure what is causing this and I've tried reinstalling SM and using the online Compiler. Did the command for this change? Did I make a stupid mistake? Any help would be much appreciated. Also if I have the wrong sub forum let me know and I will gladly move this to wherever this does belong.


#include <sourcemod>

new Handle:sm_myslap_damage = INVALID_HANDLE

public Plugin:myinfo =
{
name = "My First Plugin",
author = "Me",
description = "My first plugin ever",
version = "1.0.0.0"
}

public OnPluginStart()
{
RegAdminCmd("sm_myslap", Command_MySlap, ADMFLAG_SLAY)

sm_myslap_damage = CreateConVar("sm_myslap_damage", "5", "Default slap damage")
AutoExecConfig(true, "plugin_myslap")
}

public Action:Command_MySlap(client, args)
{
new String:arg1[32], String:arg2[32]
new damage = GetConVarInt(sm_myslap_damage)

// get the first arg
GetCmdArg(1,arg1,sizeof(arg1))

//if there are 2 or more args and second fetch is successful convert to int
if (args >= 2 && GetCmdArg(2, arg2, sizeof(arg2)))
{
damage = StringToInt(arg2)
}

//try and find a matching player
new target = FindTarget(client, arg1)
if (target == -1)
{
//auto replies with fail reason
return Plugin_Handled;
}

SlapPlayer(target, damage)

new String:name[MAX_NAME_LENGTH]

ShowActivity2(client, "[SM] ", "Slapped %s for %d damage!", name, damage)
LogAction(client, target, "\"%L\" slapped \"%L\" (damage %d)", client, target, damage)

return Plugin_Handled;
}

psychonic 04-26-2012 07:10

Re: Undefined Symbol Error
 
Code:
#include <sdktools>

berni 04-26-2012 08:40

Re: Undefined Symbol Error
 
"undefined symbol" errors basically mean that the variable or function it tried to use is not known at this point. In this case you forgot to write the include statement which includes this function.

mackid 04-26-2012 10:34

Re: Undefined Symbol Error
 
Wow such an easy fix I feel stupid. Thanks for the help!

Dr. McKay 04-26-2012 12:39

Re: Undefined Symbol Error
 
Quote:

Originally Posted by mackid (Post 1696772)
Wow such an easy fix I feel stupid. Thanks for the help!

Don't feel stupid. We all started somewhere. If you haven't found it yet, http://docs.sourcemod.net/api is extremely useful.

Also, wrapping code that you post in [php] tags makes it much easier to read.

mackid 04-28-2012 01:39

Re: Undefined Symbol Error
 
Thanks for the tip! I didn't realize one could do that, I'll make sure to do so in the future. Thanks for the link as well I hadn't found that one yet.


All times are GMT -4. The time now is 16:10.

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