Raised This Month: $ Target: $400
 0% 

Invalid character constant?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DeathChaos25
Senior Member
Join Date: Jan 2014
Location: Puerto Rico
Old 03-16-2015 , 20:59   Invalid character constant?
Reply With Quote #1

So, after declaring static const String on many of my plugins, for the first time I have gotten this error and have absolutely no idea why this would be.

Here's the code for anyone wondering
PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>

static const String:SOUND_AUTOSHOTGUN[]         = "weapons\auto_shotgun\gunfire\auto_shotgun_fire_1.wav";
static const 
String:SOUND_SPASSHOTGUN[]         = "weapons\auto_shotgun_spas\gunfire\shotgun_fire_1.wav";
static const 
String:SOUND_PUMPSHOTGUN[]         = "weapons\shotgun\gunfire\shotgun_fire_1.wav";
static const 
String:SOUND_CHROMESHOTGUN[]         = "weapons\shotgun_chrome\gunfire\shotgun_fire_1.wav";

public 
Plugin:myinfo 
{
    
name "L4D2 Thirdpersonshoulder Shotgun sound bug fix",
    
author "DeathChaos25",
    
description "Fixes the bug where shotguns make no sound when shot in thirdperson shoulder",
    
version "1.0",
    
url "DUMMY"
}

public 
APLRes:AskPluginLoad2(Handle:myselfbool:lateString:error[], err_max
{
    
decl String:s_GameFolder[32];
    
GetGameFolderName(s_GameFoldersizeof(s_GameFolder)); 
    if (!
StrEqual(s_GameFolder"left4dead2"false))
    {
        
strcopy(errorerr_max"This plugin is for Left 4 Dead 2 Only!"); 
        return 
APLRes_Failure;
    }
    return 
APLRes_Success
}

public 
OnPluginStart()
{
    
HookEvent("weapon_fire"Event_WeaponFire);
}

public 
OnMapStart()
{
    
    
PrefetchSound(SOUND_AUTOSHOTGUN);
    
PrecacheSound(SOUND_AUTOSHOTGUNtrue);

    
PrefetchSound(SOUND_SPASSHOTGUN);
    
PrecacheSound(SOUND_SPASSHOTGUNtrue);

    
PrefetchSound(SOUND_CHROMESHOTGUN);
    
PrecacheSound(SOUND_CHROMESHOTGUNtrue);

    
PrefetchSound(SOUND_PUMPSHOTGUN);
    
PrecacheSound(SOUND_PUMPSHOTGUNtrue);
    
}

public 
Action:Event_WeaponFire(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
String:weapon[64];
    
GetEventString(event"weapon"weaponsizeof(weapon));
    
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    if (
client || client MAXPLAYERS || !IsPlayerAlive(client) || GetClientTeam(client) != 2
        return 
Plugin_Handled;
    
    
// Thirdperson Shoulder check coming soon tm
    
    
if (StrEqual(weapon"autoshotgun"))
    {
        
EmitSoundToAll(SOUND_AUTOSHOTGUNclientSNDCHAN_WEAPON);
    }
    else if (
StrEqual(weapon"shotgun_spas"))
    {
        
EmitSoundToAll(SOUND_SPASSHOTGUNclientSNDCHAN_WEAPON);
    }
    else if (
StrEqual(weapon"pumpshotgun"))
    {
        
EmitSoundToAll(SOUND_PUMPSHOTGUNclientSNDCHAN_WEAPON);
    }
    else if (
StrEqual(weapon"shotgun_chrome"))
    {
        
EmitSoundToAll(SOUND_CHROMESHOTGUNclientSNDCHAN_WEAPON);
    }
    
    return 
Plugin_Continue;

Some plugins have similar code, this one is basically derived from the code of this plugin.

Why am I getting this error?

It could possibly be something I'm overlooking?
At a first glance nothing seems wrong with it, so I really have no idea.
__________________

Last edited by DeathChaos25; 03-16-2015 at 21:14.
DeathChaos25 is offline
Darkness_
Veteran Member
Join Date: Nov 2014
Old 03-16-2015 , 21:04   Re: Invalid character constant?
Reply With Quote #2

Change the direction of the slashes.
Example:
PHP Code:
static const String:SOUND_AUTOSHOTGUN[]         = "weapons\auto_shotgun\gunfire\auto_shotgun_fire_1.wav"
to
PHP Code:
static const String:SOUND_AUTOSHOTGUN[]         = "weapons/auto_shotgun/gunfire/auto_shotgun_fire_1.wav"
Darkness_ is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 03-16-2015 , 21:09   Re: Invalid character constant?
Reply With Quote #3

or \\ since \ is use for an escape character
Mathias. is offline
DeathChaos25
Senior Member
Join Date: Jan 2014
Location: Puerto Rico
Old 03-16-2015 , 21:11   Re: Invalid character constant?
Reply With Quote #4

/)_-

I knew something was up with the written strings themselves, I always tend to make the stupidest and smallest mistakes every single time.

Thanks for the responses.

Edit : Yep, that was it.
__________________

Last edited by DeathChaos25; 03-16-2015 at 21:13.
DeathChaos25 is offline
Reply



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 13:41.


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