TheGuyNL
-
Posts
50 -
Joined
-
Last visited
Posts posted by TheGuyNL
-
-
-
Yes, I know that but I want that the player can select a map from a list and then buy it as next map. Not redo the current map (which is already in my stat system as a command named: !buy redo)
-
getRunningGamemodeMap gives me the current map but not the selected map, or does it?
-
So with getRunningGamemodeMap I can get the mapname to use set nextmap with?
-
Resource 'mapmanager' running?
Of course, it's always running with race.
-
Hello,
So I am making this mapshop for my server. A friend send me his old mapshop but it comes up with an error:
ERROR: call: failed to call 'mapmanager:getGamemodeMap' [string "?"]
It actually spams the console with this error when you try to open the GUI.
Here is my server-side script:
mapCost = 5000 -- Maps function getServerMaps (loadList) local tableOut if loadList then tableOut = {} -- local deletedMaps = {} local gamemodes = {} gamemodes = call(getResourceFromName("mapmanager"), "getGamemodes") for id,gamemode in ipairs (gamemodes) do tableOut[id] = {} tableOut[id].name = getResourceInfo(gamemode, "name") or getResourceName(gamemode) tableOut[id].resname = getResourceName(gamemode) tableOut[id].maps = {} local maps = call(getResourceFromName("mapmanager"), "getMapsCompatibleWithGamemode" , gamemode) for _,map in ipairs (maps) do table.insert(tableOut[id]["maps"] ,{name = getResourceInfo(map, "name") or getResourceName(map), resname = getResourceName(map)}) end table.sort(tableOut[id]["maps"], sortCompareFunction) end table.sort((tableOut), sortCompareFunction) table.insert(tableOut, {name = "no gamemode", resname = "no gamemode", maps = {}}) local countGmodes = #tableOut local maps = call(getResourceFromName("mapmanager"), "getMapsCompatibleWithGamemode") for id,map in ipairs (maps) do -- if fileOpen(":"..getResourceName(map).."/deleted") then -- table.insert(deletedMaps ,{name = getResourceInfo(map, "name") or getResourceName(map), resname = getResourceName(map)}) -- else table.insert(tableOut[countGmodes]["maps"] ,{name = getResourceInfo(map, "name") or getResourceName(map), resname = getResourceName(map)}) -- end end -- table.sort(deletedMaps, sortCompareFunction) table.sort(tableOut[countGmodes]["maps"], sortCompareFunction) -- table.insert(tableOut, {name = "deleted maps", resname = "deleted maps", maps = {}}) -- local countGmodes = countGmodes + 1 -- tableOut[countGmodes]["maps"] = deletedMaps end local map = call(getResourceFromName("mapmanager"), "getRunningGamemodeMap") local gamemode = call(getResourceFromName("mapmanager"), "getRunningGamemode") gamemode = gamemode and getResourceName(gamemode) or "N/A" map = map and getResourceName(map) or "N/A" callClientFunction(loadList,"loadMaps", tableOut, gamemode, map) end function sortCompareFunction(s1, s2) if type(s1) == "table" and type(s2) == "table" then s1, s2 = s1.name, s2.name end s1, s2 = s1:lower(), s2:lower() if s1 == s2 then return false end local byte1, byte2 = string.byte(s1:sub(1,1)), string.byte(s2:sub(1,1)) if not byte1 then return true elseif not byte2 then return false elseif byte1 < byte2 then return true elseif byte1 == byte2 then return sortCompareFunction(s1:sub(2), s2:sub(2)) else return false end end function callGetMaps() for i,player in ipairs(getElementsByType("player")) do callClientFunction(player,"getMaps") end end addCommandHandler("rebuildMaps",callGetMaps) -- Buy as next map function buyMap(thePlayer,mapName) local account = getPlayerAccount(player) local playerCash = getAccountData(acount,"cash") if mapIsAlreadySet == false then if not (mapName == "") then if playerCash >= mapCost then triggerEvent("onExternalNextmapRequest",thePlayer,thePlayer,mapName) else outputChatBox("#FF6600* You don't have enough money to set a map!",thePlayer,255,255,255,true) end else outputChatBox("#FF6600* Please select a map from the list first!",thePlayer,255,255,255,true) end else outputChatBox("#FF6600* A map is already set at the moment! Please try again later.",thePlayer,255,255,255,true) end else outputChatBox("#FF6600* A map is already set at the moment! Please try again later.",thePlayer,255,255,255,true) end function resetMapSetStatus() mapIsAlreadySet = false end addEventHandler("onMapStarting",getRootElement(),resetMapSetStatus) addEvent("onScriptSetNextMap",true) addEventHandler("onScriptSetNextMap",getRootElement(), function (mapName) thePlayer = source local playerCash = tonumber(loadPlayerData(thePlayer,"cash")) savePlayerData(thePlayer,"cash",playerCash-mapCost) outputChatBox("#FF6600Nextmap: #FFFFFF"..getPlayerName(thePlayer).."#FF6600 has bought a next map!",getRootElement(),255,255,255,true) outputChatBox("#FF6600Nextmap: "..mapName,getRootElement(),255,255,255,true) mapIsAlreadySet = true scoreboardRefresh(thePlayer) achievement31(thePlayer) end) addEvent("onRaceSetNextMap",true) addEventHandler("onRaceSetNextMap",getRootElement(), function () mapIsAlreadySet = true end)
Here is the client-side scipt:
-- "Maps" TAB gridMaps = guiCreateGridList(17,51,315,285,false,mapGui[1]) guiGridListSetSortingEnabled(gridMaps,false) guiGridListAddColumn(gridMaps,"Map name",0.9) lblMapsInfo = guiCreateLabel(342,210,245,45,"Each map costs $5000, regardless whether it's DM or DD.",false,mapGui[1]) guiLabelSetVerticalAlign(lblMapsInfo,"center") guiLabelSetHorizontalAlign(lblMapsInfo,"center",true) guiSetFont(lblMapsInfo,"default-bold-small") lblTotalMapsOnServer = guiCreateLabel(342,28,193,19,"Total maps on the server: N/A",false,mapGui[1]) guiSetFont(lblTotalMapsOnServer,"default-bold-small") lblTotalDmMaps = guiCreateLabel(342,47,193,19,"Total DM maps: N/A",false,mapGui[1]) guiSetFont(lblTotalDmMaps,"default-bold-small") lblTotalDdMaps = guiCreateLabel(342,62,193,19,"Total DD maps: N/A",false,mapGui[1]) guiSetFont(lblTotalDdMaps,"default-bold-small") lblSetNextMapTitle = guiCreateLabel(342,189,245,16,"Set as next map",false,mapGui[1]) guiLabelSetColor(lblSetNextMapTitle,255,120,0) guiLabelSetVerticalAlign(lblSetNextMapTitle,"center") guiLabelSetHorizontalAlign(lblSetNextMapTitle,"center",false) guiSetFont(lblSetNextMapTitle,"default-bold-small") lblSearchForMaps = guiCreateLabel(25,25,101,14,"Search for maps:",false,mapGui[1]) guiLabelSetColor(lblSearchForMaps,255,120,0) guiLabelSetVerticalAlign(lblSearchForMaps,"center") guiSetFont(lblSearchForMaps,"default-bold-small") lblSelectedMapNameTitle = guiCreateLabel(342,97,245,16,"Selected map name:",false,mapGui[1]) guiLabelSetColor(lblSelectedMapNameTitle,150,255,150) guiSetFont(lblSelectedMapNameTitle,"default-bold-small") lblSelectedMapAuthorTitle = guiCreateLabel(342,136,245,16,"Map type:",false,mapGui[1]) guiLabelSetColor(lblSelectedMapAuthorTitle,150,255,150) guiSetFont(lblSelectedMapAuthorTitle,"default-bold-small") lblSelectedMapName = guiCreateLabel(342,113,245,16,"N/A",false,mapGui[1]) lblSelectedMapAuthor = guiCreateLabel(342,152,245,16,"N/A",false,mapGui[1]) lblMapTabLine1 = guiCreateLabel(342,309,245,27,"---------------------------------------------------------------",false,mapGui[1]) guiLabelSetColor(lblMapTabLine1,255,120,0) guiLabelSetVerticalAlign(lblMapTabLine1,"center") guiLabelSetHorizontalAlign(lblMapTabLine1,"center",false) guiSetFont(lblMapTabLine1,"default-bold-small") lblMapTabLine2 = guiCreateLabel(342,173,245,16,"---------------------------------------------------------------",false,mapGui[1]) guiLabelSetColor(lblMapTabLine2,255,120,0) guiLabelSetVerticalAlign(lblMapTabLine2,"center") guiLabelSetHorizontalAlign(lblMapTabLine2,"center",false) guiSetFont(lblMapTabLine2,"default-bold-small") lblMapTabLine3 = guiCreateLabel(342,81,245,16,"---------------------------------------------------------------",false,tabs[1]) guiLabelSetColor(lblMapTabLine3,255,120,0) guiLabelSetVerticalAlign(lblMapTabLine3,"center") guiLabelSetHorizontalAlign(lblMapTabLine3,"center",false) guiSetFont(lblMapTabLine3,"default-bold-small") editMapSearch = guiCreateEdit(129,23,198,21,"",false,tabs[1]) btnBuyNextMap = guiCreateButton(380,265,169,44,"Buy as next map - $5000",false,tabs[1]) function onresourceStart () bindKey ("F1", "down", displayTab) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), onresourceStart) function displayTab(openTab) local visible = guiGetVisible(mapGui[1]) if visible == false then guiSetVisible(mapGui[1],true) else guiSetVisible(mapGui[1],false) end end function getMaps() totalServerMaps = 0 totalDmMaps = 0 totalDdMaps = 0 setTimer(callServerFunction,500,1,"getServerMaps",getLocalPlayer()) end addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),getMaps) function loadMaps(gamemodeMapTable, gamemode, map) guiGridListClear(gridMaps) if gamemodeMapTable then aGamemodeMapTable = gamemodeMapTable for id,gamemode in pairs (gamemodeMapTable) do if (gamemode.name == "Race") then for id,map in ipairs (gamemode.maps) do local row = guiGridListAddRow ( gridMaps ) guiGridListSetItemText ( gridMaps, row, 1, map.name, false, false ) guiGridListSetItemData ( gridMaps, row, 1, map.resname) updateMapLabels(1) end end end end end -- Map search function mapSearch() guiGridListClear(gridMaps) local searchString = string.lower(guiGetText(editMapSearch)) if ( searchString == "" ) then for id,gamemode in pairs (aGamemodeMapTable) do if (gamemode.name == "Race") then for id,map in ipairs (gamemode.maps) do local row = guiGridListAddRow ( gridMaps ) guiGridListSetItemText ( gridMaps, row, 1, map.name, false, false ) guiGridListSetItemData ( gridMaps, row, 1, map.resname) end end end else for id,gamemode in pairs (aGamemodeMapTable) do if (gamemode.name == "Race") then local noMapsFound = true for id,map in ipairs (gamemode.maps) do if string.find(string.lower(map.name.." "..map.resname), searchString, 1, true) then local row = guiGridListAddRow ( gridMaps ) guiGridListSetItemText ( gridMaps, row, 1, map.name, false, false ) guiGridListSetItemData ( gridMaps, row, 1, map.resname) noMapsFound = false end end if noMapsFound == true then local row = guiGridListAddRow(gridMaps) guiGridListSetItemText (gridMaps, row, 1, "No maps matching your search query!", false, false) guiGridListSetItemColor (gridMaps, row, 1, 255,50,50) end end end end updateMapLabels(2) end function buyNextMap() local row,column = guiGridListGetSelectedItem(gridMaps) local mapName = guiGridListGetItemText(gridMaps,row,1) callServerFunction("buyMap",getLocalPlayer(),mapName) end -- Update labels function updateMapLabels(updateMode) if updateMode == 1 then guiSetText(lblTotalMapsOnServer,"Total maps on the server: "..totalServerMaps) guiSetText(lblTotalDmMaps,"Total DM Maps: "..totalDmMaps) guiSetText(lblTotalDdMaps,"Total DD Maps: "..totalDdMaps) else local row,column = guiGridListGetSelectedItem(gridMaps) local mapName = guiGridListGetItemText(gridMaps,row,1) if mapName == "" then guiSetText(lblSelectedMapName,"N/A") guiSetText(lblSelectedMapAuthor,"N/A") else guiSetText(lblSelectedMapName,mapName) if string.find(mapName,"[DM]",1,true) then guiSetText(lblSelectedMapAuthor,"Deathmatch") elseif string.find(mapName,"[DD]",1,true) then guiSetText(lblSelectedMapAuthor,"Destruction Derby") elseif string.find(mapName,"[FUN]",1,true) then guiSetText(lblSelectedMapAuthor,"Fun map") else guiSetText(lblSelectedMapAuthor,"UNKNOWN") end end end end
Thanks in advance for helping me!
-
-
-
exports[ "scoreboard" ]:scoreboardAddColumn ( "Cash" ) exports[ "scoreboard" ]:scoreboardAddColumn ( "Points" ) function setStats ( player ) if ( not player or not isElement ( player ) ) then return end local account = getPlayerAccount ( player ) if ( account and not isGuestAccount ( account ) ) then local cash = getAccountData ( account, "cash" ) local points = getAccountData ( account, "points" ) setElementData ( player, "Cash", "$" .. cash or 0 ) setElementData ( player, "Points", points or 0 ) else setElementData ( player, "Cash", "guest" ) setElementData ( player, "Points", "guest" ) end end function timer() setTimer( setStats, 1000, 1, source ) end addEventHandler("onPlayerLogin", getRootElement(), timer) addEventHandler("onPlayerJoin", getRootElement(), timer) addEvent ( "onMapStarting", true ) addEventHandler ( "onMapStarting", root, function ( ) for index, player in ipairs ( getElementsByType ( "player" ) ) do setStats ( player ) end end )
Thanks! This works great.
-
Is there an event for when a new map loads? I need my cash in the scoreboard to update after a new map loads, how do I do this?
Here is my script:
exports["scoreboard"]:scoreboardAddColumn("Cash") exports["scoreboard"]:scoreboardAddColumn("Points") function setStats(player) local account = getPlayerAccount(player) if (account) then local cash = getAccountData(account, "cash") local points = getAccountData(account, "points") setElementData ( player, "Cash", "$" ..cash.. "" ) setElementData ( player, "Points", points ) else setElementData ( player, "Cash", "guest" ) setElementData ( player, "Points", "guest" ) end end function timer() setTimer( setStats, 1000, 1, source ) end addEventHandler("onPlayerLogin", getRootElement(), timer) addEventHandler("onPlayerJoin", getRootElement(), timer)
-
Hey,
How can I make the killmessages support name colours?
Thanks.
-
nametag = {} local nametags = {} local g_screenX,g_screenY = guiGetScreenSize() local bHideNametags = false local NAMETAG_SCALE = 0.3 --Overall adjustment of the nametag, use this to resize but constrain proportions local NAMETAG_ALPHA_DISTANCE = 50 --Distance to start fading out local NAMETAG_DISTANCE = 120 --Distance until we're gone local NAMETAG_ALPHA = 120 --The overall alpha level of the nametag --The following arent actual pixel measurements, they're just proportional constraints local NAMETAG_TEXT_BAR_SPACE = 2 local NAMETAG_WIDTH = 50 local NAMETAG_HEIGHT = 5 local NAMETAG_TEXTSIZE = 0.26 local NAMETAG_OUTLINE_THICKNESS = 1.2 -- local NAMETAG_ALPHA_DIFF = NAMETAG_DISTANCE - NAMETAG_ALPHA_DISTANCE NAMETAG_SCALE = 1/NAMETAG_SCALE * 800 / g_screenY -- -- If 1 then it shows your own nametag, else it will make invisible Testing = 0 -- Ensure the name tag doesn't get too big local maxScaleCurve = { {0, 0}, {3, 3}, {13, 5} } -- Ensure the text doesn't get too small/unreadable local textScaleCurve = { {0, 0.8}, {0.8, 1.2}, {99, 99} } -- Make the text a bit brighter and fade more gradually local textAlphaCurve = { {0, 0}, {25, 100}, {120, 190}, {255, 190} } function nametag.create ( player ) nametags[player] = true end function nametag.destroy ( player ) nametags[player] = nil end addEventHandler ( "onClientRender", g_Root, function() -- Hideous quick fix -- for i,player in ipairs(g_Players) do if player ~= g_Me or Testing == 1 then setPlayerNametagShowing ( player, false ) if not nametags[player] then nametag.create ( player ) end end end if bHideNametags then return end local x,y,z = getCameraMatrix() for player in pairs(nametags) do while true do if not isPedInVehicle(player) or isPlayerDead(player) then break end local vehicle = getPedOccupiedVehicle(player) local px,py,pz = getElementPosition ( vehicle ) local pdistance = getDistanceBetweenPoints3D ( x,y,z,px,py,pz ) if pdistance <= NAMETAG_DISTANCE then --Get screenposition local sx,sy = getScreenFromWorldPosition ( px, py, pz+0.95, 0.06 ) if not sx or not sy then break end --Calculate our components local scale = 1/(NAMETAG_SCALE * (pdistance / NAMETAG_DISTANCE)) local alpha = ((pdistance - NAMETAG_ALPHA_DISTANCE) / NAMETAG_ALPHA_DIFF) alpha = (alpha < 0) and NAMETAG_ALPHA or NAMETAG_ALPHA-(alpha*NAMETAG_ALPHA) scale = math.evalCurve(maxScaleCurve,scale) local textscale = math.evalCurve(textScaleCurve,scale) local textalpha = math.evalCurve(textAlphaCurve,alpha) local outlineThickness = NAMETAG_OUTLINE_THICKNESS*(scale) --Draw our text local r,g,b = 255,255,255 local team = getPlayerTeam(player) if team then r,g,b = getTeamColor(team) end local offset = (scale) * NAMETAG_TEXT_BAR_SPACE/2 -- There will be the font name font = "bankgothic" -- As you can see, i'm using bankgothic font dxDrawColorText ( string.gsub(getPlayerNametagText(player),'#%x%x%x%x%x%x',''), sx + 1, sy - offset + 1, sx + 1, sy - offset + 1, tocolor(0,0,0,textalpha), textscale*NAMETAG_TEXTSIZE, font, "center", "bottom", false, false, false ) dxDrawColorText ( getPlayerNametagText(player), sx, sy - offset, sx, sy - offset, tocolor(r,g,b,textalpha), textscale*NAMETAG_TEXTSIZE, font, "center", "bottom", false, false, false ) --We draw three parts to make the healthbar. First the outline/background local drawX = sx - NAMETAG_WIDTH*scale/2 drawY = sy + offset local width,height = NAMETAG_WIDTH*scale, NAMETAG_HEIGHT*scale dxDrawRectangle ( drawX, drawY, width, height, tocolor(0,0,0,alpha) ) --Next the inner background local health = getElementHealth(vehicle) health = math.max(health - 250, 0)/750 local p = -510*(health^2) local r,g = math.max(math.min(p + 255*health + 255, 255), 0), math.max(math.min(p + 765*health, 255), 0) dxDrawRectangle ( drawX + outlineThickness, drawY + outlineThickness, width - outlineThickness*2, height - outlineThickness*2, tocolor(r,g,0,0.4*alpha) ) --Finally, the actual health dxDrawRectangle ( drawX + outlineThickness, drawY + outlineThickness, health*(width - outlineThickness*2), height - outlineThickness*2, tocolor(r,g,0,alpha) ) end break end end end ) ---------------THE FOLLOWING IS THE MANAGEMENT OF NAMETAGS----------------- addEventHandler('onClientResourceStart', g_ResRoot, function() for i,player in ipairs(getElementsByType"player") do if player ~= g_Me or Testing == 1 then nametag.create ( player ) end end end ) addEventHandler ( "onClientPlayerJoin", g_Root, function() if source == g_Me then return end setPlayerNametagShowing ( source, false ) nametag.create ( source ) end ) addEventHandler ( "onClientPlayerQuit", g_Root, function() nametag.destroy ( source ) end ) addEvent ( "onClientScreenFadedOut", true ) addEventHandler ( "onClientScreenFadedOut", g_Root, function() bHideNametags = true end ) addEvent ( "onClientScreenFadedIn", true ) addEventHandler ( "onClientScreenFadedIn", g_Root, function() bHideNametags = false end ) function dxDrawColorText(str, ax, ay, bx, by, color, scale, font, alignX, alignY) if alignX then if alignX == "center" then local w = dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font) ax = ax + (bx-ax)/2 - w/2 elseif alignX == "right" then local w = dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font) ax = bx - w end end if alignY then if alignY == "center" then local h = dxGetFontHeight(scale, font) ay = ay + (by-ay)/2 - h/2 elseif alignY == "bottom" then local h = dxGetFontHeight(scale, font) ay = by - h end end local pat = "(.-)#(%x%x%x%x%x%x)" local s, e, cap, col = str:find(pat, 1) local last = 1 while s do if cap == "" and col then color = tocolor(tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)), 255) end if s ~= 1 or cap ~= "" then local w = dxGetTextWidth(cap, scale, font) dxDrawText(cap, ax, ay, ax + w, by, color, scale, font) ax = ax + w color = tocolor(tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)), 255) end last = e + 1 s, e, cap, col = str:find(pat, last) end if last <= #str then cap = str:sub(last) local w = dxGetTextWidth(cap, scale, font) dxDrawText(cap, ax, ay, ax + w, by, color, scale, font) end end
Worked, thanks.
-
-
-
-
This map sucks. It's better than many maps around here, but it still sucks.
If you want to know why just ask me.
Race-DM-fanboys arguing stupidly against me in 3... 2... 1..
Agreed, simple jump, wallride, loop abuse. And boring aswell. And it some points you will not know where to go.
-
I hope you realize scripters don't do stuff like this for free.
-
If you have no experience with linux, don't do it. It's hard if you do not understand how to communicate with the server. If you want a server you should go with a host.
-
There are too long straights in this map. It's enjoyable but not a challange, but it's fun to play an easy map time by time.
-
https://wiki.multitheftauto.com/images/8 ... Screen.jpg
exactly what you send I will add that
-
Hello,
I have seen that in some MTA vids the infernus is all shiny and reflecting, how to do this?
Thanks,
TheGuyNL
-
Awesome map! You've done a great job on the deco, it looks very nice and the track has some new stunts aswell. Overall just another cool map! Any way I could get it for my server?
-
As you said it's a high speed map, and that's all. It's not too bad but not the best I have seen. On some points it's unclear what to do as you will not know how the map goes the first few times, but overall it's a decent map.
-
Thanks
VPS
in Servers
Posted
Hey,
I got a VPS and a mta server running on it but when I close my ssh connection the server stops aswell. How do I prevent it from doing this?