Expected = please read the code (NEWB CODER)

Had to move this to this subforum:

Hi guys im so annoyed at this dosn’t matter what i do it moans about expected “=” near chanceofjam

local jamsound = Sound(“JAMOY/jam/jam.wav”)
local OnBullet = 1 // When chanceofjam = 1 gun jams
local chanceofjam = math.random(1,self.JamChance) // from 1 to a number specifyed in the gun file so if it was 100 in the file it would be 1 in 100 rounds that jam the gun theoreticaly

Print(chanceofjam)                     // To make sure it was working dont know

[LUA]If chanceofjam == OnBullet then  // HERE it moans when i put 1 question mark or 2 dosn't matter!
	playercanshoot = false

What im trying to do is take a specifyed number from the swep file. see if a random number lands on 1 from 1 to the number specifyed in the swep. Higher the number the less chance of jaming theoreticaly. And when it jams it stops the player from firing and takes 1 bullet out. you have to press r to reload and make player can shoot = true. Simple but only the relevant code is shown

someone give me a tip on what im doing wrong please?
Thanks guys! this is my first real lua piece so be kind :smiley:

[editline]27th February 2011[/editline]

Reply fast please if you wont mind :smiley:

Please post your exact error as well as put your code in [noparse][lua][/lua][/noparse] tags.
Note: if that’s your actual code, you’ll probably get some errors because “Print” and “If” should not be capitalized.

He means use the lua tags in your post not in your title


this language is too case sensitive D:

[editline]27th February 2011[/editline]

That if statement was my problem thanks guys, i was up for about 15 hours yesterday 3 pm til 5 am and i scribbled this code down… and the question.

Thanks guys

Hey i am only using note pad but i agree totaly :smiley:

You should be using notepad++ with the gmod lua extension.

If thats the exact code your if needs to be a lower case i.

Damn, ninja’d about the I

How can you be ninja’d if those people posted it a whole week before you? :v:

then they’re a fucking fast ninja

no you are just slow