Unable to get the !donate command to work in chat. What's wrong with my script?
7 replies, posted
I have one of the two scripts that I would like to work. Neither one worked at all for me, so I'd like to see if anyone can help me on this. I must be doing something wrong because this is probably the fifth one I have. One of them being from a youtube tutorial, and 2 more being from the ULX forum (although these scripts are not related to ULX, it was in a different sub-forum)
These two are just from... wherever... but I was told they should work.
Here's the first one: (i'm not going to shameless plug my donation link so I replaced it with willreplacethisurl, just ignore that)
[CODE]function donateCommand( ply, text, public )
if( string.sub( text, 1, 7) == "!donate" ) then
gui.OpenURL("willreplacethisURL")
end
end
hook.Add( "PlayerSay", "donate", donateCommand )[/CODE]
And here is the second variation.
[CODE]function donateCommand( pl, text, public )
if (text == "!donate") then
pl:SendLua([[gui.OpenURL("willreplacethisurl")]])
end
end
end
hook.Add( "PlayerSay", "Chat", donateCommand )[/CODE]
Can anyone point out what is wrong with these scripts? Or am I just putting them in the wrong place?
[lua]
hook.Add("PlayerSay", "ChatCommand", function(ply, str, public)
if (str:lower() == "!donate") then
ply:SendLua([[gui.OpenURL("url")]])
end
end)[/lua]
SERVER SIDE
Where are you placing it?
I'll probably get rated dumb for this, but; I don't exactly know the spot to put the donate script in. I've tried every destination in the lua/autorun folder. Where should I be putting it?
garrysmod/addons/CreateFolderHere/lua/autorun/server/donatecmd.lua
then put this code inside that file;
[lua]hook.Add("PlayerSay", "ChatCommand", function(ply, str, public)
if (str:lower() == "!donate") then
ply:SendLua([[gui.OpenURL("url")]])
end
end)[/lua]
[QUOTE=Author.;46788096]garrysmod/addons/CreateFolderHere/lua/autorun/server/donatecmd.lua
then put this code inside that file;
[lua]hook.Add("PlayerSay", "ChatCommand", function(ply, str, public)
if (str:lower() == "!donate") then
ply:SendLua([[gui.OpenURL("url")]])
end
end)[/lua][/QUOTE]
Well damn. I was really hoping that was going to work since I put it in the right spot, but sadly it's still doing nothing.
/addons/donate/lua/autorun/server/donatecmd.lua
it's in the right spot so we know it's probably not that thats wrong.
Restart your game.
[QUOTE=Author.;46788379]Restart your game.[/QUOTE]
Yeah, restarting, stopping or doing anything to the server didn't help. :/
Oh well, I'll see if there is another way around this.
Sorry, you need to Log In to post a reply to this thread.