Jump to content

Castillo

Retired Staff
  • Posts

    21,935
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by Castillo

  1. -- client side: GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Grid = {} GUIEditor_Image = {} GUIEditor_Window[1] = guiCreateWindow(372,198,451,297,"Anti-Chat V2.0 For Spar/Cw",false) guiWindowSetMovable(GUIEditor_Window[1],false) guiWindowSetSizable(GUIEditor_Window[1],false) GUIEditor_Grid[1] = guiCreateGridList(9,24,248,264,false,GUIEditor_Window[1]) guiGridListAddColumn(GUIEditor_Grid[1],"Players",0.80) GUIEditor_Button[1] = guiCreateButton(269,26,138,35,"Yes",false,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(263,95,161,32,"No",false,GUIEditor_Window[1]) GUIEditor_Image[1] = guiCreateStaticImage(256,135,168,139,"images/mtalogo.png",false,GUIEditor_Window[1]) function loadPlayersToGrid() guiGridListClear(GUIEditor_Grid[1]) for index, player in ipairs(getElementsByType("player")) do local row = guiGridListAddRow(GUIEditor_Grid[1]) guiGridListSetItemText(GUIEditor_Grid[1],row,1,tostring(getPlayerName(player)),false,false) end end loadPlayersToGrid() addEventHandler("onClientPlayerJoin",root,loadPlayersToGrid) addEventHandler("onClientPlayerQuit",root,loadPlayersToGrid) addEventHandler("onClientPlayerChangeNick",root,loadPlayersToGrid) addEventHandler("onClientGUIClick",root, function () if (source == GUIEditor_Button[1]) then local row,col = guiGridListGetSelectedItem(GUIEditor_Grid[1]) if (row and col and row ~= -1 and col ~= -1) then local playerName = guiGridListGetItemText(GUIEditor_Grid[1], row, 1) local player = getPlayerFromName(playerName) setElementData(player,"canChat",true) end elseif (source == GUIEditor_Button[2]) then local row,col = guiGridListGetSelectedItem(GUIEditor_Grid[1]) if (row and col and row ~= -1 and col ~= -1) then local playerName = guiGridListGetItemText(GUIEditor_Grid[1], row, 1) local player = getPlayerFromName(playerName) setElementData(player,"canChat",false) end end end) -- server side: addEventHandler("onPlayerChat",root, function (msg, msgType) local canChat = getElementData(source,"canChat") local r, g, b = getPlayerNametagColor(source) if (msgType == 0 and canChat) then outputChatBox(getPlayerName(source) .. ': #FFFFFF' .. msg, root, r, g, b, true) cancelEvent() else cancelEvent() end if (msgType == 2 and not canChat and getPlayerTeam(source)) then for index, player in ipairs(getPlayersInTeam(getPlayerTeam(source))) do outputChatBox("[TEAM]: ".. getPlayerName(source) .. ': #FFFFFF' .. msg, player, r, g, b, true) end cancelEvent() end end)
  2. That's all wrong, try this: function sendToJail() local wanted = getPlayerWantedLevel (source) if (wanted > 0) then local x, y, z = getElementPosition (source) local marker = createMarker (x, y, z, "cylinder", 7, 255, 255, 255, 255) for index, player in ipairs(getElementsWithinColShape(getElementColShape(marker), "player")) do if (getPlayerTeam(player) and getTeamName(getPlayerTeam(player)) == "Police") then setElementInterior (source, 5) setElementPosition (source,319,315,999) outputChatBox ("You arrested a quiter.", player, 0, 255, 0) givePlayerMoney (player, 2500) end end end end addEventHandler ("onPlayerQuit", getRootElement(), sendToJail)
  3. What are you trying to achieve? could you explain us at least?
  4. function kaboom(player) local x, y, z = getElementPosition ( player ) --Get the players position if (x and y and z) then createExplosion ( x, y, z, 8, true, 0, true) timers = getTimers ( 1000 ) -- Loop through the timer list for timerKey, timerValue in ipairs(timers) do -- kill the timer killTimer ( timerValue ) end end end setTimer(function() player = getRandomPlayer() x, y, z = getElementPosition(player) model1 = createObject(1654,0,0,0) if ( model1 ) then -- if it was created exports.bone:attachElementToBone(model1, player,3,0,-0.18,0.125,0,180,0) setTimer(kaboom, 15000, 1, player) end end, 30000, 0)
  5. Ni idea, estaba en tu script original, no lo vi .
  6. --creo la tabla con la lista de teclas permitidas allowedKeys = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "num_0", "num_1", "num_2", "num_3", "num_4", "num_5", "num_6", "num_7", "num_8", "num_9", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12"} --creo todos los elementos del gui window = guiCreateWindow(0.1941,0.306,0.1934,0.2318,"Position Saver",true) savelabel = guiCreateLabel(0.057,0.191,0.4144,0.0899,"Save Position Key:",true,window) guiLabelSetColor(savelabel,0,255,0) guiSetFont(savelabel,"default-bold-small") loadlabel = guiCreateLabel(0.0532,0.5899,0.4144,0.1067,"Load Position Key:",true,window) guiLabelSetColor(loadlabel,0,255,0) guiSetFont(loadlabel,"default-bold-small") editload = guiCreateEdit(0.0456,0.7528,0.3916,0.1404,"",true,window) editsave = guiCreateEdit(0.0456,0.3596,0.384,0.1404,"",true,window) okbtn = guiCreateButton(0.5323,0.3202,0.403,0.2528,"OK",true,window) guiSetFont(okbtn,"default-bold-small") cancelbtn = guiCreateButton(0.5323,0.6461,0.403,0.2528,"Cancel",true,window) guiSetFont(cancelbtn,"default-bold-small") -- y los oculto para que el gui aparezca cuando llame la funcion guiSetVisible (window, false) guiSetInputEnabled (false) function clickok () --creo la funcion que se va a llamar cuando el cliente clickee el boton "OK". loadkey1 = guiGetText (editload) -- defino el texto del "editload" del gui como loadkey1 savekey1 = guiGetText (editsave) -- defino el texto del "editsave" del gui como savekey1 if (not isKeyOnTable(tostring(savekey1))) then outputChatBox("This key is not valid.",255,0,0) return end --[[aca tendria que poner una condicion, si lo que esta en el "editload" y "editsave" esta en la tabla creada anteriormente entonces ejecutar lo que esta abajo, y si no lo estan, dar un mensaje como "invalid keys" o algo asi, pero no se como hacer eso. ]] triggerServerEvent ("changeBinds", getRootElement(), savekey1, loadkey1) -- llamo al evento server, ya que la funcion que quiero que llame la tecla que pongo en el gui esta serverside. outputChatBox ("#AAAAAAKeys successfully changed to:" , 0, 0, 0, true) -- pongo en el chat lo que paso outputChatBox ("#AAAAAASave:#00FF00 "..savekey1 , 0, 0, 0, true) outputChatBox ("#AAAAAALoad:#00FF00 "..loadkey1 , 0, 0, 0, true) guiSetVisible (window, false) --oculto el gui guiSetInputEnabled (false) end function clickcan () guiSetVisible (window, false) --oculto el gui cuando clickeen en cancel guiSetInputEnabled (false) end function openp () guiSetVisible (window, true) guiSetInputEnabled (true) end bindKey ("F6", "down", openp) addEventHandler ("onClientGUIClick", okbtn, clickok, false) addEventHandler ("onClientGUIClick", cancelbtn, clickcan, false) function isKeyOnTable(theKey) for index, key in ipairs(allowedKeys) do if (theKey == key) then return true end end return false end Probalo.
  7. Castillo

    Que falla ?

    La funcion engineLoadIFP esta desactivada, no se puede usar.
  8. You're welcome.
  9. Of course it's possible. function setRank(thePlayer, cmd, who, ...) if (who and who ~= "") then local player = getPlayerFromName(who) local rank = table.concat({...}, " ") if (not player) then outputChatBox("This player does not exists.",thePlayer,255,0,0) return end setElementData(player,"Rank",tostring(rank)) end end addCommandHandler("setRank",setRank)
  10. function setRank(thePlayer, cmd, who) if (who and who ~= "") then local player = getPlayerFromName(who) if (not player) then outputChatBox("This player does not exists.",thePlayer,255,0,0) return end setElementData(player,"Rank","Awesome") end end addCommandHandler("setRank",setRank)
  11. -- client side: local marker = createMarker (1282, -1664.5999755859, 12.5, "cylinder", 2, 255, 255, 255, 255) function GUIEditor_Window() GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Label = {} GUIEditor_Window[1] = guiCreateWindow(1031,232,301,397,"SWAT job",false) GUIEditor_Label[1] = guiCreateLabel(193,-103,5,5,"",false,GUIEditor_Window[1]) GUIEditor_Button[1] = guiCreateButton(22,352,108,35,"Take job",false,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(179,352,110,36,"Cancel",false,GUIEditor_Window[1]) addEventHandler("onClientGUIClick", GUIEditor_Button[2], closeWindow, false) GUIEditor_Memo[1] = guiCreateMemo(19,33,273,215,"To take SWAT team job, press Take job.\n\nIf you don't want to, press Cancel.\n\n\nNOTE: You need to be into SWAT team group.",false,GUIEditor_Window[1]) end -- show GUI -- function showWindow (hitPlayer) if (hitPlayer ~= localPlayer) then return end local getVisible = guiGetVisible (GUIEditor_Window[1]) if (getVisible) then guiSetVisible (GUIEditor_Window[1], false) showCursor (false) else guiSetVisible (GUIEditor_Window[1], true) showCursor (true) end end addEventHandler ("onClientMarkerHit", marker, showWindow) -- Remove GUI -- function closeWindow () if guiGetVisible(GUIEditor_Window[1]) then guiSetVisible(GUIEditor_Window[1], false) showCursor(false) end end -- server side: function createSWATTeam () SWATTeam = createTeam ("SWAT Team", 0, 0, 255) end addEventHandler ("onResourceStart", resourceRoot, createSWATTeam)
  12. function sayHello(thePlayer, cmd, who) if (who and who ~= "") then local player = getPlayerFromName(who) if (not player) then outputChatBox("This player does not exists.",thePlayer,255,0,0) return end outputChatBox("Hello ".. getPlayerName(player) .. " from ".. getPlayerName(thePlayer) .."!",player,0,255,0) end end addCommandHandler("hello",sayHello) That?
  13. Castillo

    Error

    Copia el script de nuevo y proba.
  14. I don't understand what do you mean, you want to restrict commands using ACL? or for only some players? like checking their serials.
  15. You're welcome . P.S: I would add to kill, destroy markers on quit.
  16. Castillo

    Error

    local timers = {} addEvent("cuandoUnZombieEsCreado",true) addEventHandler("cuandoUnZombieEsCreado",root, function () if ( getElementModel (source) == 287) then timers[source] = setTimer ( encenderZombie, 100, 0, source ) end end ) function encenderZombie(zombie) if (isElement(zombie) and getElementHealth(zombie) > 0) then setPedOnFire(zombie, true) else if isTimer(timers[zombie]) then killTimer(timers[zombie]) end end end
  17. local markers = {} local timers = {} function startLights( player, cmd ) if (not markers[player]) then markers[player] = {} end if (not timers[player]) then timers[player] = {} end if isTimer(timers[player][1]) then killTimer(timers[player][1]) end if isTimer(timers[player][2]) then killTimer(timers[player][2]) end if isElement(markers[player][1]) then destroyElement(markers[player][1]) end if isElement(markers[player][2]) then destroyElement(markers[player][2]) end local vehicle = getPedOccupiedVehicle(player) local x,y,z = getElementPosition( vehicle ) obj1 = createObject(2710,x,y,z) attachElements(obj1,vehicle,0.5,0.7,1.19) obj2 = createObject(2710,x,y,z) attachElements(obj2,vehicle,-0.5,0.7,1.19) markers[player][1] = createMarker(x,y,z,"corona",0.25,0,0,255,0) attachElements(markers[player][1], obj1, 0, 0, 0.1) markers[player][2] = createMarker(x,y,z,"corona",0.25,0,0,255,0) attachElements(markers[player][1], obj2, 0, 0, 0.1) local random1 = math.random(50,300) local random2 = math.random(50,300) timers[player][1] = setTimer( flash1, random1, 0, player ) timers[player][2] = setTimer( flash2, random2, 0, player ) end addCommandHandler ( "light", startLights) function flash1(player) setMarkerColor(markers[player][1], 0, 0, 255, 200) setTimer( setMarkerColor, 50, 1, markers[player][1], 0, 0, 0, 0) end function flash2(player) setMarkerColor(markers[player][2], 0, 0, 255, 200) setTimer( setMarkerColor, 50, 1, markers[player][2], 0, 0, 0, 0) end
  18. Castillo

    Que falla ?

    Deberias mirar en la wiki antes de usar una funcion.
  19. Yeah, also, every time someone write that command another two different markers would be created with the same variable name, that's why I used a table.
  20. Castillo

    Error

    Postea la funcion "encenderZombie".
  21. Try this: local markers = {} function startLights( player, cmd ) if (not markers[player]) then markers[player] = {} end local vehicle = getPedOccupiedVehicle(player) local x,y,z = getElementPosition( vehicle ) obj1 = createObject(2710,x,y,z) attachElements(obj1,vehicle,0.5,0.7,1.19) obj2 = createObject(2710,x,y,z) attachElements(obj2,vehicle,-0.5,0.7,1.19) markers[player][1] = createMarker(x,y,z,"corona",0.25,0,0,255,0) attachElements(markers[player][1], obj1, 0, 0, 0.1) markers[player][2] = createMarker(x,y,z,"corona",0.25,0,0,255,0) attachElements(markers[player][1], obj2, 0, 0, 0.1) local random1 = math.random(50,300) local random2 = math.random(50,300) setTimer( flash1, random1, 0, player ) setTimer( flash2, random2, 0, player ) end addCommandHandler ( "light", startLights) function flash1(player) setMarkerColor(markers[player][1], 0, 0, 255, 200) setTimer( setMarkerColor, 50, 1, markers[player][1], 0, 0, 0, 0) end function flash2(player) setMarkerColor(markers[player][2], 0, 0, 255, 200) setTimer( setMarkerColor, 50, 1, markers[player][2], 0, 0, 0, 0) end
  22. That error means the function "flash2" is nil, post the rest of the script.
  23. function checkowner (player,seat,jacked) local account = getPlayerAccount( player) if (seat == 0 and not isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup( 'Admin' ))) then outputChatBox ( "You cannot drive this vehicle as it belongs to Admins ", player, 200, 0, 0 ) cancelEvent() end end
  24. @Yakuza.Real: Have you tested my function? I've tested it and seems to work fine.
  25. function getAllMapVehicles() local vehicles = {} for index, vehicle in ipairs(getElementsByType("vehicle")) do local ID = getElementID(vehicle) if (ID ~= "") then table.insert(vehicles, vehicle) end end return vehicles end Should do the job.
×
×
  • Create New...