Errors..
#1

This is giving me errors.
Код:
if(classid == 0 || classid == 1 || classid == 2 || classid == 3 || classid == 4) {
gTeam[playerid] = TEAM_Usa;
} else if(classid >= 5 && classid <= 9) {
gTeam[playerid] = TEAM_Iraq;
} else if(classid >= 10 && classid <= 14) {
gTeam[playerid] = TEAM_Nazi;
} else if(classid >= 15 && classid <= 19) {
gTeam[playerid] = TEAM_Alqaida;
}
}
Quote:

C:\DOCUME~1\17FE8~1.MRK\SKRIVB~1\Coding\PAWNO\pawn o\gamemode.pwn(83) : error 029: invalid expression, assumed zero
C:\DOCUME~1\17FE8~1.MRK\SKRIVB~1\Coding\PAWNO\pawn o\gamemode.pwn(85) : error 029: invalid expression, assumed zero
C:\DOCUME~1\17FE8~1.MRK\SKRIVB~1\Coding\PAWNO\pawn o\gamemode.pwn(87) : error 029: invalid expression, assumed zero
C:\DOCUME~1\17FE8~1.MRK\SKRIVB~1\Coding\PAWNO\pawn o\gamemode.pwn(89) : error 029: invalid expression, assumed zero

Reply
#2

pawn Код:
if(classid >= 0 && classid <= 4) gTeam[playerid] = TEAM_Usa;
else if(classid >= 5 && classid <= 9) gTeam[playerid] = TEAM_Iraq;
else if(classid >= 10 && classid <= 14) gTeam[playerid] = TEAM_Nazi;
else if(classid >= 15 && classid <= 19) gTeam[playerid] = TEAM_Alqaida;
Try this, I believe you had way too many brackets.
Reply
#3

Try using a switch statement.

pawn Код:
switch(classid)
{
    case 0..4: gTeam[playerid] = TEAM_Usa;
    case 5..9: gTeam[playerid] = TEAM_Iraq;
    case 10..14: gTeam[playerid] = TEAM_Nazi;
    case 15..19: gTeam[playerid] = TEAM_Alqaida;
}
Reply
#4

switch works just like if-else if's, it's just a bit easier to read.

You guys should learn to respect the way other people are scripting, if he uses if-else if's let him use them.

He asked for help with the errors, not with the way he scripts.
Reply
#5

Quote:
Originally Posted by Finn
switch works just like if-else if's, it's just a bit easier to read.

You guys should learn to respect the way other people are scripting, if he uses if-else if's let him use them.

He asked for help with the errors, not with the way he scripts.
whoaaaa

Ok, and tell me what is wrong with showing someone a different way to script it?

Yes, he posted about the errors. But if those errors just keep getting fixed by people, the poster is not going to learn. And theres no harm in showing another method...

Reply
#6

Quote:
Originally Posted by Finn
switch works just like if-else if's, it's just a bit easier to read.

You guys should learn to respect the way other people are scripting, if he uses if-else if's let him use them.

He asked for help with the errors, not with the way he scripts.
abit uppie? theres nothing wrong with showing more then one method, it just shows the guy other ways of doing things and other methods for future use.
Reply
#7

Yeah, there's nothing wrong with that, but if you're showing different methods of scripting something, show ALL of the different methods, because otherwise it looks like (atleast in my eyes) that you're saying 'you're doing it wrong, this is the correct way to do this' and to be honest that is pretty offensive for the beginner.

But whatever, do what you want, this is just my opinion.

IMO you guys should write a tutorial about different methods of doing stuff, so you don't need to post them individually for every newbie scripter. (:
Reply
#8

I think its very good to show other ways..
But i get..
Quote:

C:\DOCUME~1\17FE8~1.MRK\SKRIVB~1\Coding\PAWNO\pawn o\gamemode.pwn(127) : error 029: invalid expression, assumed zero
C:\DOCUME~1\17FE8~1.MRK\SKRIVB~1\Coding\PAWNO\pawn o\gamemode.pwn(12 : error 001: expected token: ";", but found "case"
C:\DOCUME~1\17FE8~1.MRK\SKRIVB~1\Coding\PAWNO\pawn o\gamemode.pwn(12 : error 029: invalid expression, assumed zero
C:\DOCUME~1\17FE8~1.MRK\SKRIVB~1\Coding\PAWNO\pawn o\gamemode.pwn(129) : error 001: expected token: ";", but found "case"
C:\DOCUME~1\17FE8~1.MRK\SKRIVB~1\Coding\PAWNO\pawn o\gamemode.pwn(129) : error 029: invalid expression, assumed zero
C:\DOCUME~1\17FE8~1.MRK\SKRIVB~1\Coding\PAWNO\pawn o\gamemode.pwn(130) : error 001: expected token: ";", but found "case"

Код:
SetPlayerTeamFromClass(playerid, classid)
{
switch(classid)
{
	case 0..4: gTeam[playerid] = TEAM_Usa;
	case 5..9: gTeam[playerid] = TEAM_Iraq;
	case 10..14: gTeam[playerid] = TEAM_Nazi;
	case 15..19: gTeam[playerid] = TEAM_Alqaida;
}
}
hmm..?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)