Difference between revisions of "Compiling SourceMod Plugins"

From AlliedModders Wiki
Jump to: navigation, search
(New page: #include <sourcemod> #include <sdktools> public Plugin:myinfo = { name = "My First Plugin", author = "Me", description = "My first plugin ever" version = "1.0.0.0", url = "http://ww...)
 
Line 50: Line 50:
 
   
 
   
 
return Plugin_Handled;
 
return Plugin_Handled;
}
+
}000

Revision as of 02:40, 20 December 2007

  1. include <sourcemod>
  2. include <sdktools>

public Plugin:myinfo = { name = "My First Plugin", author = "Me", description = "My first plugin ever" version = "1.0.0.0", url = "http://www.sourcemod.net/" }

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

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

/* Get the first argument */ GetCmdArg(1, arg1, sizeof(arg1))

/* If there are 2 or more arguments, and the second argument fetch * is successful, convert it to an integer. */ 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) { /* FindTarget() automatically replies with the * failure reason. */ return Plugin_Handled; }

SlapPlayer(target, damage)

new String:name[MAX_NAME_LENGTH]

GetClientName(target, name, sizeof(name)) ReplyToCommand(client, "[SM] You slapped %s for %d damage!", name, damage)

return Plugin_Handled; }000