Jump to content

Anti_Hack Help


Try

Recommended Posts

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

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

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

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
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
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 by Guest
Link to comment

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
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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...