Jump to content

god mode


ratoc

Recommended Posts

i tryed to write a god mode script..

my code:

  
  
function playerDamage(attacker, weapon, bodypart, loss) 
    SetElementHealth(source, 10000) -- 163. line 
end 
  
addEventHandler("onPlayerDamage", root, playerDamage) 
  

but i get this error:

ERROR: .../mods/deathmach/resourcechace/freeroam/freeroam.lua:163: attemt to call global 'setElementHealth' (a nil value)

what do i do wrong?

other: i want write a location save/load script, but i dont know how should i store the positions, because it isnt do anything:

positions = {} 
  
function savepos(player, cmd) 
    local posX, posY, posZ = getElementPosition(player) 
    local rot = getPlayerRotation(player) 
    local name = getClientName(player) 
    positions[name][x] = posX 
    positions[name][y] = posY 
    positions[name][z] = posZ 
    positions[name][rot] = rot 
end 
  
function loadpos(player, cmd) 
    setElementPosition(player, positions[name][x], positions[name][y], positions[name][z]) 
    setPlayerRotation(player, positions[name][rot]) 
end 
  
addCommandHandler("sp", savepos) 
addCommandHandler("lp", loadpos) 

Thanks, Ratoc.

Link to comment

hey.

The reason that you're SetElementHealth isn't working is because all lua commands are case sensitive, so it should be setElementHealth but there is a much better way of doing this using the cancelEvent() func in a client side script on the player damage event...

The wiki can help you here

Link to comment

Also:

# function savepos(player, cmd)

# local posX, posY, posZ = getElementPosition(player)

# local rot = getPlayerRotation(player)

# local name = getClientName(player)

# positions[name][x] = posX

# positions[name][y] = posY

# positions[name][z] = posZ

# positions[name][rot] = rot

# end

looks like you are saving exactly the same data, just twice in basically exactly the same way.

You might consider using the registry system, saving data by using the "set()" function and retrieving the data with "get()", this saved data should also persist through server reboots or downtimes. (it seems to be saved in a file called "settings.xml")

Link to comment
looks like you are saving exactly the same data, just twice in basically exactly the same way.

You might consider using the registry system, saving data by using the "set()" function and retrieving the data with "get()", this saved data should also persist through server reboots or downtimes. (it seems to be saved in a file called "settings.xml")

hmm saving is ok, but loading data isnt works :?

function savepos(player, cmd) 
    local posX, posY, posZ = getElementPosition(player) 
    local rot = getPlayerRotation(player) 
    local name = getClientName(player) 
    local positions = {posX, posY, posZ, rot} 
    local setting = set(name, positions) 
    if setting then 
        outputChatBox("Position saved.", player) 
    else 
        outputChatBox("Failed to save position.", player) 
    end 
end 
  
function loadpos(player, cmd) 
    local name = getClientName(player) 
    local data = get(name) 
    if data then 
        setElementPosition(player, data[0], data[1], data[2]) 
        setPlayerRotation(player, data[3]) 
        outputChatBox("Position loaded.", player) 
    else 
        outputChatBox("You aren't saved yet.", player) 
    end 
end 
  
addCommandHandler("sp", savepos) 
addCommandHandler("lp", loadpos) 

whats wrong? :(

oh, and the error:

[17:44:26] WARNING: teleporter.lua: Bad argument @ 'setElementPosition' - Line: 18

[17:44:27] WARNING: teleporter.lua: Bad argument @ 'setElementPosition' - Line: 18

Link to comment
okay i'm really too stupid to run it :o! could someone just make the .zip's with the god mode and the vehicle damage scripts? the meta should be in too :roll:. i don't understand so much of lua and scripting. :oops: so please ;S

sry 4 pushing but it would be so helpful :roll: ... its stupid at stunting when your car is burning after each try at many spots :cry:

Link to comment
sry 4 pushing but it would be so helpful :roll: ... its stupid at stunting when your car is burning after each try at many spots :cry:

here is a car spawner with spoosh:

  
function cmdCreateVehicle(player, cmd, vehname) 
    local vehid = getVehicleIDFromName(vehname) 
    if(vehid) then 
        if isPlayerInVehicle(player) then 
            newveh = getPlayerOccupiedVehicle(player) 
            setVehicleModel(newveh, vehid) 
        else 
            local X, Y, Z = getElementPosition(player) 
            local rot = getPlayerRotation(player) 
            newveh = createVehicle(vehid, X, Y, Z, 0, 0, rot) 
            warpPlayerIntoVehicle(player, newveh) 
        end 
        setVehicleDamageProof(newveh, true) 
        setVehicleGunsEnabled(newveh, false) 
        outputChatBox("Vehicle spawned.", player) 
    else 
        outputChatBox("Vehicle not found.", player) 
    end 
end 
  
addCommandHandler("spawn", cmdCreateVehicle) 
  

just put into the mod

Link to comment
finally... lol but the godmode? ;O would be helpful for grenadeboosting... :wink:

i like generateboosting too :D

clientside:

function damag(attacker, weapon, bodypart) 
    cancelEvent() 
end 
  
addEventHandler("onClientPlayerDamage", getLocalPlayer(), damag) 
  

nobody can help me in the savepos/loadpos problem? stunt is very bad without it

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