SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 20/02/2009, 06:18 AM   #1
SuperS0nic
Big Clucker
 
Join Date: Jan 2009
Posts: 169
Reputation: 0
Default Errors..

This is giving me errors.
Code:
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
SuperS0nic is offline  
Old 20/02/2009, 09:10 AM   #2
Finn
High-roller
 
Join Date: Jan 2008
Posts: 1,464
Reputation: 382
Default Re: Errors..

pawn Code:
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.
Finn is offline  
Old 20/02/2009, 09:14 AM   #3
kc
Gangsta
 
kc's Avatar
 
Join Date: Aug 2007
Posts: 618
Reputation: 115
Default Re: Errors..

Try using a switch statement.

pawn Code:
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;
}
kc is offline  
Old 20/02/2009, 09:20 AM   #4
Finn
High-roller
 
Join Date: Jan 2008
Posts: 1,464
Reputation: 382
Default Re: Errors..

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.
Finn is offline  
Old 20/02/2009, 09:36 AM   #5
kc
Gangsta
 
kc's Avatar
 
Join Date: Aug 2007
Posts: 618
Reputation: 115
Default Re: Errors..

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...

kc is offline  
Old 20/02/2009, 09:41 AM   #6
Nimphious
Huge Clucker
 
Join Date: Dec 2008
Posts: 371
Reputation: 2
Default Re: Errors..

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.
Nimphious is offline  
Old 20/02/2009, 09:55 AM   #7
Finn
High-roller
 
Join Date: Jan 2008
Posts: 1,464
Reputation: 382
Default Re: Errors..

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. (:
Finn is offline  
Old 20/02/2009, 10:27 AM   #8
SuperS0nic
Big Clucker
 
Join Date: Jan 2009
Posts: 169
Reputation: 0
Default Re: Errors..

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"
Code:
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..?
SuperS0nic is offline  
 

Thread Tools
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
New errors that ive never seen before Torran Help Archive 2 02/03/2010 02:20 PM
[Errors]Compiling Errors SamAlexSam Help Archive 2 04/02/2010 01:31 PM
Common compiling errors - READ BEFORE POSTING ERRORS Streetplaya Help Archive 0 23/01/2010 11:20 AM
Shows Errors but no errors in this line Kane_Phoenix Help Archive 2 31/03/2009 02:38 PM


All times are GMT. The time now is 01:10 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.