Jump to content

Musamba

Members
  • Posts

    17
  • Joined

  • Last visited

Everything posted by Musamba

  1. Is the variable "sla" in "outputChatBox(xmlNodeGetName(sla))" defined?
  2. Io ho iniziato a fare tipo 3000 gamemode mai finite ahah
  3. Bella idea davvero hunterix! Sono anche io un fan sfegatato di TWD!
  4. I don't get why I always get this error: "mapmanager: Invalid map specified" function getRandomMapCompatibleWithGamemode(gamemode) local compatibleMaps = exports.mapmanager:getMapsCompatibleWithGamemode(gamemode) if #compatibleMaps == 0 then outputDebugString("CLIMBING: No maps.") return false end local map = compatibleMaps[math.random(1, #compatibleMaps)] if exports["mapmanager"].isMap(map) then return map else outputDebugString("CLIMBING: Map not compatible("..getResourceName(map)..")") return false end end function lastCheckpoint(player) outputChatBox(getPlayerName(player).. " #ffffffhas won the match!", root, 0, 0, 0, true) if not exports["mapmanager"].changeGamemodeMap(getRandomMapCompatibleWithGamemode(getThisResource()), getThisResource()) then outputDebugString("CLIMBING: Map not changed.") end end addEvent("lastCheckpoint", true) addEventHandler("lastCheckpoint", root, lastCheckpoint)
  5. addEventHandler ("onMarkerHit",getRootElement(), function (jugador) if (source == marker1) then triggerClientEvent (jugador,"showGUI",getRootElement(),jugador) elseif (source == marker2) then triggerClientEvent (jugador,"showGUI",getRootElement(),jugador) elseif (source == marker3) then triggerClientEvent (jugador,"showGUI",getRootElement(),jugador) if source == marker then triggerClientEvent (jugador,"showGUI",getRootElement(),jugador) end end end )
  6. function consoleCreateMarker ( thePlayer, commandName ) if ( thePlayer ) then local x, y, z = getElementPosition ( thePlayer ) theMarker = createMarker ( x + 2, y + 2, z, "cylinder", 1.5, 255, 255, 0, 170 ) if ( theMarker ) then outputConsole ( "Marker created successfully", thePlayer ) else outputConsole ( "Failed to create marker", thePlayer ) end end end addCommandHandler ( "createmarker", consoleCreateMarker )
  7. Ok, i solved whit an alternative method: function addMapToFavourites(theMap, thePlayer) local serial = getPlayerSerial(thePlayer) local favs = executeSQLQuery("SELECT favmaps FROM userpanelDatas WHERE serial=?", serial) executeSQLQuery("UPDATE userpanelDatas SET favmaps='"..favs[1].favmaps..","..theMap.."' WHERE serial=?", serial) end function removeMapFromFavourites(theMap, thePlayer) local serial = getPlayerSerial(thePlayer) local favs = executeSQLQuery("SELECT favmaps FROM userpanelDatas WHERE serial=?", serial) local newData = "" for i, favmap in ipairs(split(favs[1].favmaps, ",")) do if favmap ~= theMap then newData = newData..","..favmap end end executeSQLQuery("UPDATE userpanelDatas SET favmaps='"..newData.."' WHERE serial=?", serial) end function mfavCommand(source, command) local currentMap = tostring(getResourceInfo(exports['mapmanager']:getRunningGamemodeMap(), "name")) local serial = getPlayerSerial(source) local favs = executeSQLQuery("SELECT favmaps FROM userpanelDatas WHERE serial=?", serial) if type(favs[1].favmaps) == "string" then if string.find(favs[1].favmaps, currentMap, 1, true) then removeMapFromFavourites(currentMap, source) outputChatBox("#0000ffThis map has been remove from your favourite maps#ff0000! #0000ffUse #ffffff/mfav#0000ff for mark it as favourite!", source, 255, 255, 255, true) else addMapToFavourites(currentMap, source) outputChatBox("#0000ffThis map has been added to your favourite maps#ff0000! #0000ffUse #ffffff/mfav#0000ff again for remove as favourite!", source, 255, 255, 255, true) end end end addCommandHandler("mfav", mfavCommand)
  8. Sorry but you function donsn't work because "favmap" variable is not a table.. Anyway i tryed to fix my function and i did it (Thanks Jaysds1, i used the string.find function like you used it in your function), but it still doen't work and i found the problem: the string.gsub does't work! function mfavCommand(source, command) local currentMap = tostring(getResourceInfo(exports['mapmanager']:getRunningGamemodeMap(), "name")) local serial = getPlayerSerial(source) local favs = executeSQLQuery("SELECT favmaps FROM userpanelDatas WHERE serial=?", serial) if type(favs[1].favmaps) == "string" then if string.find(favs[1].favmaps, currentMap, 1, true) then executeSQLQuery("UPDATE userpanelDatas SET favmaps='"..string.gsub(favs[1].favmaps, ","..currentMap, "").."' WHERE serial=?", serial) outputChatBox("#0000ffThis map has been remove from your favourite maps#ff0000! #0000ffUse #ffffff/mfav#0000ff for mark it as favourite!", source, 255, 255, 255, true) else executeSQLQuery("UPDATE userpanelDatas SET favmaps='"..favs[1].favmaps..","..currentMap.."' WHERE serial=?", serial) outputChatBox("#0000ffThis map has been added to your favourite maps#ff0000! #0000ffUse #ffffff/mfav#0000ff again for remove as favourite!", source, 255, 255, 255, true) end end outputChatBox(","..currentMap) --FIRST OUTPUT outputChatBox(favs[1].favmaps:gsub(tostring(","..currentMap), ""))--SECOND OUTPUT end addCommandHandler("mfav", mfavCommand) The outputs at line 14 and 15 are the same! So i think the problem is this: favs[1].favmaps:gsub(tostring(","..currentMap), "")
  9. Guys this is the full function, please help me... function mfavCommand(source, command) local currentMap = tostring(getResourceInfo(exports['mapmanager']:getRunningGamemodeMap(), "name")) local serial = getPlayerSerial(source) local favs = executeSQLQuery("SELECT favmaps FROM userpanelDatas WHERE serial=?", serial) if favs[1].favmaps then if string.find(favs[1].favmaps, currentMap) then outputChatBox("found") if string.find(favs[1].favmaps, ","..currentMap) then executeSQLQuery("UPDATE userpanelDatas SET favmaps='"..string.gsub(favs[1].favmaps,","..currentMap, "").."' WHERE serial=?", serial) elseif string.find(favs[1].favmaps, currentMap..",") then executeSQLQuery("UPDATE userpanelDatas SET favmaps='"..string.gsub(favs[1].favmaps,currentMap..",", "").."' WHERE serial=?", serial) end outputChatBox("#0000ffThis map has been remove from your favourite maps#ff0000! #0000ffUse #ffffff/mfav#0000ff for mark it as favourite!", source, 255, 255, 255, true) else outputChatBox("not found") executeSQLQuery("UPDATE userpanelDatas SET favmaps='"..favs[1].favmaps..","..currentMap.."' WHERE serial=?", serial) outputChatBox("#0000ffThis map has been added to your favourite maps#ff0000! #0000ffUse #ffffff/mfav#0000ff again for remove as favourite!", source, 255, 255, 255, true) end end end addCommandHandler("mfav", mfavCommand) The error is the same: Always "not found"!
  10. False? This should work like this: If there is not the current map name in the string got from an SQL Query it will add it, otherwise it will remove the current map name from it... Should work but it wont...
  11. What other infos you need?
  12. I always get the output "not found", it's a command: if string.find(favs[1].favmaps, currentMap) then outputChatBox("found") if string.find(favs[1].favmaps, ","..currentMap) then executeSQLQuery("UPDATE userpanelDatas SET favmaps='"..string.gsub(favs[1].favmaps,","..currentMap, "").."' WHERE serial=?", serial) elseif string.find(favs[1].favmaps, currentMap..",") then executeSQLQuery("UPDATE userpanelDatas SET favmaps='"..string.gsub(favs[1].favmaps,currentMap..",", "").."' WHERE serial=?", serial) end outputChatBox("#0000ffThis map has been remove from your favourite maps#ff0000! #0000ffUse #ffffff/mfav#0000ff for mark it as favourite!", source, 255, 255, 255, true) else outputChatBox("not found") executeSQLQuery("UPDATE userpanelDatas SET favmaps='"..favs[1].favmaps..","..currentMap.."' WHERE serial=?", serial) outputChatBox("#0000ffThis map has been added to your favourite maps#ff0000! #0000ffUse #ffffff/mfav#0000ff again for remove as favourite!", source, 255, 255, 255, true) end
  13. If i use this code: math.floor(100*(getElementHealth(vehicle)/1000)) When my vehicle is burning remains at 25% when should be at 0%, but when i'm not damaged it's at 100% If i use this one: math.floor(1000*(getElementHealth(vehicle)/100)) It's the same thing of the first one but whit 1 more 0: 25% = 250% - 100% = 1000% Can someone help me?
×
×
  • Create New...