Creating a command to allow/disallow Moderators to spawn SENTs?
7 replies, posted
I've been trying to create a command to grant Moderators permission to spawn SENTs, though It's not working, got no error messages.
function allowSENTS(ply)
if ply:IsUserGroup("Founder") and
text == string.ToLower("!modprop") then ply:ChatPrint(Color(58, 255, 78)"[Granted]"Color(255,255,255)" Permission granted!")
ply:IsUserGroup("Moderator") return true
end
hook.Add("PlayerSpawnSENT", "AllowUsersSENT", function(Client)
if (client:IsUserGroup("Admin") or client:IsUserGroup("Test") or client:IsUserGroup("Founder")) or allowSENTS() then
return true
else
return false
and ply:ChatPrint(Color(211, 14, 14)"[Error]"Color(255,255,255)" You lack the permission to spawn entities!")
end
end)
You have too many if statements, dont do that...
1. Anything after the 'return' is not executed.
2. Use ply:IsAdmin() instead to recude if statements
3. Lua is case sensitive, so 'Client' is different from 'client'
Seems like you used copypastes from web.
What is text in function allowSENTS? It's not defined anywhere
I think that Founder is not your usergroup. Usergroup has id-names (superadmin, admin, user). You're writing their "Pretty Names"
There's no function as string.ToLower, there's string.lower
You need to make lower the text, not the !modprop
ply:ChatPrint doesn't support colors
Every arguments needs to be separated by a comma. Learn Lua's syntax
else with different condition can be only as "elseif something then". Learn If/ElseIf/Else structure
You specified variable Client, but everything uses client. Variables are Case-sensitive
and can be used in return to have a choice to return something not-false. In your case the expression "return false and ply:ChatPrint" will not work because first returned thing is false and the operator is and. Lua will automatically stop looking at next expressions if it finds false near and
Your code is a shit, you don't know lua, and the code isn't optimized.
Learn by links I gave and come back later
Mate, I know my code is shit, why do you think I am trying to make scripts?
You don't learn jackshit from just reading wiki's, you gotta try and fail.
but how do you know what to try without reading wikis
I think you just took a peek at the wiki, then quickly got bored after you realized you'd have to do a bit of reading and learning.
Even though you read wiki's doesn't mean you're an expert, at least I haven't seen any similar codes to the one I'm trying to create.
The example on the SANDBOX/PlayerSpawnSENT wiki page is pretty much what you want. Just replace "ply:IsAdmin" with Player/IsUserGroup or have a table with allowed usergroups and check if Player/GetUserGroup is in the table.
Sorry, you need to Log In to post a reply to this thread.