Jump to content

Savannah

Members
  • Posts

    12
  • Joined

  • Last visited

  • Days Won

    1

Savannah last won the day on December 4 2016

Savannah had the most liked content!

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Savannah's Achievements

Square

Square (6/54)

5

Reputation

  1. You can perfectly use setTimer(). Here this should be a little easier for you to understand: local aTimer = {} function hydraulics(plr) if getElementType(plr) == "player" then if isTimer(aTimer[plr]) then outputChatBox("#ff0000You can only TP to the Gun Shop once every 5 minutes!", plr, 255, 255, 255, true) else setElementPosition(plr, 199.2939453125, 1428.4794921875, 10.5859375) aTimer[plr] = setTimer(function(plr) aTimer[plr] = nil end,4000,1,plr) end end end addEvent("hydraulics",true) addEventHandler("hydraulics",root,hydraulics) addCommandHandler("tp",hydraulics,false,false)
  2. Savannah

    Cross GUI

    SORRY EDIT in other post (/msg already exists) and added player check addCommandHandler("message", function(_,playerName,...) if not playerName then outputChatBox("No player name given") return end if #arg == 0 then outputChatBox("No message given") return end local player = getPlayerFromName(playerName) if not player then outputChatBox("Player not found") else local message = table.concat(arg," ") triggerServerEvent("printMsg",localPlayer,player,message) end end ,false,false) Also, GUIeditor example: showCursor(true) function printMsg(playerName,message) if playerName:len() == 0 then outputChatBox("No player name given") return end if message:len() == 0 then outputChatBox("No message given") return end local player = getPlayerFromName(playerName) if player then triggerServerEvent("printMsg",localPlayer,player,message) end end GUIEditor = { button = {}, label = {}, edit = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.button[1] = guiCreateButton(399, 484, 101, 48, "Send", false) GUIEditor.label[1] = guiCreateLabel(315, 384, 75, 32, "player name:", false) guiLabelSetHorizontalAlign(GUIEditor.label[1], "right", false) guiLabelSetVerticalAlign(GUIEditor.label[1], "center") GUIEditor.label[2] = guiCreateLabel(315, 434, 75, 32, "message:", false) guiLabelSetHorizontalAlign(GUIEditor.label[2], "right", false) guiLabelSetVerticalAlign(GUIEditor.label[2], "center") GUIEditor.edit[1] = guiCreateEdit(405, 381, 135, 35, "", false) GUIEditor.edit[2] = guiCreateEdit(405, 431, 340, 35, "aa", false) end ) addEventHandler("onClientGUIClick", resourceRoot, function() if source == GUIEditor.button[1] then printMsg(guiGetText(GUIEditor.edit[1]),guiGetText(GUIEditor.edit[2])) end end )
  3. Savannah

    Cross GUI

    Now I know this is going from client to server to client. If you're doing it just by command you can do it straight from the server. But since you want to do it through a gui, this is an example of how you could do it: Client-side: addCommandHandler("msg", function(_,playerName,...) if not playerName then outputChatBox("No player name given") return end if #arg == 0 then outputChatBox("No message given") return end local player = getPlayerFromName(playerName) if player then local message = table.concat(arg," ") triggerServerEvent("printMsg",localPlayer,player,message) end end ,false,false) addEvent("onMsg",true) addEventHandler("onMsg",root, function(msg) sender = getPlayerName(source) message = msg if isTimer(receiveTimer) then resetTimer(receiveTimer) else addEventHandler("onClientRender",root,drawMessage) receiveTimer = setTimer(function() removeEventHandler("onClientRender",root,drawMessage) sender,message = nil,nil end,5000,1) end end ) function drawMessage() dxDrawText("A message from "..sender..":", 15, 324, 279, 360, tocolor(255, 255, 255, 255), 1.50, "default", "left", "top", false, false, false, false, false) dxDrawText(message, 15, 368, 279, 529, tocolor(45, 203, 78, 255), 1.50, "default", "left", "top", false, true, false, false, false) end Server-side: addEvent("printMsg",true) addEventHandler("printMsg",root, function(player,message) triggerClientEvent(player,"onMsg",source,message) end )
  4. https://wiki.multitheftauto.com/wiki/Meta.xml <script src="example.lua" type="client" cache="false/>
  5. You can't get their name but you could store their name when they login For example: addEventHandler("onPlayerLogin",root, function(_,playerAcc) setAccountData(playerAcc,"name",getPlayerName(source)) end ) then get it elsewhere: local playerName = getAccountData(playerAcc,"name")
  6. Won't GuiSetText work?
  7. function horn(player) if isElement(horn) then stopSound(horn) else horn = playSound("Sirens/Sound_003.wav") setSoundVolume(horn, 0.3) end end addCommandHandler("horn", horn) bindKey("num_1", "down", horn) function siren(player) if isElement(siren) then stopSound(siren) else siren = playSound("Sirens/Sound_012.wav") setSoundVolume(siren, 0.3) end end addCommandHandler("siren", siren) bindKey("num_2", "down", siren) This should work. Fixed the binds for you too.
  8. Also one small thing, you might want to move the local total = 0 variable into the function above the loop, so the total gets reset everything you execute the command.
  9. Just move the outputChatBox line after the loop. You use the loop purely for counting here, you can output after. local lucre = {1500, 2500, 1000, 5000} local total = 0 function loopLucre(player, comandName) for _,v in pairs(lucre) do total = total + v end outputChatBox("My lucre is "..tostring(total), player, 255, 255, 0) end addCommandHandler("lucre", loopLucre)
  10. You can count them up this way: local total = 0 for _,v in pairs(lucre) do total = total + v end
  11. @LoPollo Fixed and edited it, my bad. You don't have to use tables if you're just trying to control one sound. You use isElement(sound) to check if it's playing.
  12. Eddy, what is it you need. Just a simple sound toggle? function sound003(player) if isElement(sound) then stopSound(sound) else sound = playSound("Sirens/Sound_003.wav") setSoundVolume(sound, 0.3) end end addCommandHandler("sound003", sound003) bindKey("num_1", "down", "sound003")
×
×
  • Create New...