Member
|
09-21-2012
, 13:05
Re: [CS:GO] ! ! ! Simple-Special-Script ! ! ! -> sm-sss
|
#20
|
Quote:
Originally Posted by leichenclub
I tried to compile this:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
new String:g_strGuns[][] =
{
"weapon_molotov",
"weapon_incgrenade"
} //semicolon?
#define OUCH_SOUND "ouch.mp3"
#define IDIOT_SOUND "idiot.mp3"
#define SLAP_SOUND false // false to disable the slap sound in addition to idiot/ouch, true to enable
public Plugin:myinfo = {
name = "[CS:S/CS:GO] Sounds & Slapping",
author = "Dr. McKay",
description = "Requested at https://forums.alliedmods.net/showthread.php?t=195654",
version = "1.0.0",
url = "http://www.doctormckay.com"
};
public OnPluginStart() {
HookEvent("player_hurt", Event_PlayerHurt);
HookEvent("bomb_abortplant", Event_AbortPlant);
HookEvent("bomb_abortdefuse", Event_AbortDefuse);
}
public OnMapStart() {
decl String:buffer[256];
Format(buffer, sizeof(buffer), "sound/%s", OUCH_SOUND);
AddFileToDownloadsTable(buffer);
Format(buffer, sizeof(buffer), "sound/%s", IDIOT_SOUND);
AddFileToDownloadsTable(buffer);
PrecacheSound(OUCH_SOUND);
PrecacheSound(IDIOT_SOUND);
}
//Action: before event names?
public Event_PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast) {
new victim = GetClientOfUserId(GetEventInt(event, "userid"));
new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
if ((victim != attacker) && GetClientTeam(victim) == GetClientTeam(attacker)) {
decl String:weapon[32];
GetEventString(event, "weapon", weapon, sizeof(weapon));
for (new i = 0; i < sizeof(g_strGuns); i++)
{
if (!strcmp(weapon, g_strGuns[i], false))
return Plugin_Continue;
}
EmitSoundToClient(attacker, OUCH_SOUND);
EmitSoundToClient(victim, OUCH_SOUND);
SlapPlayer(attacker, 0, SLAP_SOUND);
}
return Plugin_Continue;
}
public Event_AbortPlant(Handle:event, const String:name[], bool:dontBroadcast) {
new client = GetClientOfUserId(GetEventInt(event, "userid"));
EmitSoundToAll(IDIOT_SOUND);
PrintToChatAll("%N aborted planting the bomb!", client);
SlapPlayer(client, 0, SLAP_SOUND);
CreateTimer(0.5, Timer_Slap, client);
}
public Event_AbortDefuse(Handle:event, const String:name[], bool:dontBroadcast) {
new client = GetClientOfUserId(GetEventInt(event, "userid"));
EmitSoundToAll(IDIOT_SOUND);
PrintToChatAll("%N aborted defusing the bomb!", client);
SlapPlayer(client, 0, SLAP_SOUND);
CreateTimer(0.5, Timer_Slap, client);
}
public Action:Timer_Slap(Handle:timer, any:client) {
SlapPlayer(client, 0, SLAP_SOUND);
}
and get this error:
Your plugin failed to compile! Read the errors below:
SourcePawn Compiler 1.4.0
Copyright (c) 1997-2006, ITB CompuPhase, (C)2004-2008 AlliedModders, LLC
/home/groups/sourcemod/upload_tmp/phpzGKUiM.sp(16) : error 001: expected token: ";", but found "public"
/home/groups/sourcemod/upload_tmp/phpzGKUiM.sp(49) : warning 213: tag mismatch
/home/groups/sourcemod/upload_tmp/phpzGKUiM.sp(55) : warning 213: tag mismatch
1 Error.
|
PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
new String:g_strGuns[][] = { "weapon_molotov", "weapon_incgrenade"} ;
#define OUCH_SOUND "ouch.mp3"
#define IDIOT_SOUND "idiot.mp3"
#define SLAP_SOUND false // false to disable the slap sound in addition to idiot/ouch, true to enable
public Plugin:myinfo = {
name = "[CS:S/CS:GO] Sounds & Slapping",
author = "Dr. McKay",
description = "Requested at https://forums.alliedmods.net/showthread.php?t=195654",
version = "1.0.0",
url = "http://www.doctormckay.com"
};
public OnPluginStart() {
HookEvent("player_hurt", Event_PlayerHurt);
HookEvent("bomb_abortplant", Event_AbortPlant);
HookEvent("bomb_abortdefuse", Event_AbortDefuse);
}
public OnMapStart() {
decl String:buffer[256];
Format(buffer, sizeof(buffer), "sound/%s", OUCH_SOUND);
AddFileToDownloadsTable(buffer);
Format(buffer, sizeof(buffer), "sound/%s", IDIOT_SOUND);
AddFileToDownloadsTable(buffer);
PrecacheSound(OUCH_SOUND);
PrecacheSound(IDIOT_SOUND);
}
public Action:Event_PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast) {
new victim = GetClientOfUserId(GetEventInt(event, "userid"));
new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
if ((victim != attacker) && GetClientTeam(victim) == GetClientTeam(attacker)) {
decl String:weapon[32];
GetEventString(event, "weapon", weapon, sizeof(weapon));
for (new i = 0; i < sizeof(g_strGuns); i++)
{
if (!strcmp(weapon, g_strGuns[i], false))
return Plugin_Continue;
}
EmitSoundToClient(attacker, OUCH_SOUND);
EmitSoundToClient(victim, OUCH_SOUND);
SlapPlayer(attacker, 0, SLAP_SOUND);
}
return Plugin_Continue;
}
public Action:Event_AbortPlant(Handle:event, const String:name[], bool:dontBroadcast) {
new client = GetClientOfUserId(GetEventInt(event, "userid"));
EmitSoundToAll(IDIOT_SOUND);
PrintToChatAll("%N aborted planting the bomb!", client);
SlapPlayer(client, 0, SLAP_SOUND);
CreateTimer(0.5, Timer_Slap, client);
}
public Action:Event_AbortDefuse(Handle:event, const String:name[], bool:dontBroadcast) {
new client = GetClientOfUserId(GetEventInt(event, "userid"));
EmitSoundToAll(IDIOT_SOUND);
PrintToChatAll("%N aborted defusing the bomb!", client);
SlapPlayer(client, 0, SLAP_SOUND);
CreateTimer(0.5, Timer_Slap, client);
}
public Action:Timer_Slap(Handle:timer, any:client) {
SlapPlayer(client, 0, SLAP_SOUND);
}
Fixed.
|
|