ratoc Posted January 7, 2008 Share Posted January 7, 2008 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
AlienX Posted January 7, 2008 Share Posted January 7, 2008 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
[email protected] Posted January 8, 2008 Share Posted January 8, 2008 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
ratoc Posted January 8, 2008 Author Share Posted January 8, 2008 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
idiot Posted January 10, 2008 Share Posted January 10, 2008 maybe it could help me too... is this script only for health or for vehicle damage too? Link to comment
ratoc Posted January 10, 2008 Author Share Posted January 10, 2008 maybe it could help me too... is this script only for health or for vehicle damage too? only health to vehicle: setVehicleDamageProof(veh, true) Link to comment
idiot Posted January 12, 2008 Share Posted January 12, 2008 okay i'm really too stupid to run it ! could someone just make the .zip's with the god mode and the vehicle damage scripts? the meta should be in too . i don't understand so much of lua and scripting. so please ;S Link to comment
idiot Posted January 16, 2008 Share Posted January 16, 2008 okay i'm really too stupid to run it ! could someone just make the .zip's with the god mode and the vehicle damage scripts? the meta should be in too . i don't understand so much of lua and scripting. so please ;S sry 4 pushing but it would be so helpful ... its stupid at stunting when your car is burning after each try at many spots Link to comment
ratoc Posted January 16, 2008 Author Share Posted January 16, 2008 sry 4 pushing but it would be so helpful ... its stupid at stunting when your car is burning after each try at many spots 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
idiot Posted January 16, 2008 Share Posted January 16, 2008 big THANKS !!!!!!!! finally... lol but the godmode? ;O would be helpful for grenadeboosting... Link to comment
ratoc Posted January 17, 2008 Author Share Posted January 17, 2008 finally... lol but the godmode? ;O would be helpful for grenadeboosting... i like generateboosting too 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
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