Different errors in matching script - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Different errors in matching script (
/showthread.php?tid=412715)
Different errors in matching script -
DLR - 02.02.2013
expected token: "-string end-", but found "-identifier-"
pawn Код:
case 2: division = "B" { // Central
invalid function or declaration
pawn Код:
case 3: division = "C" { // Eastern
I get the first error for the first 2 cases, then the second error for every case after that.
Every case within this switch is the same, just a different division string, and different rank strings. Nothing else is changed...
pawn Код:
case 1: division = "A" { // Western
switch(PlayerInfo[targetid][pRank])
{
case 1: rank = "Prob. Officer";
case 2: rank = "Snr. Officer";
case 3: rank = "Sergeant";
case 4: rank = "Inspector";
case 5: rank = "Chief Inspector";
case 6: rank = "Superintendent";
case 7: rank = "Chief Superintendent";
default: rank = "OIT";
}
}
Re: Different errors in matching script -
Misiur - 02.02.2013
This is not how switch works.
pawn Код:
switch(division) {
case 'A': {
(...)
}
case 'B': {
(...)
}
default: {
(...)
}
}
Also switch _won't work_ with strings. As you can see there is 'A', not "A", so I'm comparing char, not string. You have to use strcmp with if/elseif/else control structure to compare strings.
#e:
In case you want to assign division, simply move the division = X after the curly brace
Re: Different errors in matching script -
DLR - 02.02.2013
That wasn't the problem...
pawn Код:
case 3: division = "C" { // Eastern
Should be written...
pawn Код:
case 3: { division = "C"; // Eastern
That's all it was.