error 001: expected token: "-string end-", but found "-identifier-" Any Ideas?
#1

Right, I know its something to do with strings, but not quite sure...
(the code is in a dialog)
pawn Code:
if(inputtext == "LV"||"LS"||"SF"||"AA")
Code:
error 001: expected token: "-string end-", but found "-identifier-"
Any ideas?

Thanks

Jack_Rocker
Reply
#2

PHP Code:
if(!strcmp(inputtext"LV"true) || !strcmp(inputtext"LS"true) || !strcmp(inputtext"LS"true) || !strcmp(inputtext"AA"true)) 
Reply
#3

You can't compare strings like that at all in Pawn.

First of all, you need to use strcmp() to compare values to strings, and you can't use quotation marks like that.

Secondly, you can't use logical 'or' statements like that, you quite literally need to compare the value to the string each time.

pawn Code:
if(!strcmp(inputtext, "LV", true) || !strcmp(inputtext, "LS", true) || !strcmp(inputtext, "SF", true) || !strcmp(inputtext, "AA", true))
Should be right, my memory of the syntax in Pawn is pretty bad.
Reply
#4

pawn Code:
if(inputtext[0] == 'L' && (inputtext[1] == 'S' ||inputtext[1] == 'F' ||inputtext[1] == 'V') && inputtext[2] == EOS)
{
//do something
}
for strings with a size bigger use strcmp .. https://sampwiki.blast.hk/wiki/Strcmp
Reply
#5

Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)