Hello. I Am Coding My Gamemode And I Have Added The Following To The init.lua
Im Getting The Error: myfile.lua:1: attempt to index global 'ply' (a nil value)
Here Is my Code:
[CODE]if ply:IsAdmin() or ply:IsSuperAdmin() then
timer.Simple(0, function()
for k, v in pairs(player.GetAll()) do
SendChat(ply, Color( 0, 150, 255 ), "Hello "..ply:Nick().." you are a/an "..ply:GetUserGroup().." ")
end
function GM:PlayerConnect( name )
print("Welcome Back Admin " .. name .. ", :D")
end
function GM:PlayerAuthed( ply, steamID, uniqueID, ip )
print(" "..ply:GetUserGroup().." " .. ply:Nick() .. ", has Authorized.")
end
end)
else
SendChat(ply, Color( 255, 0, 255 ), "Don't forget to donate to the server!" )
end[/CODE]
[QUOTE=knackrack;39494481]Hello. I Am Coding My Gamemode And I Have Added The Following To The init.lua
Im Getting The Error: myfile.lua:1: attempt to index global 'ply' (a nil value)
Here Is my Code:
[CODE]if ply:IsAdmin() or ply:IsSuperAdmin() then
timer.Simple(0, function()
for k, v in pairs(player.GetAll()) do
SendChat(ply, Color( 0, 150, 255 ), "Hello "..ply:Nick().." you are a/an "..ply:GetUserGroup().." ")
end
function GM:PlayerConnect( name )
print("Welcome Back Admin " .. name .. ", :D")
end
function GM:PlayerAuthed( ply, steamID, uniqueID, ip )
print(" "..ply:GetUserGroup().." " .. ply:Nick() .. ", has Authorized.")
end
end)
else
SendChat(ply, Color( 255, 0, 255 ), "Don't forget to donate to the server!" )
end[/CODE][/QUOTE]
Could you post the whole function ??
[QUOTE=R@Rdeathmatch;39494587]Could you post the whole function ??[/QUOTE]
Thats is all i have that on a file called admincc.lua :P and i have included that on my init.lua
- snip -
What I meant was put something around the first if.. it is just there outside a function..
or am I wrong?
[QUOTE=addemod;39494701]Try surround it with a 'function (ply)'[/QUOTE]
I Have tryed that is still not working :(
[QUOTE=knackrack;39494600]Thats is all i have that on a file called admincc.lua :P and i have included that on my init.lua[/QUOTE]
Basically you have just the code from the function. Anyway try this.
[LUA]
function GM:PlayerInitialSpawn( ply )
if ply:IsAdmin() or ply:IsSuperAdmin() then
timer.Simple(0, function()
for k, v in pairs(player.GetAll()) do
SendChat(ply, Color( 0, 150, 255 ), "Hello "..ply:Nick().." you are a/an "..ply:GetUserGroup().." ")
end
function GM:PlayerConnect( name )
print("Welcome Back Admin " .. name .. ", :D")
end
function GM:PlayerAuthed( ply, steamID, uniqueID, ip )
print(" "..ply:GetUserGroup().." " .. ply:Nick() .. ", has Authorized.")
end
end
[/LUA]
Check the code again, I think you missed some end's
[QUOTE=R@Rdeathmatch;39494786]Basically you have just the code from the function. Anyway try this.
[LUA]
function GM:PlayerInitialSpawn( ply )
if ply:IsAdmin() or ply:IsSuperAdmin() then
timer.Simple(0, function()
for k, v in pairs(player.GetAll()) do
SendChat(ply, Color( 0, 150, 255 ), "Hello "..ply:Nick().." you are a/an "..ply:GetUserGroup().." ")
end
function GM:PlayerConnect( name )
print("Welcome Back Admin " .. name .. ", :D")
end
function GM:PlayerAuthed( ply, steamID, uniqueID, ip )
print(" "..ply:GetUserGroup().." " .. ply:Nick() .. ", has Authorized.")
end
end
[/LUA]
Check the code again, I think you missed some end's[/QUOTE]
I Have Tryed That Is Not Working :( (no any end missed)
[QUOTE=knackrack;39495144]I Have Tryed That Is Not Working :( (no any end missed)[/QUOTE]
Are you getting any errors? Also please don't capitalize ever first letter in your sentence, you don't speak like that, don't type like that.
[QUOTE=Pandaman09;39495246]Are you getting any errors? Also please don't capitalize ever first letter in your sentence, you don't speak like that, don't type like that.[/QUOTE]
Yes im getting the following error: [CODE][ERROR] gamemodes/basewars/gamemode/admincc.lua:13: ')' expected (to close '(' at line 3) near '<eof>'
1. unknown - gamemodes/basewars/gamemode/admincc.lua:0[/CODE]
Sorry guys im new to lua im still learning :(
Thank you all for quick reply and support :)
Im Trying To Script My Own Basewars :D
[QUOTE=knackrack;39495427]Yes im getting the following error: [CODE][ERROR] gamemodes/basewars/gamemode/admincc.lua:13: ')' expected (to close '(' at line 3) near '<eof>'
1. unknown - gamemodes/basewars/gamemode/admincc.lua:0[/CODE]
Sorry guys im new to lua im still learning :(
Thank you all for quick reply and support :)
Im Trying To Script My Own Basewars :D[/QUOTE]
If you ever get an error and you want someone's help, the minimum we need is the line, but it is always more helpful to give the entire function or most of it
[QUOTE=knackrack;39494481]Hello. I Am Coding My Gamemode And I Have Added The Following To The init.lua
Im Getting The Error: myfile.lua:1: attempt to index global 'ply' (a nil value)
Here Is my Code:
[CODE]if ply:IsAdmin() or ply:IsSuperAdmin() then
timer.Simple(0, function()
for k, v in pairs(player.GetAll()) do
SendChat(ply, Color( 0, 150, 255 ), "Hello "..ply:Nick().." you are a/an "..ply:GetUserGroup().." ")
end
function GM:PlayerConnect( name )
print("Welcome Back Admin " .. name .. ", :D")
end
function GM:PlayerAuthed( ply, steamID, uniqueID, ip )
print(" "..ply:GetUserGroup().." " .. ply:Nick() .. ", has Authorized.")
end
end)
else
SendChat(ply, Color( 255, 0, 255 ), "Don't forget to donate to the server!" )
end[/CODE][/QUOTE]
you need to define what 'ply' is in a hook
-Shniped-
[QUOTE=Pandaman09;39495453]If you ever get an error and you want someone's help, the minimum we need is the line, but it is always more helpful to give the entire function or most of it[/QUOTE]
this is the only error im getting :(
The error again in photo: [url]http://prntscr.com/rs31s[/url]
The Full File In Photo: [url]http://prntscr.com/rs39m[/url]
[QUOTE=knackrack;39495427]Yes im getting the following error: [CODE][ERROR] gamemodes/basewars/gamemode/admincc.lua:13: ')' expected (to close '(' at line 3) near '<eof>'
1. unknown - gamemodes/basewars/gamemode/admincc.lua:0[/CODE][/QUOTE]
What does <eof> mean ??
Knackrack I fixed it.
[editline]6th February 2013[/editline]
You didn't finish your timer.simple( function()
[QUOTE=R@Rdeathmatch;39495575]What does <eof> mean ??[/QUOTE]
i Don't know i think is a end problem or something ... :(
Again. I fixed it please try out my code
[lua]
function GM:PlayerConnect( name )
print("Welcom back Admin ".. name ..", :D")
end
function GM:PlayerAuthed( ply, steamID, UniqueID, ip )
print(""..ply:GetUserGroup().." ".. ply:Nick() ..", has Authorized.")
end
function GM:PlayerInitialSpawn( ply )
if ply:IsAdmin() or ply:IsSuperAdmin() then
SendChat(ply, Color( 0, 150, 255), "Hello ".. ply:Nick() .." you are a/an".. ply:GetUserGroup() ..".")
end
end
[/lua]
Please for the love of god, learn to indent.
Also I don't think you can create functions inside other functions, so make them before you call them.
EDIT: I just read that... Why the F are you using a for loop, when the function calls 1 player?
[QUOTE=DrJenkins;39495626]Again. I fixed it please try out my code[/QUOTE]
Yup i see my problem but im putting ")" in the end on the last line but i still have problem
You can Send me the code completed fixed ? Thanks man :D
-snip-
[QUOTE=R@Rdeathmatch;39495575]What does <eof> mean ??[/QUOTE]
It means End of File
I looked at his code wrong because of the way it was spaced out.
[QUOTE=knackrack;39495666]Yup i see my problem but im putting ")" in the end on the last line but i still have problem
You can Send me the code completed fixed ? Thanks man :D[/QUOTE]
So what was the problem ?
If you're too fucking stupid to look at other posts where I post the code. Then don't ask for help.
[QUOTE=Pandaman09;39495657][lua]
function GM:PlayerConnect( name )
print("Welcom back Admin ".. name ..", :D")
end
function GM:PlayerAuthed( ply, steamID, UniqueID, ip )
print(""..ply:GetUserGroup().." ".. ply:Nick() ..", has Authorized.")
end
function GM:PlayerInitialSpawn( ply )
if ply:IsAdmin() or ply:IsSuperAdmin() then
SendChat(ply, Color( 0, 150, 255), "Hello ".. ply:Nick() .." you are a/an".. ply:GetUserGroup() ..".")
end
end
[/lua]
Please for the love of god, learn to indent.
Also I don't think you can create functions inside other functions, so make them before you call them.
EDIT: I just read that... Why the F are you using a for loop, when the function calls 1 player?[/QUOTE]
Ok With your code my script is working without any errors :D
but is not working ingame i need to include that on serverside lua or clientside ?
[editline]6th February 2013[/editline]
[QUOTE=DrJenkins;39495743]If you're too fucking stupid to look at other posts where I post the code. Then don't ask for help.[/QUOTE]
Yes i have see your answer is the same with pandaman09 your code is working but i still don't know if i need to put it on serverside lua or clientside lua :(
The code should be server sided only?
yeah they are all server only.
Yeah Works Great Thanks To All You Help Me With My First Gamemode :DDD
I love how he doesn't really understand how to make a game mode, but one of his top priorities was the donation thing
why do people like you not understand that [b]you have no place in programming, coding, scripting, or anything that requires the mental ability of anything above a toddler[/b]
[QUOTE=>>;39497180]why do people like you not understand that [b]you have no place in programming, coding, scripting, or anything that requires the mental ability of anything above a toddler[/b][/QUOTE]
Wtf man, what is your problem ??
Yeah his new to Lua and I don't think he diden't try to find the solution by himself, but maybe he couldn't find it. So if you can't find the solution you come on facepunch and ask for help.
So you don't have to be rude.
Sorry, you need to Log In to post a reply to this thread.