Jump to content

Castillo

Retired Staff
  • Posts

    21,935
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by Castillo

  1. Pero no se oira raro cuando dispara se combinen los 2 sonidos? bueno aun asi cheque en la wiki y el sonido se reproduce en un cierto lugar asi que pense combinar el playSound3D Con una funcion que consiga la localizacion del jugador mas no encontre esa funcion existira? Usa getElementPosition
  2. Castillo

    Help pls!

    it is possible, just use "getPedWeapon". alreadyS = 0 addEventHandler("onPlayerJoin",root, function () bindKey(source,"x","down",setStat) end) addEventHandler("onResourceStart",resourceRoot, function () for index, player in ipairs(getElementsByType("player")) do bindKey(player,"x","down",setStat) end end) function setStat(player) local currentWeaponID = getPedWeapon(player) if (currentWeaponID == 34) then if (alreadyS == 0) then setPedStat ( player, 79, 300 ) alreadyS = 1 outputChatBox("Works", player, 255, 69, 0) else setPedStat ( player, 79, 999 ) alreadyS = 0 outputChatBox("works!!.", player, 255, 69, 0) end end end
  3. No podes cambiar el sonido (osea remplazarlo), pero podes poner uno ensima. Usa el evento: "onClientPlayerWeaponFire" combinado con playSound3D https://wiki.multitheftauto.com/wiki/OnC ... WeaponFire
  4. Mira que a tu script le falta: fadeCamera y setCameraTarget si no la pantalla estara en negro.
  5. Castillo

    Stats

    Look, you and nobody will tell me how to organize my scripts, understood? I don't want to sound rude but it look's like you're saying I must do it that way or die. P.S: I didn't "tabulate" the code above because I just added a event handler.
  6. Castillo

    Stats

    Kenix: We all have different scripting ways.
  7. /me killed CapY (placed a plastic duck near the shower.)
  8. You can't compile maps, why would you do it?
  9. https://community.multitheftauto.com/index.php?p= ... ls&id=1316 I don't know if it works.
  10. onClientClick doesn't work for DX drawing, you must make your own event. You can use getCursorPosition to compare the position of the DX drawing with the mouse.
  11. You want to detect when click on a GUI element? if so use "onClientGUIClick". function news(_,_,_,_,_,_,_,clickedElement) if (clickedElement == login) then addEventHandler("onClientRender",rootElement, serverBoxDesign) end end addEventHandler ( "onClientClick", root, news )
  12. The resource must be in a folder, if it's in a ".zip" file the file will not be created.
  13. There's no need to add that resource to ACL, as it doesn't have any function that requires it. P.S: Maybe all the speedometers you've tested are bugged?
  14. The first argument of "onClientClick" is the mouse button pressed, not the world element clicked.
  15. What you don't understand is that you need Lua knowledge before converting it, is not that easy for a newbie (no offense).
  16. Castillo

    SOLVED

    I guess, I just added the event handler that was missing.
  17. -- client side: addEvent("playWastedSound",true) addEventHandler("playWastedSound",root, function (thePath) if (thePath and fileExists(thePath)) then local sound = playSound(thePath) setSoundVolume(sound, 1.5) end end) -- server side: addEventHandler("onPlayerWasted", root, function ( ammo, killer, killerweapon, bodypart ) if ( killer ) and ( killer ~= source ) then outputChatBox("**Great Shot Player +$40!**",killer,255,255,0) triggerClientEvent(killer,"playWastedSound",killer,"sounds/1.ogg") givePlayerMoney ( killer, 40 ) if (bodypart == 9) then outputChatBox("**OWned->HeadShot +$50**",killer,255,255,0) triggerClientEvent(killer,"playWastedSound",killer,"sounds/2.ogg") givePlayerMoney ( killer, 50 ) end else outputChatBox("**Woops Your Dead Try Next Time - $5**",source,255,255,0) triggerClientEvent(source,"playWastedSound",source,"sounds/3.ogg") takePlayerMoney( source, 5 ) end end) The other script: function levelup () local Exp = getElementData(localPlayer,"Exp") local Level = getElementData(localPlayer,"Level") if isElement(expLabel) then destroyElement(expLabel) end expLabel = guiCreateLabel(0.777,0.22,0.1708,0.0963,"EXP gained: ??\nTotal EXP: ".. tostring(Exp) .."\nLevel: ".. tostring(Level),true) guiLabelSetColor(expLabel,0,255,0) guiLabelSetVerticalAlign(expLabel,"top") guiLabelSetHorizontalAlign(expLabel,"left",false) guiSetFont(expLabel,"clear-normal") end setTimer ( levelup, 2000, 1)
  18. Try this: function globalOOC(thePlayer, commandName, ...) local logged = tonumber(getElementData(thePlayer, "loggedin")) if (logged==1) then if not (...) then outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14) else local oocEnabled = exports.global:getOOCState() message = table.concat({...}, " ") local muted = getElementData(thePlayer, "muted") if (oocEnabled==0) and not (exports.global:isPlayerAdmin(thePlayer)) then outputChatBox("OOC Chat is currently disabled.", thePlayer, 255, 0, 0) elseif (muted==1) then outputChatBox("You are currenty muted from the OOC Chat.", thePlayer, 255, 0, 0) else local players = exports.pool:getPoolElementsByType("player") local playerName = getPlayerName(thePlayer) local playerID = getElementData(thePlayer, "playerid") local r, g, b = getPlayerNametagColor(thePlayer) local adminTitle = exports.global:getPlayerAdminTitle(thePlayer) local hiddenAdmin = getElementData(thePlayer, "hiddenadmin") local adminLevel = exports.global:getPlayerAdminLevel(thePlayer) local accountName = getElementData(thePlayer,"gameaccountusername") exports.logs:logMessage("[OOC: Global Chat] " .. playerName .. ": " .. message, 1) for k, arrayPlayer in ipairs(players) do local logged = tonumber(getElementData(arrayPlayer, "loggedin")) local targetOOCEnabled = getElementData(arrayPlayer, "globalooc") if (logged==1) and (targetOOCEnabled==1) then if (accountName == "theAccountNameWithTag") then outputChatBox("(( [GOOC] #33FF00[TheTag]#FFFFCC (" .. playerID .. ") " .. playerName .. ": " .. message .. " ))", arrayPlayer, 255, 255, 204, true) return end if exports.global:isPlayerAdmin(thePlayer) then if (hiddenAdmin == 0) then if (adminLevel >= 1 and adminLevel < 4) then outputChatBox("(( [GOOC] #33FF00[" .. tostring(adminTitle) .. "]#FFFFCC (" .. playerID .. ") " .. playerName .. ": " .. message .. " ))", arrayPlayer, 255, 255, 204, true) elseif (adminLevel >= 4 and adminLevel < 1337) then outputChatBox("(( [GOOC] #c41212[" .. tostring(adminTitle) .. "]#FFFFCC (" .. playerID .. ") " .. playerName .. ": " .. message .. " ))", arrayPlayer, 255, 255, 204, true) end else if (exports.global:getPlayerDonatorLevel(thePlayer) > 0) then outputChatBox("(( [GOOC]#AD8200 [Donator]#FFFFCC (" .. playerID .. ") " .. playerName .. ": " .. message .. " ))", arrayPlayer, 255, 255, 204, true) else outputChatBox("(( [GOOC] (" .. playerID .. ") " .. playerName .. ": " .. message .. " ))", arrayPlayer, 255, 255, 204, true) end end else if (exports.global:getPlayerDonatorLevel(thePlayer) > 0) then outputChatBox("(( [GOOC]#AD8200 [Donator]#FFFFCC (" .. playerID .. ") " .. playerName .. ": " .. message .. " ))", arrayPlayer, 255, 255, 204, true) else outputChatBox("(( [GOOC] (" .. playerID .. ") " .. playerName .. ": " .. message .. " ))", arrayPlayer, 255, 255, 204, true) end end end end end end end end addCommandHandler("o", globalOOC, false, false) addCommandHandler("GlobalOOC", globalOOC) Change "theAccountNameWithTag" with the account name you want to be with a "special" tag, and "TheTag" with the tag.
  19. Castillo

    SOLVED

    call(getResourceFromName("scoreboard"), "addScoreboardColumn", "Race Wins") function DestructionWin( ) local alivePlayers = getAlivePlayers( ) if #alivePlayers == 1 then local account = getPlayerAccount( alivePlayers[1] ) local wins = getAccountData( account,"Race Wins" ) or 0 if account then if isGuestAccount( account ) then return end setAccountData( account,"Race Wins", wins + 1 ) end local playername = getPlayerName( alivePlayers[1] ) outputChatBox ( "#FFA824The player " .. playername .. " won!", root, 255, 255, 255, true ) end end addEventHandler( "onPlayerWasted", root,DestructionWin) addEventHandler( "onPlayerWasted", root, function( ) local account = getPlayerAccount( source ) local loses = getAccountData( account,"Race Loses" ) or 0 if account then if isGuestAccount( account ) then return end setAccountData( account,"Race Loses", loses + 1 ) end end ) function updateRatio (thePlayer) local account = getPlayerAccount( theplayer ) if account then if isGuestAccount( account ) then return end local wins = getAccountData( account, "Race Wins" ) or 0 local loses = getAccountData( account, "Race Loses" ) or 0 if loses == 0 then setAccountData(account, "ratio", "-") else local kdr = round( wins / loses, 2) setAccountData(account, "ratio", kdr) end end end function publicstatsinfo( ) if isElement( source ) then local account = getPlayerAccount( source ) if account then if isGuestAccount( account ) then return end local askdname = getPlayerName( source ) local wins = getAccountData( account, "Race Wins" ) or 0 local loses = getAccountData( account, "Race Loses" ) or 0 local ratio = getAccountData( account, "Ratio" ) or N/A if loses and wins then outputChatBox("#FFA824*" .. askdname .. " won " .. tostring( wins ) .. " times and he lost " ..tostring( loses ).. " times, his ratio is " .. tostring( ratio ) .. "%", root, 255, 12, 15, true) else outputChatBox("#FFA824*" .. askdname .. " doesen't losed or won " , root, 255, 12, 15, true) end end else outputChatBox( "Error source is not player" ) end end addEvent( "stats", true ) addEventHandler( "stats", root, publicstatsinfo ) function checkCommand( message, messageType ) if messageType == 0 then if message == "!stats" then triggerEvent( "stats", source ) elseif message == "!st" then triggerEvent( "stats", source ) cancelEvent( ) end end end addEventHandler( "onPlayerChat", root, checkCommand ) function getPlayerFromNamePart(Name) local thePlayer = getPlayerFromName(thePlayerName) if thePlayer then return thePlayer end for _,thePlayer in ipairs(getElementsByType("player")) do if string.find(string.gsub(getPlayerName(thePlayer):lower(),"#%x%x%x%x%x%x", ""), thePlayerName:lower(), 1, true) then return thePlayer end end return false end restriction = {} addCommandHandler("stats", function (thePlayer, cmd, whoToCheck) local playerName = getPlayerName(thePlayer) if restriction[playerName] then outputChatBox("#FFA824You have to wait 30 seconds", thePlayer, 255, 0, 0, true) else restriction[playerName] = true setTimer(restrictionEnd, 30000, 1, playerName) local player = getPlayerFromNamePart( whoToCheck ) if (player) then local account = getPlayerAccount( player ) if account then if isGuestAccount( account ) then return end local wins = getAccountData( account, "Race Wins" ) or 0 local loses = getAccountData( account, "Race Loses" ) or 0 ratio = (tonumber(wins)/tonumber(loses))*10 or N/A outputChatBox("#FFA824*[sTATS] Player's "..tostring(player).." stats : " , root, 255, 12, 15, true) if wins then outputChatBox("#FFA824*Wins: "..tostring(wins).."!", root, 255, 12, 15, true) else outputChatBox("#FFA824*Wins: 0 !" , root, 255, 12, 15, true) end if loses then outputChatBox("#FFA824*Loses: "..tostring(loses).."!", root, 255, 12, 15, true) else outputChatBox("#FFA824*Loses: 0 !", root, 255, 12, 15, true) end if ratio then outputChatBox("#FFA824*Ratio: "..tostring(ratio).."% !", root, 255, 12, 15, true) else outputChatBox("#FFA824*Ratio: - %", root, 255, 12, 15, true) end end else outputChatBox( "Player not found!" ) end end end) function restrictionEnd(playerName) restriction[playerName] = nil end
  20. Check this out: http://lua-users.org/wiki/TablesTutorial
  21. MTA Folder\server\mods\deathmatch\resources\[category]
  22. Castillo

    Stats

    function DestructionWin( ) local alivePlayers = getAlivePlayers( ) if #alivePlayers == 1 then local account = getPlayerAccount( alivePlayers[1] ) local wins = getAccountData( account,"Race Wins" ) or 0 if account then if isGuestAccount( account ) then return end setAccountData( account,"Race Wins", wins + 1 ) end local playername = getPlayerName( alivePlayers[1] ) outputChatBox ( "#FFA824The player " .. playername .. " won!", root, 255, 255, 255, true ) end end addEventHandler( "onPlayerWasted", root, function( ) local account = getPlayerAccount( source ) local loses = getAccountData( account,"Race Loses" ) or 0 if account then if isGuestAccount( account ) then return end setAccountData( account,"Race Loses", loses + 1 ) end end ) function updateRatio (thePlayer) local account = getPlayerAccount( theplayer ) if account then if isGuestAccount( account ) then return end local wins = getAccountData( account, "Race Wins" ) or 0 local loses = getAccountData( account, "Race Loses" ) or 0 if loses == 0 then setAccountData(account, "ratio", "-") else local kdr = round( wins / loses, 2) setAccountData(account, "ratio", kdr) end end end function publicstatsinfo( ) if isElement( source ) then local account = getPlayerAccount( source ) if account then if isGuestAccount( account ) then return end local askdname = getPlayerName( source ) local wins = getAccountData( account, "Race Wins" ) or 0 local loses = getAccountData( account, "Race Loses" ) or 0 local ratio = getAccountData( account, "Ratio" ) or N/A if loses and wins then outputChatBox("#FFA824*" .. askdname .. " won " .. tostring( wins ) .. " times and he lost " ..tostring( loses ).. " times, his ratio is " .. tostring( ratio ) .. "%", root, 255, 12, 15, true) else outputChatBox("#FFA824*" .. askdname .. " doesen't losed or won " , root, 255, 12, 15, true) end end else outputChatBox( "Error source is not player" ) end end addEvent( "stats", true ) addEventHandler( "stats", root, publicstatsinfo ) function checkCommand( message, messageType ) if messageType == 0 then if message == "!stats" then triggerEvent( "stats", source ) elseif message == "!st" then triggerEvent( "stats", source ) cancelEvent( ) end end end addEventHandler( "onPlayerChat", root, checkCommand ) function getPlayerFromNamePart(thePlayerName) local thePlayer = getPlayerFromName(thePlayerName) if thePlayer then return thePlayer end for _,thePlayer in ipairs(getElementsByType("player")) do if string.find(string.gsub(getPlayerName(thePlayer):lower(),"#%x%x%x%x%x%x", ""), thePlayerName:lower(), 1, true) then return thePlayer end end return false end restriction = {} addCommandHandler("stats", function (thePlayer, cmd, whoToCheck) local playerName = getPlayerName(thePlayer) if restriction[playerName] then outputChatBox("#FFA824You have to wait 30 seconds", thePlayer, 255, 0, 0, true) else restriction[playerName] = true setTimer(restrictionEnd, 30000, 1, playerName) local player = getPlayerFromNamePart( whoToCheck ) if (player) then local account = getPlayerAccount( player ) if account then if isGuestAccount( account ) then return end local wins = getAccountData( account, "Race Wins" ) or 0 local loses = getAccountData( account, "Race Loses" ) or 0 ratio = (tonumber(wins)/tonumber(loses))*10 or N/A outputChatBox("#FFA824*[sTATS] Player's "..tostring(player).." stats : " , root, 255, 12, 15, true) if wins then outputChatBox("#FFA824*Wins: "..tostring(wins).."!", root, 255, 12, 15, true) else outputChatBox("#FFA824*Wins: 0 !" , root, 255, 12, 15, true) end if loses then outputChatBox("#FFA824*Loses: "..tostring(loses).."!", root, 255, 12, 15, true) else outputChatBox("#FFA824*Loses: 0 !", root, 255, 12, 15, true) end if ratio then outputChatBox("#FFA824*Ratio: "..tostring(ratio).."% !", root, 255, 12, 15, true) else outputChatBox("#FFA824*Ratio: - %", root, 255, 12, 15, true) end end else outputChatBox( "Player not found!" ) end end end) function restrictionEnd(playerName) restriction[playerName] = nil end
×
×
  • Create New...