-
Posts
1,058 -
Joined
-
Last visited
-
Days Won
1
Everything posted by Saml1er
-
"SELECT * SHOW TABLES" As you can see here you have spaces SHOW TABLES. Not sure but I don't think so you can use spaces and it should be "SELECT * FROM MyTableName"
-
Ow I didn't know that. Calculating offsets for some weapons is time consuming and it would be better if MTA team makes setPedAimTarget for localPlayer as well.
-
If you're using Den's code then all you need is this function: setPedAimTarget local function getPedsOnScreen() local peds = {} for key, ped in ipairs(getElementsByType("ped", root, true)) do if isElementOnScreen(ped) then table.insert(peds, ped) end end return peds end local function dxDrawCircle(posX, posY, radius, width, angleAmount, color, postGUI) radius = radius or 50 width = width or 5 angleAmount = angleAmount or 1 color = color or tocolor(255, 255, 255, 200) postGUI = postGUI or false for i=0,360,angleAmount do local _i = i*(math.pi/180) dxDrawLine(math.cos(_i)*(radius-width)+posX, math.sin(_i)*(radius-width)+posY, math.cos(_i)*(radius+width)+posX, math.sin(_i)*(radius+width)+posY, tocolor(255, 0, 0), width, postGUI) end return true end local function findRotation(x1,y1,x2,y2) local t = -math.deg(math.atan2(x2-x1,y2-y1)) if t < 0 then t = t + 360 end; return t; end local function sortbyrot(a, b) local _, _, rz = getElementRotation(localPlayer) local x, y = getElementPosition(localPlayer) local ax, ay = getElementPosition(a) local bx, by = getElementPosition(b) local arz = findRotation(x, y, ax, ay) arz = math.abs(rz - arz) local brz = findRotation(x, y, bx, by) brz = math.abs(rz - brz) return arz < brz end addEventHandler("onClientRender", root, function() local weapon = getPedWeapon(localPlayer) if weapon and weapon > 0 then local peds = getPedsOnScreen() if #peds > 0 then table.sort(peds, sortbyrot) local chosen = peds[1] local hx, hy, hz = getPedBonePosition(chosen, 6) local sx, sy = getScreenFromWorldPosition(hx, hy, hz) if sx then dxDrawCircle(sx, sy) setPedAimTarget(chosen,hx,hy,hz) --- Now see the magic end end end end)
-
Hello! I'm working on a new zombie script and I'm soon gonna soon add it to my server but the problem is I'm really worried people because there are too many hackers around and decompiling ain't hard and that cache option in meta.xml.. I can't trust it tho. Does anybody know a good way to script a script? I really dunno what to do..
-
Just Awesome man. Keep up the good work. (y)
-
function getPi(commandName,number) number = tonumber ( number ) if number then -- if we converted it into a number then lets proceed ..... calc = number*math.sin(0.5/number) outputChatBox(calc) end end addCommandHandler("pi",getPi) Well good luck. Your efforts are always appreciated.
-
if (getElementType(getPedTarget(localPlayer))== "vehicle" ) then local color= {255,0,0} else color = {0,0,0} end local hX,hY,hZ = getPedTargetEnd ( localPlayer ) local screenX1, screenY1 = getScreenFromWorldPosition ( hX,hY,hZ ) addEventHandler ("onClientRender",root,function() dxDrawLine(screenX1-(size/6), screenY1-(size/6), screenX1, screenY1, tocolor(unpack(color),255)) -- If your calculations are correct then it should work end )
-
Then explain better local col = createColRectangle (96, 1788, 184, 145) setElementData (col,"zombieProof", true) addEventHandler("onColShapeHit", col, function(h) if not isElement(h) then return end if getElementData(h,"zombie") then killPed(h) end end)
-
Your scripts are never safe in mta but use cache="false" in méta.xml. Its the best way to protect your scripts.
-
for _,v in pairs ( getElementsByType("player")) do setElementData (v,"zombieProof", true) end local col = createColRectangle (96, 1788, 184, 145) addEventHandler("onColShapeHit", col, function(h) if not isElement(h) then return end if getElementData(h,"zombie") then killPed(h) end end)
-
Everything depends on how you trigger it from server side. For example, -- server side local player = getPlayerFromName ("Saml1er") if player then -- if we got the player named Saml1er then triggerClientEvent(player,"LoadModels",player) -- lets trigger it for the player named Saml1er end --client side addEvent("LoadModels",true) addEventHandler("LoadModels",root, function () -- Now this function will work for the player who triggered the event end )
-
_createPed = createPed -- save the function createPed = function(x,y,z,rot,syn) if x and y and z then local rot = rot or 0 local syn = syn or true local thePed = _createPed (x,y,z,rot,syn) -- now we'll call it if thePed then return thePed triggerEvent (thePed,"onPedSpawn",thePed) -- lets trigger it end end end Usage: _createPed (0,0,0) So your new event is "onPedSpawn" and the source of this event is the ped that was created.
-
Those are default groups and if you delete them then some of MTA scripts like race and admin resource won't work. You should have added new groups instead of modifying the existing ones.
-
Admin group is missing.
-
function text () local test = math.random(100, 200) local serverDisplay = textCreateDisplay() for _,v in pairs (getElementsByType("player") ) do -- loop through all players textDisplayAddObserver ( serverDisplay, v) end -- loop ends local serverText = textCreateTextItem ( tonumber(test), 0.5, 0.5 ) textDisplayAddText ( serverDisplay, serverText ) setTimer(function () textDestroyDisplay ( serverDisplay ) textDestroyTextItem( serverText ) end,6000,1) end addEventHandler("onPlayerWasted",root,text) btw source is the player who died so it will create text only for the player and the code I posted below will display text for all players.
-
Change this at line 3: function ( playername) Change this at line 4: if not playername then return end Change this at line 26: local _, _, r = getElementRotation ( player ) And replace sourcePlayer with source(if you do other stuff for the player who triggered the event ) else replace it with player.
-
Just edit your meta: <script src="YourFileName.lua" type="client" cache="false"/> // cache to false.
-
Use pcall with loadString ^^ local code = loadstring(myString) if code then pcall(code) print (worked) end
-
addEventHandler("onClientGUIClick",root, function (b,s) if b == "left" then if source == GUIEditor.button[1] then if not rendering then addEventHandler("onClientRender",root,FunctionName) rendering = true else removeEventHandler("onClientRender",root,FunctionName) rendering = nil end end end )
-
addEventHandler("onClientGUIClick",root, function (b,s) if b == "left" then if source == GUIEditor.button[1] then guiSetVisible (GUIEditor.button[1], not guiGetVisible(GUIEditor.button[1])) end end end )
-
Poor people, they got scammed.
-
"onClientClick is more efficient". You don't even need to create any gui element for dx but if you want to make a rectangle or something then use "onClientGUIClick" else its not needed.
-
I meant toggleVehicleRespawn does not work with onVehicleExplode if the vehicle that you want to respawn is the vehicle that exploded. For example, can a dead person eat food or drink water? The answer is no. So when the exploded is myVeh then server memory reads your code like this: function respawnExplodedVehicle() toggleVehicleRespawn( myVeh, true ) -- myVeh is not defined setVehicleRespawnDelay( myVeh, 5000 ) -- myVeh is not defined end addEventHandler("onVehicleExplode", getRootElement(), respawnExplodedVehicle
-
Tried but still i got the same problem, i still cant see the vehicle respawning. Its because when the vehicle is destroyed (exploded) then it doesn't exist you must set respawn to true before the vehicle is destroyed.