Lovinglife Posted March 12, 2010 Share Posted March 12, 2010 https://forum.multitheftauto.com/viewtop ... 08&t=21109 this is the topic about pingkicker... i wonder know how can i do that pingkicker kicks people Onplayerspawn and not Onplayerconnect...cause when ur downloading stuff ur ping is high and u get kicked...bcuz that is rly annoyin.... Plus What i would suggest is making a new topic, requesting a Ping Kicker script that will not kick anyone while a download is active from the server.so it would probably have to be client sided to check each client for if they are downloading. and if so, not kick them, and give them another 15 seconds after DL finishes before checking. to make sure their pings have returned to normal. regards Lovinglife Link to comment
karlis Posted March 12, 2010 Share Posted March 12, 2010 (edited) heres simple clientside version: --clientside pinglimit=1000 function isdownloading() if isTransferBoxActive() then setTimer(isdownloading,3000,1) else addpingkicker() end end function addpingkicker() if not pingtimer then pingtimer=setTimer(function() newping=getPlayerPing(getLocalPlayer()) if newping>=pinglimit then triggerServerEvent("kickpinger",getRootElement(),newping,pinglimit) end end,1000,0) end end addEventHandler("onClientPlayerSpawn",getRootElement(),isdownloading) --serverside function kickpinger(newping,pinglimit) kickPlayer(client,"your ping was higher than limit("..pinglimit..")!") outputChatBox("\'\'"..getPlayerName(client).."#64ff00\'\' has been kicked for too high ping("..newping..") || limit is "..pinglimit.."!",getRootElement(),100,255,0,true) end addEvent("kickpinger",true) addEventHandler("kickpinger",getRootElement(),kickpinger) please say if i forgot smthing Edited March 13, 2010 by Guest Link to comment
Gamesnert Posted March 12, 2010 Share Posted March 12, 2010 newping=getPlayerPing(getLocalPlayer) -- always returns false, try putting () behind getLocalPlayer if newping>=pinglimit then -- Error: Comparing a boolean with a number value Link to comment
Lovinglife Posted March 12, 2010 Author Share Posted March 12, 2010 heres simple clientside version: --clientside pinglimit=1000 function isdownloading() if isTransferBoxActive() then setTimer(isdownloading,3000,1) else addpingkicker() end end function addpingkicker() if not pingtimer then pingtimer=setTimer(function() newping=getPlayerPing(getLocalPlayer()) if newping>=pinglimit then triggerServerEvent("kickpinger",getRootElement(),newping) end end,1000,0) end end addEventHandler("onClientPlayerSpawn",getRootElement(),isdownloading) --serverside pinglimit=1000 function kickpinger() kickPlayer(client,"your ping was higher than limit("..pinglimit..")!") outputChatBox("\'\'"getPlayerName(client).."#64ff00\'\' has been kicked for too high ping("..newping..") || limit is "..pinglimit"!",getRootElement(),100,255,0,true) end addEvent("kickpinger",true) addEventHandler("kickpinger",getRootElement(),kickpinger) please say if i forgot smthing uhmm ty... btw i didnt understand...i got already my client and server side....what should i do with ur code? Adding it? i just see the code is a bit different than the one i got from that topic Link to comment
karlis Posted March 13, 2010 Share Posted March 13, 2010 i made this for separated use, u need run it on own, but i didnt test it so i give no grantee it will work property Link to comment
karlis Posted March 13, 2010 Share Posted March 13, 2010 basicly u need integrate that "isdownloading" function and replacing onClientPlayerJoin with onClientPlayerSpawn edit:fixed my code litle Link to comment
Lovinglife Posted March 13, 2010 Author Share Posted March 13, 2010 basicly u need integrate that "isdownloading" function and replacing onClientPlayerJoin with onClientPlayerSpawnedit:fixed my code litle wow, ty for ur "work" And is anyone able to tell me how to: outputChatBox ("Pingkicker: You will be kicked in 3 seconds, reason: Too high ping (Max: " .. maxPingValue .. ")", thePlayer, 255, 0, 0) this appear only in player chat... i need that everyone on the server can read "warning: PLAYER A got (value) ping" Link to comment
karlis Posted March 13, 2010 Share Posted March 13, 2010 replace ur "thePlayer" with GetRootElement(), anyway i dont see why u should put my work in quotes, isn't that i wrote some code from zero just to help u enough? Link to comment
Lovinglife Posted March 13, 2010 Author Share Posted March 13, 2010 replace ur "thePlayer" with GetRootElement(),anyway i dont see why u should put my work in quotes, isn't that i wrote some code from zero just to help u enough? lol i dont mean nothing i mean ur "help" but thats it a "work" more than a simple "help" btw ty again im gonna try the output Link to comment
karlis Posted March 13, 2010 Share Posted March 13, 2010 im very sopry, not GetRootElement(), but getRootElement() Link to comment
Lovinglife Posted March 14, 2010 Author Share Posted March 14, 2010 hey hello, sry but i tried this resource (i mean pingk) and it didnt work Link to comment
karlis Posted March 15, 2010 Share Posted March 15, 2010 any errors?dont forget we are trying to help u, not u to us, do /debugscript 3 and see is there any bugs, othervise cant help Link to comment
Lovinglife Posted March 15, 2010 Author Share Posted March 15, 2010 any errors?dont forget we are trying to help u, not u to us, do /debugscript 3 and see is there any bugs, othervise cant help yeah i know it btw i get this error ERROR: Client triggered serverside event kickpinger, but event is not added serverside.... Btw i ve been thinkin that i could need a "warningtimes cmd"...for istance, my ping is 130 and i get 1st warning..it appears "blabla got 1/*(value) warning".. when i get the 3rd(if i type /warningtimes 3, so max is 3)warning i get kicked... outputChatBox ("Pingkicker: " .. getClientName(thePlayer) .. "AVVISO UNO (ping alto) (Max: " .. maxPingValue .. ")", getRootElement(), 255, 0, 0) outputChatBox ("Pingkicker: blabla, reason: Too high ping (Max: " .. maxPingValue .. ")", thePlayer, 255, 0, 0) i need something to appy here : outputChatBox ("Pingkicker: " .. getClientName(thePlayer) .. "AVVISO UNO (ping alto) (Max: " .. maxPingValue .. ")", getRootElement(), 255, 0, 0)...<--- this warning should get Value 1....so i may use an other fuct to do what i type... why i need this? to avoid ping bounce...coz i am organizin a tournament...and direct kick is too bad Regards Lovinglife Link to comment
karlis Posted March 15, 2010 Share Posted March 15, 2010 1)dont have clue why events dont trigger 2)130 ping is WAY too small to get kicked, it shoudl be 400 at minimum 3)for warings implend in script smthing like it: warnigs=0 function name(...) ... if warnings<=3 then outputchatbox(...) warnings=warinigs+1 else kick ... end Link to comment
Lovinglife Posted March 16, 2010 Author Share Posted March 16, 2010 Thank you very much karlis i created a new way to use pingkicker and it is working Regards Lovinglife Link to comment
Lovinglife Posted March 17, 2010 Author Share Posted March 17, 2010 hi again...i'm getting this issue... ->>>>>>>>>>>>> http://img651.imageshack.us/img651/8760 ... 161634.png It should be : Each player got his warnings : Vale 3/1, 3/2, 3/3...etc... Jo 3/1, 3/2, 3/3...etc... Instead of Vale 3/1,Jo 3/2, Vale 3/3...etc...Kick. Every player must have his warnings.... This is the code's piece u need to see.... if (maxPingEnabled) then if (playerPing > maxPingValue) then TogglePingWarning(thePlayer, true) avvisiKick = avvisiKick + 1 i think that here i should add something like "for index, thePlayer in ipairs(getElementsByType("player")) do" or "if (isElement(thePlayer))" i rly dont know...i need something that assignes different warnings to each player Link to comment
Dark Dragon Posted March 17, 2010 Share Posted March 17, 2010 you can use a table with all players or even easier element data. if (maxPingEnabled) then if (playerPing > maxPingValue) then TogglePingWarning(thePlayer, true) setElementData(thePlayer,"pingwarnings",tonumber(getElementData(thePlayer,"pingwarnings"))+1) Link to comment
karlis Posted March 17, 2010 Share Posted March 17, 2010 jsut do warings clientside...solves all problems, when need to kick-trigger server, but make check "if (source==this) then kick..." for security reasons Link to comment
Lovinglife Posted March 19, 2010 Author Share Posted March 19, 2010 you can use a table with all players or even easier element data. if (maxPingEnabled) then if (playerPing > maxPingValue) then TogglePingWarning(thePlayer, true) setElementData(thePlayer,"pingwarnings",tonumber(getElementData(thePlayer,"pingwarnings"))+1) hey ... i saw "nil" value if i use debugscript3....Attempt to perform on arit on nil value on top i got avvisiSettati=2 avvisiKick=0 i guess i should try avvisisettati or avvisikick as Onresourcestart local value7 = get('avvisisettati') if (value7) then avvisiSettati = value7 end local value8 = get('avvisikick') if (value8) then avvisiKick = value8 end ? @Karlis i didnt understand, i kinda such with lua, damn it Should i do same things on client side? Thanks both ofc ! Link to comment
karlis Posted March 19, 2010 Share Posted March 19, 2010 get("name") is serverside function for such options in meta.xml : <settings> <setting name="*name" value="values in JSON" /> ... settings> for JSON info watch: https://forum.multitheftauto.com/viewtop ... 91&t=26845 ------- and i just say you should move all warnings system clientside, that would delete many pain in ass, btw if tis hard for you you could post whole code and if ill have time i could rewrite warings myself Link to comment
Lovinglife Posted March 20, 2010 Author Share Posted March 20, 2010 get("name") is serverside function for such options in meta.xml : <settings> <setting name="*name" value="values in JSON" /> ... settings> for JSON info watch: https://forum.multitheftauto.com/viewtop ... 91&t=26845 ------- and i just say you should move all warnings system clientside, that would delete many pain in ass, btw if tis hard for you you could post whole code and if ill have time i could rewrite warings myself hey karlis, sup that Json seems kinda hard for me...btw...my warnings system is composed by a cmd to set up "avvisisettati" (the number u cant go on) and a value avvisikick, starts 0, (=avvisisettati+1,each time u if (playerPing > maxPingValue)) when ur aKick is bigger than aSettati u get kicked . and i appreciate ur usefull help but i d like to try alone...btw what i explained above is in server side...should i move that to client side (i think i cant bcuz of CMD(server side, right, only?) or only the thing " if (playerPing > maxPingValue) then TogglePingWarning(thePlayer, true) bla bla avvisiKick = avvisiKick + 1 and if only that piece of code, how? Regards Link to comment
karlis Posted March 21, 2010 Share Posted March 21, 2010 you can do like u showed, but i see you don't have real purpose to do so anymore, as you did all already serverside, but yes, u CAN addCommandHandler clientside anyway if you want trigger kick/ban from clientside be sure you do folowing check if this==source then kick ... end or kickPlayer(this,blabla) --not "source", but "this" since then player cant trigger to kick other player Link to comment
50p Posted March 21, 2010 Share Posted March 21, 2010 you can do like u showed, but i see you don't have real purpose to do so anymore, as you did all already serverside, but yes, u CAN addCommandHandler clientsideanyway if you want trigger kick/ban from clientside be sure you do folowing check if this==source then kick ... end or kickPlayer(this,blabla) --not "source", but "this" since then player cant trigger to kick other player I think you should spend more time on wiki. Not "this" but "client" since event handler is not attached to player but root element (in the script on the 1st page of this topic). https://wiki.multitheftauto.com/wiki/AddEventHandler Link to comment
karlis Posted March 21, 2010 Share Posted March 21, 2010 oh sory, not problem that i didnt see it on wiki, problem thats i messed em up on brain 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