• Automatic adverts
    3 replies, posted
Hello, i need a addon like ulx has. automatic adverts like the same what darkrp has. with: [B]Type /buyfood <Type> (e.g: /buyfood melon) T[/B] I hope you guys know this addon Thanks Rickyboy12367
Here's a very basic script I use. Credits to Overv for the server-side chat.AddText [lua]if SERVER then AddCSLuaFile() chat = { } function chat.AddText( ... ) local arg = {...} if ( type( arg[1] ) == "Player" ) then ply = arg[1] end umsg.Start( "AddText", ply ) umsg.Short( #arg ) for _, v in pairs( arg ) do if ( type( v ) == "string" ) then umsg.String( v ) elseif ( type ( v ) == "table" ) then umsg.Short( v.r ) umsg.Short( v.g ) umsg.Short( v.b ) umsg.Short( v.a ) end end umsg.End( ) end local ads = { "Join our TeamSpeak server! teamspeak.sammyservers.com", "Visit SammyServers.com and join in with the community!", "Want higher prop limits and access to more tools? Donate at SammyServers.com", "Play our new minigame at the forum for your chance to win various prizes, including a $1,000,000 jackpot!", "You can now donate for custom connect places! Simply click GeoIP donations from our donations menu on the website!", "Interested in running your own minecraft server? We're the server experts so you don't have to be! getnodecraft.net", "This server is running the fantastic addon Check 'Em. Download from Steam Workshop!", "Request an admin's assistance with /report. Example: /report player prop killed me" } local num = 1 timer.Create("Advertisements", 180, 0, function() for k,v in pairs(player.GetAll()) do chat.AddText(v, Color(math.random(0,255),math.random(0,255),math.random(0,255)), "[Advertisement] ", Color(255,255,255), ads[num]) end num = (num + 1 > #ads) and 1 or num + 1 end) else usermessage.Hook( "AddText", function( um ) local argc = um:ReadShort( ) local args = { } for i = 1, argc / 2, 1 do table.insert( args, Color( um:ReadShort( ), um:ReadShort( ), um:ReadShort( ), um:ReadShort( ) ) ) table.insert( args, um:ReadString( ) ) end chat.AddText( unpack( args ) ) end ) end[/lua] You could run it client side and negate the need for the chat.AddText server-side, but whatever.
Thanks for this code. i just need to place it into my addons folder with the name adverts.lua or something? Thanks Rickyboy
[QUOTE=rickyboy12367;38651459]Thanks for this code. i just need to place it into my addons folder with the name adverts.lua or something? Thanks Rickyboy[/QUOTE] Any server side lua file. lua/autorun/server/adverts.lua would be a good place.
Sorry, you need to Log In to post a reply to this thread.