Sparrow Posted December 19, 2011 Share Posted December 19, 2011 Hello all, Today visite some severs and I saw that many players lagging, so I think to do a pingkick script. Because I'm new in scripting, I don't know the functions, so can someone post them in reply? I'll try to script this script. Thank you. Link to comment
myonlake Posted December 19, 2011 Share Posted December 19, 2011 Hello there, new scripter! As you're a new scripter, I'd suggest to start from the scripting manual. I started my scripting from there aswell, now I am an advanced scripter (I think, heh'). 'Creating a server' manual: https://wiki.multitheftauto.com/wiki/Server_Manual Scripting introduction: https://wiki.multitheftauto.com/wiki/Scr ... troduction Server-Side Functions: https://wiki.multitheftauto.com/wiki/Ser ... _Functions Events: https://wiki.multitheftauto.com/wiki/Ser ... ing_Events Client-Side Functions: https://wiki.multitheftauto.com/wiki/Cli ... _Functions Events: https://wiki.multitheftauto.com/wiki/Cli ... ing_Events Link to comment
Sparrow Posted December 19, 2011 Author Share Posted December 19, 2011 Is it as that? Client: local maxPing = 350 function checkPing() local ping = getPlayerPing(source) if (ping > 350) then outputChatBox("#FF0000Your ping is high, lower it please.", source) end end addEventHandler("onPlayerJoin", getRootElement(), checkPing) function getPings() if getPlayerPing(getLocalPlayer()) >= maxPing then triggerServerEvent("ping.onKickHighPing",getLocalPlayer(),getPlayerPing(getLocalPlayer())) end end setTimer (5000,0) Server: local maxPing = 350 function onHighPing() kickPlayer(source,source,"Your ping is over the limit. (over "..maxPing..")") outputChatBox("#FF0000"..getPlayerName(source).."#FF0000 has been kicked for high ping.",root,255,0,0,true) end addEvent( "ping.onKickHighPing", true ) addEventHandler( "ping.onKickHighPing", getRootElement(), onHighPing ) Link to comment
codeluaeveryday Posted December 19, 2011 Share Posted December 19, 2011 Hey, your settimer is incorrect. Events are wrong UNTESTED: Client: function checkPing() local ping = getPlayerPing(source) if (ping > 350) then outputChatBox("#FF0000Your ping is high, lower it please.", source,255,255,255,true) end end addEventHandler("onClientPlayerJoin", getRootElement(), checkPing) function triggerPingKicker() if getPlayerPing(getLocalPlayer()) >= maxPing then triggerServerEvent("ping.onKickHighPing",getLocalPlayer(),getPlayerPing(getLocalPlayer())) end end setTimer(triggerPingKicker,5000,0) Server: local maxPing = 350 function onHighPing() kickPlayer ( thePlayer, "Your ping is over the limit. (over "..maxPing..")" ) outputChatBox("#FF0000"..getPlayerName(source).."#FF0000 has been kicked for high ping.",root,255,0,0,true) end addEvent( "ping.onKickHighPing", true ) addEventHandler( "ping.onKickHighPing", getRootElement(), onHighPing ) Link to comment
Sparrow Posted December 19, 2011 Author Share Posted December 19, 2011 I'll try this. You only change setTimer(triggerPingKicker,5000,0) ? Link to comment
codeluaeveryday Posted December 19, 2011 Share Posted December 19, 2011 Lol i changed many things. In your client you used onPlayerJoin as the event handler?!?!?!!? UM ?!?!? Its onClientPlayerJoin... and outputChatBox("#FF0000Your ping is high, lower it please.", source) didnt support colors, now it does.... and ofc your settimer was WRONG! and kickPlayer in the server was used incorrectly?!?!?!?!?! I basically simplified it! Could you please read my code carefully next time! I really hate justifying myself. Link to comment
Sparrow Posted December 19, 2011 Author Share Posted December 19, 2011 Thank you, I'm new scripter for that there is failers on it Link to comment
codeluaeveryday Posted December 19, 2011 Share Posted December 19, 2011 Your welcome, sorry for being very stubborn. Best wishes to you. Does the script work? If not what are the debug errors shown in /debugscript 3? Link to comment
Sparrow Posted December 19, 2011 Author Share Posted December 19, 2011 This are the errors in /debigscript 3 Link to comment
codeluaeveryday Posted December 19, 2011 Share Posted December 19, 2011 Client: function checkPing() local ping = getPlayerPing(source) if (ping > 350) then outputChatBox("#FF0000Your ping is high, lower it please.", source,255,255,255,true) end end addEventHandler("onClientPlayerJoin", getRootElement(), checkPing) function triggerPingKicker() if getPlayerPing(getPlayerName(getLocalPlayer())) >= maxPing then triggerServerEvent("ping.onKickHighPing",getLocalPlayer(),getPlayerPing(getLocalPlayer())) end end setTimer(triggerPingKicker,5000,0) Server: local maxPing = 350 function onHighPing() kickPlayer ( thePlayer, "Your ping is over the limit. (over "..maxPing..")" ) outputChatBox("#FF0000"..getPlayerName(source).."#FF0000 has been kicked for high ping.",root,255,0,0,true) end addEvent( "ping.onKickHighPing", true ) addEventHandler( "ping.onKickHighPing", getRootElement(), onHighPing ) Try this one. i attempted to use getPlayerName(getLocalPlayer()). Let me know of more errors if any persist. Link to comment
Castillo Posted December 19, 2011 Share Posted December 19, 2011 -- client side: local maxPing = 350 function checkPing() local ping = getPlayerPing(source) if (ping > tonumber(maxPing)) then outputChatBox("#FF0000Your ping is high, lower it please.", source,255,255,255,true) end end addEventHandler("onClientPlayerJoin", getRootElement(), checkPing) function triggerPingKicker() if (getPlayerPing(localPlayer) >= tonumber(maxPing)) then triggerServerEvent("ping.onKickHighPing",localPlayer,maxPing) end end setTimer(triggerPingKicker,5000,0) -- server side: function onHighPing(maxPing) kickPlayer ( thePlayer, "Your ping is over the limit. (over "..maxPing..")" ) outputChatBox("#FF0000"..getPlayerName(source).."#FF0000 has been kicked for high ping.",root,255,0,0,true) end addEvent( "ping.onKickHighPing", true ) addEventHandler( "ping.onKickHighPing", getRootElement(), onHighPing ) Link to comment
codeluaeveryday Posted December 19, 2011 Share Posted December 19, 2011 lol nvm, Castillo to the rescue. Link to comment
Sparrow Posted December 19, 2011 Author Share Posted December 19, 2011 This is the errors @csmit. @SolidSnake, thank you, no errors on it. Thank you both for helping. Link to comment
Sparrow Posted December 30, 2011 Author Share Posted December 30, 2011 Sorry for this but, when I start my server mins ago and I get this error: [2011-12-30 19:50:40] WARNING: ping\ping_server.lua:4: Access denied @ 'kickPlayer' Link to comment
Xeno Posted December 30, 2011 Share Posted December 30, 2011 Go to your admin panel and go to the resources section and press "manage ACL" - Click on the admin bit and press addObject and put in: resource.ping Link to comment
Sparrow Posted December 30, 2011 Author Share Posted December 30, 2011 ok I'll try. EDIT: It's not working, still the same problem. Link to comment
JR10 Posted December 30, 2011 Share Posted December 30, 2011 Post your ACL, you probably didn't add it correctly. Link to comment
Al3grab Posted December 31, 2011 Share Posted December 31, 2011 you can remove all these resources and add <object name="resource.*"></object> Link to comment
BinSlayer1 Posted December 31, 2011 Share Posted December 31, 2011 you can remove all these resources and add <object name="resource.*"></object> But that defeats the purpose of ACL.. You might as well do user.* and it's as good as deleted Link to comment
Sparrow Posted December 31, 2011 Author Share Posted December 31, 2011 you can remove all these resources and add <object name="resource.*"></object> It's working now, thank you but the probelems stll in mtaserver.exe Link to comment
Al3grab Posted December 31, 2011 Share Posted December 31, 2011 you can remove all these resources and add <object name="resource.*"></object> But that defeats the purpose of ACL.. You might as well do user.* and it's as good as deleted giving all resources admin rights wont make a problem , because you are the one who installing the resources so you must be sure about what you are installing =D Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now