String invalid character constant
#1

Код:
#define FACTION_TYPE_NONE	0
#define FACTION_TYPE_POLICE     1
#define FACTION_TYPE_MEDIC	2
#define FACTION_TYPE_GOV        3
#define FACTION_TYPE_NEWS       4
#define FACTION_TYPE_WEAPONS    5
#define FACTION_TYPE_DRUGS      6
Код:
stock GetFactionTypeName(type)
{
	new typestr[20];
	switch(type)
	{
		case FACTION_TYPE_NONE: typestr = 'None'; < 4492
		case FACTION_TYPE_POLICE: typestr = 'Police';
		case FACTION_TYPE_MEDIC: typestr = 'Fire & Medic';
		case FACTION_TYPE_GOV: typestr = 'Government';
		case FACTION_TYPE_NEWS: typestr = 'News';
		case FACTION_TYPE_WEAPONS: typestr = 'Weapon dist.';
		case FACTION_TYPE_DRUGS: typestr = 'Drug dist.';
		default: typestr = 'undefined';
	}
	return typestr;
}
Код:
C:\Users\Administrator\Desktop\Script from scratch new\gamemodes\script.pwn(4492) : error 027: invalid character constant
C:\Users\Administrator\Desktop\Script from scratch new\gamemodes\script.pwn(4492 -- 4493) : warning 215: expression has no effect
C:\Users\Administrator\Desktop\Script from scratch new\gamemodes\script.pwn(4493) : error 001: expected token: ";", but found "case"
C:\Users\Administrator\Desktop\Script from scratch new\gamemodes\script.pwn(4493) : error 014: invalid statement; not in switch
C:\Users\Administrator\Desktop\Script from scratch new\gamemodes\script.pwn(4493) : fatal error 107: too many error messages on one line
Reply
#2

Single quotes ('a') are for single character, use "" for strings.
Reply
#3

PHP код:
stock GetFactionTypeName(type)
{
    new 
typestr[20];
    switch(
type)
    {
        case 
FACTION_TYPE_NONEtypestr "None";
        case 
FACTION_TYPE_POLICEtypestr "Police";
        case 
FACTION_TYPE_MEDICtypestr "Fire & Medic";
        case 
FACTION_TYPE_GOVtypestr "Government";
        case 
FACTION_TYPE_NEWStypestr "News";
        case 
FACTION_TYPE_WEAPONStypestr "Weapon dist.";
        case 
FACTION_TYPE_DRUGStypestr "Drug dist.";
        default: 
typestr "undefined";
    }
    return 
typestr;

Use " to enclose strings as opposed to '. A good usage for ' is for characters, for example:

PHP код:
public OnPlayerText(playeridtext[])
{
    if(
text[0] == '#'// The first character of the text is #
    
else if(text[6] == 'A'// The 7th character of the text is a capital A 
etc.
Reply
#4

Aha, stupid mistake of me, thanks for the help.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)