-
Posts
117 -
Joined
-
Last visited
Everything posted by shaio
-
I tried changing the time but heres what happens, the colors split in half, one half goes slower, the other goes faster..
-
Basic Code. addEventHandler("onResourceStart",getRootElement(),function() for _,obj in ipairs(getElementsByType("object")) do if (getElementModel(obj) == 10324) or (getElementModel(obj) == 10329) or (getElementModel(obj) == 10330) or (getElementModel(obj) == 10331) or (getElementModel(obj) == 10332) or (getElementModel(obj) == 10715) or (getElementModel(obj) == 10719) then return else removeWorldModel(obj) destroyElement(obj) setOcclusionsEnabled(false) end end end)
-
Well this is a small server-side payment script that lets players pay each other, unfortunately my 'money checker' doesn't work, no matter how much money you have, it says you don't have enough. I have no idea why it is doing this.. function payScript(player,cmd,other,amount) local money = getPlayerMoney(player) local otherPlayer = getPlayerFromName(other) if not other then outputChatBox("Syntax: /pay (playerName) (amount)",player,0,255,255) else if not amount then outputChatBox("Syntax: /pay (playerName) (amount)",player,0,255,255) else if ((money - amount) < money) then outputChatBox("You do not have enough money!",player,0,255,255) return else setPlayerMoney(otherPlayer,getPlayerMoney(otherPlayer) + amount) setPlayerMoney(player,money - amount) outputChatBox("$"..amount.." has been sent to "..other.."!",player,0,255,255) outputChatBox("You have received $"..amount.." from "..getPlayerName(player).."!",otherPlayer,0,255,255) end end end end addCommandHandler("pay",payScript)
-
I don't think this is possible, because even if you freeze the player in the air, it will automatically do the falling anim. Not sure if there is a way to work around that.
-
How do I bind the multiplayer menu to another key?
shaio replied to RedneckRandy's topic in Scripting
There is a default resource found in serverFolder/mods/deathmatch/resources/gameplay/freeroam The resource is called "freeroam" You want to open the fr_client.lua file and find the event "onClientResourceStart" and change the bind key there. Also if you want to change the message "Press F1 to show/hide controls" open the fr_server.lua and find that as well. When you're all done, just save the script and restart the resource or start the server. -
How would I hook up commands to these events? local sound = {} local blocked = {} local draw = {} addEvent ("playSounds", true) addEventHandler ("playSounds", getRootElement(), function (sound2D, sound3D, attached, theSound, x, y, z, player, vehicle) if (checkBlockedPlayers (player) == true) then outputChatBox (getPlayerName(player).." is currently on your blocked players list.") else if string.find(tostring(theSound), "http://") == nil and string.find(tostring(theSound), "https://") == nil then theSound = string.format("http://%s", theSound) end local newSound = url_decode (theSound) if sound3D == true then if attached == false then local dimension = getElementDimension (player) sound[player] = playSound3D (theSound, x, y, z, true) if not sound[player] then outputChatBox ("Failed to create your sound. (not attached)") end setElementDimension (sound[player], dimension) attachElements (sound[player], getRootElement()) setSoundMinDistance (sound[player], 20) setSoundMaxDistance (sound[player], 40) setSoundVolume (sound[player], 15) addText (player, tostring(newSound), false, true, x, y, z) return true elseif attached == true then if vehicle then local dimension = getElementDimension (vehicle) sound[player] = playSound3D (theSound, x, y, z, true) if not sound[player] then outputChatBox ("Failed to create your sound. (attached + vehicle)") end setElementDimension (sound[player], dimension) setSoundVolume (sound[player], 1) setSoundMinDistance (sound[player], 20) setSoundMaxDistance (sound[player], 40) attachElements (sound[player], vehicle, 0, 0, 0) addText (player, tostring(newSound), vehicle) return true else local dimension = getElementDimension (player) sound[player] = playSound3D (theSound, x, y, z, true) if not sound[player] then outputChatBox ("Failed to create your sound. (attached + on foot)") end setElementDimension (sound[player], dimension) setSoundVolume (sound[player], 1) setSoundMinDistance (sound[player], -- s8) --> setSoundMaxDistance (sound[player], 18) attachElements (sound[player], player, 0, 0, 0) addText (player, tostring(newSound)) return true end else outputConsole ("Failed attach and static") end elseif sound2D == true then sound[player] = playSound (theSound, true) setSoundVolume (sound[player], 1) return true else outputConsole ("Failed making anything") end end end ) addEvent ("stopAllSongs", true) addEventHandler ("stopAllSongs", getRootElement(), function () for k, v in ipairs (getElementsByType ("sound")) do destroyElement (v) end draw = {} end ) addEvent ("stopPlayerSongs", true) addEventHandler ("stopPlayerSongs", getRootElement(), function (player) if sound[player] then destroyElement (sound[player]) removeText (player) end end ) function checkBlockedPlayers (player) for k, players in ipairs (blocked) do if players == player then return true else return false end end end function addText(player, text, vehicle, static, x, y, z) local temp if vehicle then temp = { ["player"] = player, ["text"] = text, ["vehicle"] = vehicle } elseif static == true then temp = { ["player"] = player, ["text"] = text, ["vehicle"] = false, ["static"] = true, ["x"] = x, ["y"] = y, ["z"] = z } else temp = { ["player"] = player, ["text"] = text } end table.insert (draw, temp) end function removeText (player) for k, v in ipairs (draw) do if v["player"] == player then table.remove (draw, k) break end end end function url_decode(str) str = string.gsub (str, "+", " ") str = string.gsub (str, "%%(%x%x)", function(h) return string.char(tonumber(h,16)) end) str = string.gsub (str, "\r\n", "\n") return str end addEvent ("blockPlayer", true) addEventHandler ("blockPlayer", getRootElement(), function (player) if checkBlockedPlayers (player) == false or checkBlockedPlayers (player) == nil then table.insert (blocked, player) outputChatBox ("Blocked "..getPlayerName (player)) elseif checkBlockedPlayers (player) == true then for k, v in ipairs (blocked) do if v == player then table.remove (blocked, k) break end end outputChatBox ("Unblocked "..getPlayerName (player)) end end ) addEventHandler ("onClientResourceStart", getResourceRootElement(getThisResource()), function () setTimer (triggerServerEvent, 4000, 1, "startSounds", getRootElement(), getLocalPlayer()) end ) addEventHandler ("onClientRender", getRootElement(), function () if draw then for k, v in ipairs(draw) do if isElement (v["player"]) then local x, y, z if v["static"] == true then x, y, z = v["x"], v["y"], v["z"] elseif v["vehicle"] and isElement (v["vehicle"]) then x1, y1, z1 = getElementPosition (v["vehicle"]) x, y, z = x1, y1, z1 + 1 else local camPosXl, camPosYl, camPosZl = getPedBonePosition (v["player"], 6) local camPosXr, camPosYr, camPosZr = getPedBonePosition (v["player"], 7) x, y, z = (camPosXl + camPosXr) / 2, (camPosYl + camPosYr) / 2, (camPosZl + camPosZr) / 2 end local cx, cy, cz = getCameraMatrix () local distance = getDistanceBetweenPoints3D (cx, cy, cz, x, y, z) local posx, posy = getScreenFromWorldPosition (x, y, z + 0.020 * distance + 0.10) local ignore = getPedOccupiedVehicle (v["player"]) or v["player"] local ignore2 = getPedOccupiedVehicle(getLocalPlayer()) or getLocalPlayer() if posx and distance <= 45 and (isLineOfSightClear (cx, cy, cz, x, y, z, true, true, false, true, false, true, false, ignore)) and (isLineOfSightClear (cx, cy, cz, x, y, z, true, true, false, true, false, true, false, ignore2)) then local width = dxGetTextWidth (v["text"], 1, "default") dxDrawText (v["text"], posx - (0.5 * width), posy, posx - (0.5 * width), posy, tocolor(255, 255, 255, 255), 1, "default", "left", "top", false, false, false) end end end end end )
-
I tried but i cant get it to go slower, except it like cuts the colors in half, one is different kinds of blue and the rest are like red, yellow, and orange and the blue ends up going slow but the red, yellow, and orange just fly through.
-
it looks too fast, colors switch too fast, i want it to be smoother, how do i turn the timing down?
-
To be frank with you, I've never worked with file opening, closing, editing or anthing like that.. But I pieced together this. I have no idea if it works or not, but it does make sense . Good luck bro. (You need to name the resource "logs" - without quotes - or else it wont work) function logStart() if fileExists((":%s/%s"):format("logs","log.txt")) then for _,plr in ipairs(getElementsByType("player")) do local file = fileOpen("log.txt") fileWrite(file,getPlayerName(plr).." - Health: "..getElementHealth(plr).."\n\r") fileClose(file) end else local file = fileCreate("log.txt") end setTimer(logStart,5000,0) end addEventHandler("onResourceStart",getRootElement(),logStart)
-
You're original code didnt work. I tried to make it work both serverside and client side with the cmd i made for it. I want to have an enable and disable feature, to do that I use element data on the vehicle and then loop all vehicles. function rgbToggle(player,cmd,value) if not value then outputChatBox("Syntax: /rgb (on/off)",player,0,255,255) end if (value == "on") then setElementData(getPedOccupiedVehicle(player),"rgb","on") outputChatBox("Enabled.",player,0,255,255) elseif (value == "off") then setElementData(getPedOccupiedVehicle(player),"rgb","off") outputChatBox("Disabled.",player,0,255,255) else outputChatBox(value.." is not a valid argument!",player,0,255,255) end end addCommandHandler("rgb",rgbToggle) local function wavelengthToRGBA(length) local r, g, b, factor if (length >= 380 and length < 440) then r, g, b = -(length - 440)/(440 - 380), 0, 1 elseif (length < 489) then r, g, b = 0, (length - 440)/(490 - 440), 1 elseif (length < 510) then r, g, b = 0, 1, -(length - 510)/(510 - 490) elseif (length < 580) then r, g, b = (length - 510)/(580 - 510), 1, 0 elseif (length < 645) then r, g, b = 1, -(length - 645)/(645 - 580), 0 elseif (length < 780) then r, g, b = 1, 0, 0 else r, g, b = 0, 0, 0 end if (length >= 380 and length < 420) then factor = 0.3 + 0.7*(length - 380)/(420 - 380) elseif (length < 701) then factor = 1 elseif (length < 780) then factor = 0.3 + 0.7*(780 - length)/(780 - 700) else factor = 0 end return r*255, g*255, b*255, factor*255 end local startTime = getTickCount() local function rainbowColorVehicle() for _,v in ipairs(getElementsByType("vehicle")) do if (getElementData(v,"rgb") == "on") then local progress = math.fmod(getTickCount() - startTime, 3000) / 3000 local length = interpolateBetween(400, 0, 0, 700, 0, 0, progress, "Linear") local r, g, b = wavelengthToRGBA(length) setVehicleColor(v, r, g, b, r, g, b, r, g, b, r, g, b) end end end addEventHandler("onClientPreRender", getRootElement(), rainbowColorVehicle)
-
Holy moly, I was not expecting that. I'm like a script kiddie and ur a pro This is blowin my mind, and I would never think of this, thank you so much!
-
I'm trying to make a script that changes the color of the car automatically, but I want it to be rainbow colored. I've only gotten it to do random colors. I've seen on many servers where they have rainbow colors, it like switches from turquoise blue to blue and then purple, and then green, and then yellow and what not.. function rgbToggle(player,cmd,value) if not value then outputChatBox("Syntax: /rgb (on/off)",player,0,255,255) end if (value == "on") then setElementData(getPedOccupiedVehicle(player),"rgb","on") outputChatBox("Enabled.",player,0,255,255) elseif (value == "off") then setElementData(getPedOccupiedVehicle(player),"rgb","off") outputChatBox("Disabled.",player,0,255,255) end end addCommandHandler("rgb",rgbToggle) setTimer(function() for _,v in ipairs(getElementsByType("vehicle")) do if (getElementData(v,"rgb") == "on") then setVehicleColor(v,math.random(0,255),math.random(0,255),math.random(0,255),math.random(0,255),math.random(0,255),math.random(0,255)) end end end,300,0)
-
My server doesn't require a login, cuz I have a team selection when a player joins and the text always goes over the login screen, no matter what it is. I just assume go with serials rather than accounts, since some servers don't use accounts.
-
I've been working on this code for like a week, I wanted to create a good lock system. It started out as just /lock, people would be able to jack your car if it wasn't locked, so I decided to make an auto 'owning' feature, if you spawn the car, you own the car and nobody can take it, however they can get in as a passenger, if you don't want anyone getting in your car at all you simply press K while in the vehicle. I plan to make a sharing feature, where you can allow other people to drive your car. Other than that, this is what I got. If anyone has any suggestions for me, or if there is a way to make this script more efficient, just let me know. My skype is cemour.burkoff [Tested and functional] function lock(player,cmd) if getPedOccupiedVehicle(player) and getPedOccupiedVehicleSeat(player) == 0 then if (getElementData(getPedOccupiedVehicle(player),"locks") == true) then setElementData(getPedOccupiedVehicle(player),"lock",false) setElementData(getPedOccupiedVehicle(player),"locks",false) outputChatBox("Unlocked!",player,0,255,255) else setElementData(getPedOccupiedVehicle(player),"lock",getPlayerSerial(player)) setElementData(getPedOccupiedVehicle(player),"locks",true) outputChatBox("Locked!",player,0,255,255) end else outputChatBox("You are not the driver!",player,0,255,255) end end addCommandHandler("lock",lock) addEventHandler ("onPlayerJoin", getRootElement(), function() bindKey (source, "k", "down", lock) end) addEventHandler ("onResourceStart", getResourceRootElement(getThisResource()), function() local players = getElementsByType ("player") for k, player in ipairs (players) do bindKey (player, "k", "down", lock) end end) function enterVehicle(player,seat,jacked) if not (getElementData(source,"lock") == getPlayerSerial(player)) then if (getElementData(source,"lock") == false) then return else cancelEvent() outputChatBox("This is not your vehicle!",player,0,255,255) end end end addEventHandler("onVehicleStartEnter",getRootElement(),enterVehicle) function inveh(player,seat,jacked) if not (getElementData(source,"locked") == getPlayerSerial(player)) then if seat == 0 then cancelEvent() outputChatBox("This is not your vehicle!",player,0,255,255) else return end else return end end addEventHandler("onVehicleStartEnter",getRootElement(),inveh) function lockVeh(player,seat,jacked) setElementData(source,"locked",getPlayerSerial(player)) end addEventHandler("onVehicleEnter",getRootElement(),lockVeh)