Jump to content

Saml1er

Retired Staff
  • Posts

    1,058
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Saml1er

  1. Why are you using 2 same event handlers? addEventHandler("onClientRender", root, function () local vehicle = getPedOccupiedVehicle( localPlayer ) if ( vehicle ) then local vehicleHealth = getElementHealth( vehicle ) local scx, scy = guiGetScreenSize() dxDrawText( ( math.floor( vehicleHealth ) ).." %", scx - 125,scy - 70,scx,scx,tocolor(255,255,255,255),0.9, "arial","center","top",false,false,false) end end )
  2. Harder to know if the driver has been killed by that shot ... Why so? if weapon == 19 then I haven't tested it either but I hope it works.
  3. Yep. It also works for functions, tables etc.
  4. Cool. I don't need to use colshapes anymore.
  5. getProjectileTarget() hmmm? Did try to use this?
  6. Saml1er

    Hex Color Help

    Now it does not turn on at all Try to debug ( go to your server and login > type/debugscript 3 ) it. Since I'm on from mobile, I can't scroll +200 lines.
  7. Saml1er

    Hex Color Help

    Copy the code again from my first post.
  8. Saml1er

    Blocking

    Thats weird. Try debugging it.
  9. Saml1er

    Blocking

    That's impossible. You must use an end when you use break anways you can do it without break ( just remove break from the code you posted just now ) well but I wanted to break the loop when we get the blocked player or send the pm btw did you test the code ?
  10. Saml1er

    Blocking

    You're missing an "end". If you're saving the player's name in the table then it should definitely work. function lolok(ply) local playername = getPlayerName(ply) for _,v in ipairs(blocked) do if v == playername then outputChatBox("block") break else outputChatBox("Message sent",255,255,255,true) end end end end addEvent("xD", true) addEventHandler("xD", root, lolok)
  11. Saml1er

    Hex Color Help

    Huh, just copy all this. --- DONT TRY TO COPY LITTLE BITCH g_LocalPlayer = getLocalPlayer() g_Root = getRootElement() g_ThisResource = getThisResource() g_ResourceRoot = getResourceRootElement(getThisResource()) chat = {} -- table to store chat windows in newmsg = {show=false, tick=getTickCount(), showtime=5000, img=nil, lbl=nil } -- new msg table anims = {} function buildPlayerList() local x,y = guiGetScreenSize() local width,height = 175,350 x = x-width y = (y-height)/2 newmsg.img = guiCreateStaticImage(681.0000,134.0000, 42.0000,34.0000, "image/chat-icon.png", false) -- mail message icon newmsg.lbl = guiCreateLabel(553.0000,175.0000, 244.0000, 19.0000, "", false) guiLabelSetHorizontalAlign(newmsg.lbl, "right", true) guiSetAlpha(newmsg.img, 0) --guiSetAlpha(newmsg.lbl, 0) wndPlayers = guiCreateWindow(x,y,width,height, "Private Chat", false) grdPlayers = guiCreateGridList(.025,.065, .975,.915, true, wndPlayers) colPlayers = guiGridListAddColumn(grdPlayers, "Players", 0.85) local players = getElementsByType("player") for k,v in ipairs(players) do addPlayerToList(v) end guiWindowSetSizable(wndPlayers, false) guiSetProperty(wndPlayers, "RollUpEnabled", "true") guiSetProperty(wndPlayers, "Dragable", "true") guiSetAlpha(wndPlayers, 0) -- create animations for it anims.plfadein = Animation.create(wndPlayers, Animation.presets.guiFadeIn(1000)) anims.plfadeout = Animation.create(wndPlayers, Animation.presets.guiFadeOut(1000)) anims.nmfadein = Animation.create(newmsg.img, Animation.presets.guiFadeIn(1000)) anims.nmfadeout = Animation.create(newmsg.img, Animation.presets.guiFadeOut(1000)) anims.nmtextin = Animation.create(newmsg.lbl, Animation.presets.guiFadeIn(1000)) anims.nmtextout = Animation.create(newmsg.lbl, Animation.presets.guiFadeOut(1000)) --[[ local x,y = guiGetPosition(newmsg.img) outputDebugString("guigetPostions: " ..tostring(x).." "..tostring(y)) local scrx,scry = guiGetScreenSize() anims.nmslidein = Animation.create(newmsg.img, Animation.presets.guiMove(x,y))--, 1000,false, scrx,scry, false)) anims.nmslideout = Animation.create(newmsg.img, Animation.presets.guiMove(scrx,scry))--, 1000,false, x,y, false)) ]] bindKey("F2", "down", togglePmGui) end function addPlayerToList(ply) --outputDebugString("addPlayerToList:" ..getPlayerName(ply)):gsub("#%x%x%x%x%x%x","") local row = guiGridListAddRow(grdPlayers) local name=getPlayerName(ply):gsub("#%x%x%x%x%x%x","") guiGridListSetItemText(grdPlayers,row,colPlayers, name, false, false) end function removePlayerFromList(ply) --outputDebugString("removePlayerFromList:" ..getPlayerName(ply)):gsub("#%x%x%x%x%x%x","") local name=getPlayerName(ply):gsub("#%x%x%x%x%x%x","") for row=0,guiGridListGetRowCount(grdPlayers) do if guiGridListGetItemText(grdPlayers, row, colPlayers) == name then guiGridListRemoveRow(grdPlayers, row) outputDebugString("remove row" ..tostring(row)) end end end function showPmGui(state) if state == true then anims.plfadein:play() for k,v in pairs(chat) do guiSetVisible(chat[k].wnd,true) end showCursor(true) elseif state == false then anims.plfadeout:play() for k,v in pairs(chat) do guiSetVisible(chat[k].wnd,false) end showCursor(false) guiSetInputEnabled(false) end end function togglePmGui() if not anims.plfadein:isPlaying() and not anims.plfadeout:isPlaying() then if guiGetAlpha(wndPlayers) > .1 then showPmGui(false) else showPmGui(true) end end end function buildChatWindow(ply) local x,y = guiGetScreenSize() local width,height = 300,250 x = x*.5 y = y*.5 chat[ply] = {} chat[ply].wnd = guiCreateWindow(x,y,width,height, getPlayerName(ply):gsub("#%x%x%x%x%x%x","") , false) chat[ply].memo = guiCreateMemo(.025,.075, .95,.55, "", true, chat[ply].wnd) chat[ply].edit = guiCreateEdit(.025,.65, .95,.15, "", true, chat[ply].wnd) chat[ply].btnClose = guiCreateButton(.1,.83, .3,.125, "Close", true, chat[ply].wnd) chat[ply].btnSend = guiCreateButton(.6,.83, .3,.125, "Send", true, chat[ply].wnd) guiMemoSetReadOnly(chat[ply].memo, true) guiWindowSetSizable(chat[ply].wnd, false) guiSetProperty(chat[ply].wnd, "RollUpEnabled", "true") guiSetProperty(chat[ply].wnd, "Dragable", "true") if anims.plfadein:isPlaying() then-- in process of fading in guiSetVisible(chat[ply].wnd, true) elseif anims.plfadeout:isPlaying() then -- in process of fading out guiSetVisible(chat[ply].wnd, false) else -- not in process of either if guiGetAlpha(wndPlayers) > .1 then guiSetVisible(chat[ply].wnd, true) -- is showing else guiSetVisible(chat[ply].wnd, false) -- isnt showing end end end function destroyChatWindow(ply) if chat[ply] and isElement(chat[ply].wnd) then destroyElement(chat[ply].wnd) chat[ply] = nil end end function sendChatMessage(ply) --outputDebugString("sendChatMessage: " .. tostring(ply)) if chat[ply] and isElement(chat[ply].wnd) then local newText = guiGetText(chat[ply].edit) if newText and string.len(newText) > 0 then local oldText = guiGetText(chat[ply].memo) if not oldText then oldText = "" end oldText = oldText .. getPlayerName(g_LocalPlayer):gsub("#%x%x%x%x%x%x","") .. ": " .. newText .. "\n" guiSetText(chat[ply].memo, oldText) guiSetText(chat[ply].edit, "") guiMemoSetCaretIndex(chat[ply].memo, string.len(oldText)) triggerServerEvent("onGUIPrivateMessage", g_LocalPlayer, ply,newText) end end end function recieveChatMessage(ply, msg) --outputDebugString("recieveChatMessage: " .. msg) if not chat[ply] then buildChatWindow(ply) end newmsg.show = true newmsg.tick = getTickCount() ---guiSetText(newmsg.lbl, getPlayerName(ply):gsub("#%x%x%x%x%x%x","") .. ": " .. msg .. "\n") guiSetText(newmsg.lbl, "New Messages " .. getPlayerName(ply):gsub("#%x%x%x%x%x%x","") .. "\n") anims.nmfadein:play() anims.nmtextin:play() --anims.nmslidein:play() local oldText = guiGetText(chat[ply].memo) if not oldText then oldText = "" end oldText = oldText .. getPlayerName(ply):gsub("#%x%x%x%x%x%x","") .. ": " .. msg .. "\n" guiSetText(chat[ply].memo, oldText) guiMemoSetCaretIndex(chat[ply].memo, string.len(oldText)) end event_resource_start = function(res) buildPlayerList() outputChatBox("",255,255,255,true) end event_resource_stop = function(res) unbindKey("F2", "down", togglePmGui) showPmGui(false) end event_player_join = function() --outputDebugString("onClientPlayerJoin") addPlayerToList(source) end event_player_quit = function() --outputDebugString("onClientPlayerQuit") removePlayerFromList(source) destroyChatWindow(source) end event_gui_click = function(button, state, absx, absy) if button == "left" and state == "up" then if getElementType(source) == "gui-button" then local parent = getElementParent(source) if parent ~= false then local ply = getPlayerFromName(guiGetText(parent)) if ply then if source == chat[ply].btnClose then destroyChatWindow(ply)[youtube][/youtube] guiSetInputEnabled(false) elseif source == chat[ply].btnSend then sendChatMessage(ply) guiSetInputEnabled(false) end end end elseif getElementType(source) == "gui-edit" then local parent = getElementParent(source) if parent ~= false then local ply = getPlayerFromName(guiGetText(parent)) if source == chat[ply].edit then guiSetInputEnabled(true) end end else guiSetInputEnabled(false) end end end event_gui_doubleclick = function(button, state, absx, absy) if button == "left" and state == "up" then if source == grdPlayers then local row, col = guiGridListGetSelectedItem(grdPlayers) --outputDebugString("double clicked row: "..tostring(row)) if row == -1 or col == -1 then return end local name = guiGridListGetItemText(grdPlayers, row, col) local ply = getPlayerFromName(name) if not chat[ply] then buildChatWindow(ply) end guiBringToFront(chat[ply].wnd) end end end event_gui_accepted = function(element) local parent = getElementParent(source) if parent ~= false then local ply = getPlayerFromName(guiGetText(parent)) if ply then if element == chat[ply].edit then sendChatMessage(ply) end end
  12. Saml1er

    Blocking

    There's a check. if v == getPlayerName (toPlayer) then This will remove the player specified in the command only.
  13. Saml1er

    Blocking

    You need to loop through the table. for _,v in ipairs(myTable) do if v == getPlayerName (toPlayer) then -- use getPlayerName (v) if you're storing him as a player break -- don't send him pm else -- send the pm end end end To unblock him addCommandHandler ("unblock", function ( commandName, sendToName) if sendToName then local toPlayer = (getPlayerFromParticalName (sendToName)) for _,v in ipairs(myTable) do if v == getPlayerName (toPlayer) then -- use getPlayerName (v) if you're storing him as a player table.remove (myTable, v ) -- use getPlayerName (v) if you're storing him as a player break end end end end end )
  14. Use guiBringToFront ( )
  15. Saml1er

    help :(

    function nightvision ( target ) if getElementType ( target ) == "player" then lTeam = getPlayerTeam(localPlayer) if (lTeam and getTeamName(lTeam) == "Team") then if (getCameraGoggleEffect() == "normal") then setCameraGoggleEffect("nightvision") elseif (getCameraGoggleEffect() == "nightvision") then setCameraGoggleEffect("normal") end end end end addEventHandler ( "onClientPlayerTarget", getRootElement(), nightvision) Then this should work. Test it.
  16. Saml1er

    help :(

    function nightvision ( target ) if getElementType ( target ) == "player" then lTeam = getPlayerTeam(localPlayer) if (lTeam and getTeamName(lTeam) == "Team") then if (getCameraGoggleEffect() == "normal") then setCameraGoggleEffect("nightvision") elseif (getCameraGoggleEffect() == "nightvision") then setCameraGoggleEffect("normal") end end end end addEventHandler ( "onClientPlayerTarget", getRootElement(), nightvision) You mean this??
  17. The two functions have the same Name. Just change the seconds lena function to lena2 but the best and less memory usage way would be to use elseif statement. function lena(thePlayer) local playerTeam = getPlayerTeam ( player ) local ss = getTeamName ( playerTeam ) if ss=="The Magic Assassins" then setTimer(azaz, 1800, 1, player) outputDebugString("It's works") setTimer(setElementPosition, 1800, 1 ,1094.7105712891,2092.7939453125,15.350400924683 ) elseif ss=="EleCtriC KiLlerS" then setTimer(setElementPosition, 1800, 1 ,7105712891,2092.7939453125,15.350400924683 ) outputDebugString("It's works") end end addEventHandler("onPlayerWasted",getRootElement(),lena) )
  18. Yes, thats it. No wonder why I wrote getPlayerFromName there
  19. local lvl = getElementData ( getPlayerFromName ( player ), "level" ) or "Can't find Player" Replace it with this and don't use dxDrawColor text because its dxDrawText supports hex code.
  20. Maths! Health = 50 Health = tonumber (Health) / 100 * 100 print ( Health.."%") -- 50 % As much as I know total health should be 100 or check it by yourself
  21. findMap( query ) function is missing.
  22. Saml1er

    Need some help!

    Too lazy to retype it again So.
  23. Not needed. Do something like This: local mesg = "" addCommandHandler("say", function (player,_,msg) local time = getRealTime() local hours = time.hour local minutes = time.minute mesg = mesg.." [:"..hours..":"..minutes.."]"..msg end ) function LogTimer () File = fileOpen ("logs.txt") if File then fileWrite (File, mesg ) else fileCreate ("logs.txt") File = fileOpen ("logs.txt") fileWrite (File, mesg ) end fileClose (File) end setTimer (LogTimer, 300000, 0 ) -- updating log file in every 1 hour I wrote this from mobile so couldn't test it but anyways this Just an example. ⌒.⌒ I had thought of something like that but my mta server does not allow direct link then I do not know how to read the file from website which is located on a different server My script is saving the logs in your resources folder. Its not sending any data to any website. Its keeps updating the log file after every one hour by a timer anyways I added another line to clear the data in memory when the data is saved in log file. You can access that file by MTA > Mods > Deathmatch > resources > logs
  24. Not needed. Do something like This: local mesg = "" addCommandHandler("say", function (thePlayer,_,msg) local time = getRealTime() local hours = time.hour local minutes = time.minute mesg = mesg.." [:"..hours..":"..minutes.."] "..getPlayerName ( thePlayer )..": "..msg end ) function LogTimer () File = fileOpen ("logs.txt") if File then fileWrite (File, mesg ) else fileCreate ("logs.txt") File = fileOpen ("logs.txt") fileWrite (File, mesg ) end fileClose (File) mesg = "" end setTimer (LogTimer, 300000, 0 ) -- updating log file in every 1 hour I wrote this from mobile so couldn't test it but anyways this is just an example. ⌒.⌒
×
×
  • Create New...