hahec Posted January 21, 2012 Posted January 21, 2012 Hello MTA. I'm new here. I have a problem with my script. I got it long time ago (dunno from where) and i didn't used it but now i found it like fun script to be working on my server. It's about killing an player who isn't moving. I know some basics in Lua scripting btw. Seems like something isn't working fine. I start the script (no errors). I camp and after a while i got warning "you will be killed in 10,9,8,7...". But when the countdown finishes nothing happens. Maybe you know the problem. Ty. Script: MaxAFKtime = 25 warnTime = 15 v = 0 AFKtime = 0 tCount = 11 sx,sy = guiGetScreenSize() wEvent = false afkCounter = 1 function rWarn() dxDrawImage( sx/2 - 300, sy/2 - 100, 600, 200, "warn.png") dxDrawText("You will be killed in "..tostring(tCount).." seconds",sx/2 - 255, sy/2 + 45,sx,sy,tocolor(255,186,0,255),1.01,"bankgothic") end function stopWarn() if(wEvent) then removeEventHandler("onClientRender", getRootElement(), rWarn) wEvent = false end end function imgHandler() stopWarn() end addEventHandler("onClientPlayerWasted",getLocalPlayer(),imgHandler) function checkMain() if isPedInVehicle ( getLocalPlayer() ) then aTimeAdd() end end function aTimeAdd() AFKtime = AFKtime + 1 local isFinished = getElementData ( getLocalPlayer(), "dead") if(isElementFrozen ( getPedOccupiedVehicle ( getLocalPlayer() )) and isFinished == false) then aTimeClear() return end local isNew = getElementData (getLocalPlayer(), "state") if isNew == "waiting" or isNew == "dead" then aTimeClear() return end if getControlState("accelerate") or getControlState("vehicle_left") or getControlState("vehicle_right") or getControlState("brake_reverse") then aTimeClear() return end if(getPedOccupiedVehicle ( getLocalPlayer() ) ~= false) then local player = getLocalPlayer() if (AFKtime >= MaxAFKtime) then if (afkCounter <= 4) then triggerServerEvent ( "afkWarn", player, 1, afkCounter) afkCounter = afkCounter+1 triggerServerEvent ( "afkSlap", player) stopWarn() elseif (afkCounter > 2) then triggerServerEvent ( "afkWarn", player, 1, afkCounter) triggerServerEvent ( "afkWarn", player, 2) afkCounter = 1 triggerServerEvent ( "afkKick", player , player) end elseif(AFKtime >= warnTime) then tCount = tCount - 1 if(not wEvent) then addEventHandler("onClientRender", getRootElement(), rWarn) wEvent = true end end end end setTimer ( checkMain, 1000, -1) function aTimeClear() AFKtime = 0 tCount = 11 stopWarn() end bindKey("accelerate","down",aTimeClear) bindKey("vehicle_left","down",aTimeClear) bindKey("vehicle_right","down",aTimeClear) bindKey("brake_reverse","down",aTimeClear) function setKBA(thePlayer) killedByAfk = 1 end function getKBA(thePlayer) if killedByAfk == 0 then thePlayer = getLocalPlayer() callServerFunction("earnMoney", thePlayer) end end function deathReset() if killedByAfk == 0 then afkCounter = 1 else end end addEventHandler("onClientPlayerWasted",getLocalPlayer(),deathReset) function resetKBA() killedByAfk = 0 end function callClientFunction(funcname, ...) local arg = { ... } if (arg[1]) then for key, value in next, arg do arg[key] = tonumber(value) or value end end loadstring("return "..funcname)()(unpack(arg)) end addEvent("onServerCallsClientFunction", true) addEventHandler("onServerCallsClientFunction", resourceRoot, callClientFunction) function callServerFunction(funcname, ...) local arg = { ... } if (arg[1]) then for key, value in next, arg do if (type(value) == "number") then arg[key] = tostring(value) end end end triggerServerEvent("onClientCallsServerFunction", resourceRoot , funcname, unpack(arg)) end meta.xml: "idiotek" type="script" name="Anti-AFK" version="1.0.0" /> "warn.png" />
Kenix Posted January 21, 2012 Posted January 21, 2012 This is not your script. You need learn lua http://www.lua.org/manual/5.1/ and this https://wiki.multitheftauto.com/wiki/Scr ... troduction http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
hahec Posted January 21, 2012 Author Posted January 21, 2012 I said i got it from somewhere, i didn't said it's mine. I just want to make it work with your help. Ty.
Kenix Posted January 21, 2012 Posted January 21, 2012 (edited) I said i got it from somewhere, i didn't said it's mine. I just want to make it work with your help. Senselessly this create zero effect. http://www.lua.org/manual/5.1/ and this https://wiki.multitheftauto.com/wiki/Scr ... troduction You need learn it. If you want write scripts further. This is council listen to him. Edited January 21, 2012 by Guest http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
TAPL Posted January 21, 2012 Posted January 21, 2012 1- did you give the resource admin right? 2- where the server side?
hahec Posted January 21, 2012 Author Posted January 21, 2012 1- did you give the resource admin right?2- where the server side? this is the only thing i have...client-side.
Kenix Posted January 21, 2012 Posted January 21, 2012 Listen to my advice. Otherwise, in the future will spare this. http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
hahec Posted January 21, 2012 Author Posted January 21, 2012 I read that alredy. And debuging and GUI. I really want to make this script work. Ty.
bandi94 Posted January 22, 2012 Posted January 22, 2012 post the server side where you add "killPed" and use debugscript 3 to find where is the error Ingame Name : |DGT|Puma DGT Clan Server 24/7 Owner/Scripter MultiGameMode in progress :
hahec Posted January 22, 2012 Author Posted January 22, 2012 Well..I mention that I don't have server-side and I would be glad if you/someone could tell me what must the server-side have to make the script work Ty
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