Try Posted May 15, 2011 Share Posted May 15, 2011 Hello Guys, Im making a new style of anti-hack, one like /hack then the people wont stop get teleported, I have a code: ------------------------ -- Anti-Hack by Maria -- ------------------------ -- Set Who Hacks function hacker(commandName, name) local theVehicle = getPedOccupiedVehicle ( name ) if theVehicle then local vehicles = getElementsByType("vehicle") for i,v in ipairs(vehicles) do if (getElementModel(v) == modelID) then destroyElement(v) setElementPostion(name, 0, 0, 3) outputChatBox("TURN OFF OR REMOVE THE HACK!",name,255,0,0) else setElementPostion(name, 0, 0, 3) outputChatBox("TURN OFF OR REMOVE THE HACK!",name,255,0,0) end end end end addEventHandler("hack",hacker) But its not woking, I need your help with how to get when people get a car and delete the car, Thanks For the Help, Maria. Link to comment
Aibo Posted May 15, 2011 Share Posted May 15, 2011 i dont really get what are you trying to do (get player's vehicle and then destroy some other unrelated vehicle by it's ID?), but: 1. first argument to command handler function is player element (im assuming this is serverside script) so hacker(player, commandName, name) 2. you cant getPedOccupiedVehicle from name string, you need to get player element first, using getPlayerFromName(name) 3. modelID is not set anywhere in this function, is it outside? 4. setElementPosition, not setElementPostion (also needs player element, not name, which is a string) 5. outputChatBox also needs player element Link to comment
karlis Posted May 15, 2011 Share Posted May 15, 2011 acutally i have no idea what you wanted to to with the loop, so sorry if this doest solve your problem function hacker(player,commandName, name,) local theVehicle = getPedOccupiedVehicle (player) if theVehicle then destroyElement(theVehicle) end setElementPosition(player, 0, 0, 3) outputChatBox("TURN OFF OR REMOVE THE HACK!",player,255,0,0) end addCommandHandler("hack",hacker) Link to comment
Try Posted May 15, 2011 Author Share Posted May 15, 2011 Ok i will test but if the people are not using a car that code will work too? Thanks, Maria. Link to comment
karlis Posted May 15, 2011 Share Posted May 15, 2011 yes, basically it just destroys car is there is one. Link to comment
Try Posted May 15, 2011 Author Share Posted May 15, 2011 Wrong function hacker(player,commandName, name) local theVehicle = getPedOccupiedVehicle (player) if theVehicle then destroyElement(theVehicle) setElementPosition(player, 0, 0, 3) outputChatBox("TURN OFF OR REMOVE THE HACK!",player,255,0,0) setTimer(hacker, 200, 999999999999999999999999999) end end addCommandHandler("hack",hacker) Sorry i forgot add the Timer, This spam at debugscript, and i need for all the time the car get removed, the code remove only one time, and can don't spam at debugscript? Thanks, Maria. Link to comment
Castillo Posted May 16, 2011 Share Posted May 16, 2011 timers = {} function hacker(player,commandName, name) local theVehicle = getPedOccupiedVehicle (getPlayerFromName(name)) if theVehicle then destroyElement(theVehicle) setElementPosition(getPlayerFromName(name) or theVehicle, 0, 0, 3) outputChatBox("TURN OFF OR REMOVE THE HACK!",getPlayerFromName(name),255,0,0) if not timers[getPlayerFromName(name)] then timers[getPlayerFromName(name)] = setTimer(hacker, 200, 0, player, nil, name) end end end addCommandHandler("hack",hacker) Link to comment
karlis Posted May 16, 2011 Share Posted May 16, 2011 (edited) timers = {} function hacker(player,commandName, name) local theVehicle = getPedOccupiedVehicle (getPlayerFromName(name)) if theVehicle then destroyElement(theVehicle) setElementPosition(getPlayerFromName(name) or theVehicle, 0, 0, 3) outputChatBox("TURN OFF OR REMOVE THE HACK!",getPlayerFromName(name),255,0,0) if not timers[getPlayerFromName(name)] then timers[getPlayerFromName(name)] = setTimer(hacker, 200, 0, player, nil, name) end end end addCommandHandler("hack",hacker) might be better to store player variable, then to get player 5times. also theVehicle pos will never be set, as player is not false/nil always. and it currently has no way of removing the timer, you should add. addCommandHandler("doesnthack",function(_,_,name) killTimer(timers[getPlayerFromName(name)]) end) Edited May 16, 2011 by Guest Link to comment
Castillo Posted May 16, 2011 Share Posted May 16, 2011 There's no such function: destroyTimer o,o, i think you mean killTimer? addCommandHandler("doesnthack",function(_,_,name) killTimer(timers[getPlayerFromName(name)]) end) Link to comment
karlis Posted May 16, 2011 Share Posted May 16, 2011 yep true, soz didnt script a while and forgot the proper names. Link to comment
Try Posted May 16, 2011 Author Share Posted May 16, 2011 I tested the codes but at debugscript say: Bad Argument GetPedOcuppiedVehicle I think the code only work if the people was by car I need when by car or when on foot and other its not teleporting Thanks for the Help, Maria. Link to comment
karlis Posted May 16, 2011 Share Posted May 16, 2011 I tested the codes but at debugscript say:Bad Argument GetPedOcuppiedVehicle I think the code only work if the people was by car I need when by car or when on foot and other its not teleporting Thanks for the Help, Maria. its getPedOcuppiedVehicle, not GetPedOcuppiedVehicle Link to comment
Try Posted May 16, 2011 Author Share Posted May 16, 2011 Noooooooooooooo the wrong its: Bad Argument getPedOcuppeiedVehicle sorry i wrote wrong ------- I got one idea like: function hack(player,commandName,name) setElementPosition(...) return end......... i mean use one think for the function restart Link to comment
Castillo Posted May 16, 2011 Share Posted May 16, 2011 Ok, this code should do what you want. hackers = {} function hacker(player, commandName, name) local hacker = getPlayerFromName(name) if not isHackerInList(hacker) then table.insert(hackers,{hacker, name}) outputChatBox("* Added "..tostring(name).." to hacker's list!",player,255,0,0) else outputChatBox("* "..tostring(getPlayerName(hacker)).." is already in hacker's list!",player,255,0,0) end end addCommandHandler("hack",hacker) function isHackerInList(name) for i,v in pairs(hackers) do if v[1] == name then return true end end return false end function disableHacker() for i,v in pairs(hackers) do if isElement(v[1]) then local theVehicle = getPedOccupiedVehicle (v[1]) if theVehicle then destroyElement(theVehicle) end setElementPosition(v[1], 0, 0, 3) outputChatBox("TURN OFF OR REMOVE THE HACK!",v[1],255,0,0) end end end setTimer(disableHacker,200,0) addCommandHandler("doesnthack",function(player,_,name) for i,v in pairs(hackers) do if v[2] == name then table.remove(hackers,i) outputChatBox("* Removed "..tostring(name).." from hacker's list!",player,0,255,0) end end end) Link to comment
Try Posted May 17, 2011 Author Share Posted May 17, 2011 I made some changes because the warn spam, but now its solved, Thanks Castilllllllo, kaslis, Aiboforce, Thanks for your help, Maria. Link to comment
Castillo Posted May 17, 2011 Share Posted May 17, 2011 Oh, i suposed the Spam of warning was intended, lol. Anyway if you fixed it, great, and no problem . Link to comment
qaisjp Posted May 20, 2011 Share Posted May 20, 2011 Maria/Try, you don't need to correct your post by using a new post if it has a one word mistake, use the edit button 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