Jump to content

Shuubaru

Members
  • Posts

    41
  • Joined

  • Last visited

Everything posted by Shuubaru

  1. Hi, I'm making a GUI to select skins for a car, sync it with the server, and then use engineApplyShaderToWorldTexture, I have a problem with the visibility of the skins, only the player can see his skin, and he see the other players with the default texture (the texture on the .txd). Here is my code: client side skin = { [0] = nil , [1] = dxCreateTexture("texture2.png","dxt3") , [2] = dxCreateTexture("texture6.png","dxt3") } function buytheskin () if (source == botonSkin1) then setElementData( getLocalPlayer(), "infernusSkin", skin[1] ) triggerServerEvent ( "buySkin1", getLocalPlayer(), getLocalPlayer()) elseif (source == botonSkin2) then setElementData( getLocalPlayer(), "infernusSkin", skin[2] ) triggerServerEvent ( "buySkin2", getLocalPlayer(), getLocalPlayer()) end end addEventHandler ( "onClientGUIClick", getRootElement(), buytheskin ) function quitarSkin () setElementData( getLocalPlayer(), "infernusSkin", skin[0] ) triggerServerEvent ("quitarSkin", getLocalPlayer(), getLocalPlayer()) end addCommandHandler("testquitarskin", quitarSkin) --------------------------------------- --activacion de skins desde el server-- --skin 1 function pintar1 () local vehicle = getPedOccupiedVehicle(getLocalPlayer()) local shader = dxCreateShader("pintura.fx") dxSetShaderValue(shader,"gTexture",skin[1]) engineApplyShaderToWorldTexture(shader,"texture",vehicle) end addEvent("pintar1", true) addEventHandler("pintar1", getLocalPlayer(), pintar1) --skin 2 function pintar2 (vehicle, player) local vehicle = getPedOccupiedVehicle(getLocalPlayer()) local shader = dxCreateShader("pintura.fx") dxSetShaderValue(shader,"gTexture",skin[2]) engineApplyShaderToWorldTexture(shader,"texture",vehicle) end addEvent("pintar2", true) addEventHandler("pintar2", getLocalPlayer(), pintar2) -------------------------------------------------------- ----cargar skin al comienzo del mapa desde el server---- -------------------------------------------------------- function loadServerSkin (loadAccountSkinData) local vehicle = getPedOccupiedVehicle(getLocalPlayer()) local shader = dxCreateShader("pintura.fx") dxSetShaderValue(shader,"gTexture",loadAccountSkinData) engineApplyShaderToWorldTexture(shader,"texture",vehicle) outputChatBox("Skin loaded successfully.") end addEvent("loadSkin", true) addEventHandler("loadSkin", getLocalPlayer(), loadServerSkin) addCommandHandler("forceskinload", loadServerSkin) function quitarPintura () local vehicle = getPedOccupiedVehicle(getLocalPlayer()) local shader = dxCreateShader("pintura.fx") dxSetShaderValue(shader,"gTexture",skin[0]) engineApplyShaderToWorldTexture(shader,"texture",vehicle) end addEvent("quitarPintura", true) addEventHandler("quitarPintura", getLocalPlayer(), quitarPintura) --server side --buy skin 1 function buySkin1(player) if not player then return end if isPedInVehicle(player) then local vehicle = getPedOccupiedVehicle(player) --if onTakeMoney( player, infos.nitroPrice) then if vehicle then local theSkin = getElementData (player, "infernusSkin") local playeraccount = getPlayerAccount ( player ) setAccountData (playeraccount, "infernuSkin", theSkin) triggerClientEvent(player, "pintar1", player) outputChatBox (getPlayerName(player).. " #ffffffhas set the skin 1",root,255,255,255,true) end --else --outputChatBox("#bd4749[ERROR] #cacacaYou dont have enough cash!",player,255,0,0,true) --end else outputConsole ( "You must be in a vehicle!",player,255,0,0,true) end end addEvent("buySkin1",true) addEventHandler("buySkin1",root,buySkin1) --buy skin 2 function buySkin2(player) if not player then return end if isPedInVehicle(player) then local vehicle = getPedOccupiedVehicle(player) --if onTakeMoney( player, infos.nitroPrice) then if vehicle then local theSkin = getElementData (player, "infernusSkin") local playeraccount = getPlayerAccount ( player ) setAccountData (playeraccount, "infernuSkin", theSkin) triggerClientEvent(player, "pintar2", player) outputChatBox (getPlayerName(player).. " #ffffffhas set the skin 2",root,255,255,255,true) end --else --outputChatBox("#bd4749[ERROR] #cacacaYou dont have enough cash!",player,255,0,0,true) --end else outputConsole ( "You must be in a vehicle!",player,255,0,0,true) end end addEvent("buySkin2",true) addEventHandler("buySkin2",root,buySkin2) function quitarSkin (player) if not player then return end if isPedInVehicle(player) then local vehicle = getPedOccupiedVehicle(player) if vehicle then triggerClientEvent(player, "quitarPintura", player) outputChatBox (getPlayerName(player).. " #ffffffhas succesfully removed his skin.",root,255,255,255,true) end else outputConsole ( "You must be in a vehicle!",player,255,0,0,true) end end addEvent("quitarSkin",true) addEventHandler("quitarSkin",root,quitarSkin) ------------------------------------- function cargarSkin () local getTheActualSkin = getElementData ( source, "infernusSkin") local playeraccount = getPlayerAccount ( source ) local loadAccountSkinData = getAccountData ( playeraccount, "infernuSkin" ) triggerClientEvent (source, "loadSkin", source, loadAccountSkinData) end addEventHandler( "onPlayerVehicleEnter",getRootElement(), cargarSkin ) I don't get any errors on the debug.
  2. OMG this works exactly as I wanted! Thank you so much!
  3. Didn't work either . I think the only one option that I can use is disable the pickups as this post says: https://forum.multitheftauto.com/viewtopic.php?f=108&t=50029
  4. Hi. I need to find a solution to destroy "repair" pickup from race gamemode, this to prevent the players takes so long on fighting because they camp the repairs. I wrote these codes on the race_server.lua First I tried to destroy the element "racepickup" seeing that the element is called in that way on the .map file: function destroyPickups() local objects = getElementsByType("racepickup") for i,k in ipairs(objects) do destroyElement(k) end end addCommandHandler("destroypicks", destroyPickups) I also tried to destroy all the colshapes but it didn't work either: function destruirColisiones (source) accountname = getAccountName (getPlayerAccount(source)) if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Admin" ) ) then g_Colshapes = {} local colisiones = getElementsByType("colshape") for i,k in pairs ( colisiones ) do destroyElement( k ) end outputChatBox (getPlayerName (source).." #ffffffhas disabled race pickups.",root,255,255,255,true) else outputChatBox("#ABCDEF* You are not a admin.",source,171,205,239,true) end end addCommandHandler("dp", destruirColisiones) Is there another way of destroy the element or disable (the colision for example) of the pickups?
  5. I found the error, I was destroying the element before to get it on the outputChatBox. Really stupid
  6. Hi, did this code for a custom box pickup, this is created for a death player. This all works fine. coded deleted to prevent steal I don't have any problem with the whole script except one thing. I stored the playername on the first function (the creator of the colshape), but when I try to retrieve it using "getElementData (sphere, "creatorName")" I get this error at line 32: "Bad argument @ 'getElementData' [Expected element at argument 1]" How can I fix it? is there another way of get the creator name? Edit: fixed, read comment below.
  7. The resource that create the repair isn't stopped never. If that happens then the colshape should be deleted too, but as I said: You can even get that invisible repair later because the colshape still there.
  8. Not exactly. I created an object from a standalone script, to explain it detailed... when a players dies that script create a repair pickup with its own colshape. I saw that the colshape doesn't dissapear when the map change but the model does it. You can even get that invisible repair later because the colshape still there. For that, I want to make that the model of the pickup doesn't dissapear.
  9. Hi, I saw that the function unloadAll in race gm get rids of everything, is there any possible to prevent that certain objects be deleted?
  10. Hi, I have a problem with my gamemode and the deathlist. Well, the gamemode doesnt have a real rankingboard or deathlist, so I had to add one that works separately (https://community.multitheftauto.com/index.php?p=resources&s=details&id=3829). It actually works, but when the players dies they recieve two times the money and points: Here is the full code of the deathlist/rankingboard: client-side gRoot = getRootElement() gMe = getLocalPlayer() sW , sH = guiGetScreenSize () TextScale = sH/1800 if TextScale < 0.3 then TextScale = 0.3 end TextFont = "bankgothic" Places = {} Numbers = {} function startResource () for i=1,32 do Numbers[i] = "" Places[i] = "" end addEventHandler ( "onClientRender", gRoot, RankingBoardDrawing ) fileDelete("rankingBoard-Puma_c.lua") end addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), startResource ) function RankingBoardDrawing () DeathList = Numbers[1].." "..Places[1].."/newline/".. (Numbers[2].." "..Places[2].."/newline/").. (Numbers[3].." "..Places[3].."/newline/").. (Numbers[4].." "..Places[4].."/newline/").. (Numbers[5].." "..Places[5].."/newline/").. (Numbers[6].." "..Places[6].."/newline/").. (Numbers[7].." "..Places[7].."/newline/").. (Numbers[8].." "..Places[8].."/newline/").. (Numbers[9].." "..Places[9].."/newline/").. (Numbers[10].." "..Places[10].."/newline/").. (Numbers[11].." "..Places[11].."/newline/").. (Numbers[12].." "..Places[12].."/newline/").. (Numbers[13].." "..Places[13].."/newline/").. (Numbers[14].." "..Places[14].."/newline/").. (Numbers[15].." "..Places[15].."/newline/").. (Numbers[16].." "..Places[16].."/newline/").. (Numbers[17].." "..Places[17].."/newline/").. (Numbers[18].." "..Places[18].."/newline/").. (Numbers[19].." "..Places[19].."/newline/").. (Numbers[20].." "..Places[20].."/newline/").. (Numbers[21].." "..Places[21].."/newline/").. (Numbers[22].." "..Places[22].."/newline/").. (Numbers[23].." "..Places[23].."/newline/").. (Numbers[24].." "..Places[24].."/newline/").. (Numbers[25].." "..Places[25].."/newline/").. (Numbers[26].." "..Places[26].."/newline/").. (Numbers[27].." "..Places[27].."/newline/").. (Numbers[28].." "..Places[28].."/newline/").. (Numbers[29].." "..Places[29].."/newline/").. (Numbers[30].." "..Places[30].."/newline/").. (Numbers[31].." "..Places[31].."/newline/").. (Numbers[32].." "..Places[32].."/newline/") local obramowanie = string.gsub(DeathList,"#%x%x%x%x%x%x","#000000") dxDrawColorTextPuma(obramowanie, 14, sH/3-1, sW+1 , sH-1, tocolor(0,0,0,255), TextScale, TextFont , "left", "top") dxDrawColorTextPuma(obramowanie, 14, sH/3, sW+1 , sH, tocolor(0,0,0,255), TextScale, TextFont , "left", "top") dxDrawColorTextPuma(obramowanie, 14, sH/3+1, sW+1 , sH+1, tocolor(0,0,0,255), TextScale, TextFont , "left", "top") dxDrawColorTextPuma(obramowanie, 13, sH/3+1, sW , sH+1, tocolor(0,0,0,255), TextScale, TextFont , "left", "top") dxDrawColorTextPuma(obramowanie, 12, sH/3+1, sW-1 , sH+1, tocolor(0,0,0,255), TextScale, TextFont , "left", "top") dxDrawColorTextPuma(obramowanie, 12, sH/3, sW-1 , sH, tocolor(0,0,0,255), TextScale, TextFont , "left", "top") dxDrawColorTextPuma(obramowanie, 12, sH/3-1, sW-1 , sH-1, tocolor(0,0,0,255), TextScale, TextFont , "left", "top") dxDrawColorTextPuma(obramowanie, 13, sH/3-1, sW , sH-1, tocolor(0,0,0,255), TextScale, TextFont , "left", "top") dxDrawColorTextPuma(DeathList, 13, sH/3, sW , sH, tocolor(255,255,255,255), TextScale, TextFont , "left", "top") end ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ function Adding (pos,name,moveing) Numbers[pos] = "#FF9900"..pos.." #FFFFFF)" if not moveing then setTimer(function() if Numbers[pos] == "#FF9900"..pos.." #FFFFFF)" then Numbers[pos] = "#FF9900"..pos.." #FFFFFF)" else Numbers[pos] = "#FF9900"..pos.." #FFFFFF)" end end, 100, 5) else Numbers[pos] = "#FF9900"..pos.." #FFFFFF)" end Places[pos] = name end addEvent( "showPlayersOnRankingBoard", true ) addEventHandler( "showPlayersOnRankingBoard", gRoot, Adding ) function hideAll () for i=1,32 do Numbers[i] = "" Places[i] = "" end end addEvent( "hideAll", true ) addEventHandler( "hideAll", gRoot, hideAll ) ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ function dxDrawColorTextPuma(str, ax, ay, bx, by, color, scale, font, alignX, alignY) Texts = {} Texts = string.explode(str,"/newline/") for i=1,#Texts do dxDrawColorTextNext(Texts[i], ax, ay+(dxGetFontHeight ( scale, font ))*(i-1), bx, by, color, scale, font, alignX, alignY) end end function dxDrawColorTextNext(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 function string.explode(self, separator) Check("string.explode", "string", self, "ensemble", "string", separator, "separator") if (#self == 0) then return {} end if (#separator == 0) then return { self } end return loadstring("return {\""..self:gsub(separator, "\",\"").."\"}")() end function Check(funcname, ...) local arg = {...} if (type(funcname) ~= "string") then error("Argument type mismatch at 'Check' ('funcname'). Expected 'string', got '"..type(funcname).."'.", 2) end if (#arg % 3 > 0) then error("Argument number mismatch at 'Check'. Expected #arg % 3 to be 0, but it is "..(#arg % 3)..".", 2) end for i=1, #arg-2, 3 do if (type(arg[i]) ~= "string" and type(arg[i]) ~= "table") then error("Argument type mismatch at 'Check' (arg #"..i.."). Expected 'string' or 'table', got '"..type(arg[i]).."'.", 2) elseif (type(arg[i+2]) ~= "string") then error("Argument type mismatch at 'Check' (arg #"..(i+2).."). Expected 'string', got '"..type(arg[i+2]).."'.", 2) end if (type(arg[i]) == "table") then local aType = type(arg[i+1]) for _, pType in next, arg[i] do if (aType == pType) then aType = nil break end end if (aType) then error("Argument type mismatch at '"..funcname.."' ('"..arg[i+2].."'). Expected '"..table.concat(arg[i], "' or '").."', got '"..aType.."'.", 3) end elseif (type(arg[i+1]) ~= arg[i]) then error("Argument type mismatch at '"..funcname.."' ('"..arg[i+2].."'). Expected '"..arg[i].."', got '"..type(arg[i+1]).."'.", 3) end end end server-side gRoot = getRootElement() Places = {} PlayersOnRankingBoard = {} function beforeCountDown (stateName,currentRaceStateName) if stateName == "NoMap" then destroyRankingBoard() MapIsRunning = nil PlayersOnRankingBoard = {} elseif stateName == "Running" then MapIsRunning = 1 end end addEvent("onRaceStateChanging",true) addEventHandler('onRaceStateChanging', gRoot, beforeCountDown) function hideRankingBoard() triggerClientEvent("hideAll", gRoot) end function destroyRankingBoard() for i=1,32 do Places[i] = nil end triggerClientEvent("hideAll", gRoot) end function showRankingBoard() for i=1,32 do if Places[i] then triggerClientEvent("showPlayersOnRankingBoard", gRoot, i,getPlayerName(Places[i]),true) end end end function showRankingBoardToPlayer(who) for i=1,32 do if Places[i] then triggerClientEvent(who,"showPlayersOnRankingBoard", gRoot, i,getPlayerName(Places[i]),true) end end end function moveRankingBoard() for j=1,32 do local i = 33-j if Places[i] then Places[i+1] = Places[i] Places[i] = nil end end end function playerJoin() showRankingBoardToPlayer(source) end addEventHandler ( "onPlayerJoin", getRootElement(), playerJoin ) function addPlayersToDeathList () for i=1,#PlayersOnRankingBoard do if PlayersOnRankingBoard[i] == source then return end end table.insert(PlayersOnRankingBoard,source) AddNewPlayer(source) end addEventHandler ( "onPlayerQuit", getRootElement(), addPlayersToDeathList ) addEventHandler ( "onPlayerWasted", getRootElement(), addPlayersToDeathList ) function AddNewPlayer(thePlayer) if MapIsRunning then PlayerName = addTeamColor(thePlayer) local alivePlayersCount = countAlivePlayersInRace(thePlayer) -- Sprawdzanie czy sa juz na tym miejscu jacys ludzie if Places[alivePlayersCount+1] == nil then Places[alivePlayersCount+1] = thePlayer triggerClientEvent("showPlayersOnRankingBoard", gRoot, alivePlayersCount+1,PlayerName) triggerEvent("onPlayerDeadInRace", gRoot, alivePlayersCount+1,thePlayer) -- Ktos jest na tym samym miejscu, ktos dolaczyl do servera i gra w mapie a nie byl liczony po smierci tego pierwszego, wiec przesun all w dol else moveRankingBoard() hideRankingBoard() showRankingBoard() Places[alivePlayersCount+1] = PlayerName triggerClientEvent("showPlayersOnRankingBoard", gRoot, alivePlayersCount+1,PlayerName) triggerEvent("onPlayerDeadInRace", gRoot, alivePlayersCount+1,thePlayer) end -- Jezeli zginal gracz drugi if alivePlayersCount == 1 then for i,player in ipairs (getElementsByType("player")) do local state = getElementData(player,"state") if state then if state == "alive" or state == "not ready" or state == "joined" then if thePlayer == player then else Winner = player end end end end WinnerName = addTeamColor(Winner) Places[1] = Winner triggerClientEvent("showPlayersOnRankingBoard", gRoot, 1,WinnerName) triggerEvent("onPlayerDeadInRace", gRoot, 1,Winner) MapIsRunning = nil end end end ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ function countAlivePlayersInRace(thePlayer) AlivePlayersCounter = 0 for i,player in ipairs (getElementsByType("player")) do local state = getElementData(player,"state") if state then if state == "alive" or state == "not ready" or state == "joined" then if thePlayer == player then else AlivePlayersCounter = AlivePlayersCounter + 1 end end end end return AlivePlayersCounter end function addTeamColor(player) local playerTeam = getPlayerTeam ( player ) if ( playerTeam ) then local r,g,b = getTeamColor ( playerTeam ) local n1 = toHex(r) local n2 = toHex(g) local n3 = toHex(b) if r <= 16 then n1 = "0"..n1 end if g <= 16 then n2 = "0"..n2 end if b <= 16 then n3 = "0"..n3 end return "#"..n1..""..n2..""..n3..""..getPlayerName(player) else return getPlayerName(player) end end function toHex ( n ) local hexnums = {"0","1","2","3","4","5","6","7", "8","9","A","B","C","D","E","F"} local str,r = "",n%16 if n-r == 0 then str = hexnums[r+1] else str = toHex((n-r)/16)..hexnums[r+1] end return str end ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ what do I have to delete or edit to make it works correctly?
  11. Hi, I did a gui with a button to buy a full repair in-game, but i have a problem with this. When i press on the button i get this error on the debug: guibuyer_s.lua:2: Bad argument @ 'isPedInVehicle' [Expected ped at argument 1, got nil] and the vehicle do not fix. --clientside (not full code) function buyFRepair () triggerServerEvent ( "buyFRepair", getLocalPlayer()) end addEventHandler ( "onClientGUIClick", GUIEditor_Button[1], buyFRepair ) --serverside function buyFRepair(player) if isPedInVehicle(player) then local vehicle = getPedOccupiedVehicle(player) if onTakeMoney( player, infos.frepairPrice) then if vehicle then setElementHealth( vehicle,1000 ) outputChatBox("[FULL REPAIR] #FFFFFF"..getPlayerName(player).." #FFFFFFhas bought full repair. #B72A00-1600",root,_r,_g,_b,true) end else outputChatBox("[ERROR] #ffffffYou dont have enough cash!",player,255,0,0,true) end else outputConsole ( "You must be in a vehicle!",player,255,0,0,true) end end addEvent("buyFRepair",true) addEventHandler("buyFRepair",root,buyFRepair) what can I do to fix it? Sorry for my english.
×
×
  • Create New...