Jump to content

Citizen

Moderators
  • Posts

    1,803
  • Joined

  • Last visited

  • Days Won

    8

Everything posted by Citizen

  1. Show me how your code looks like now ? What is the error now ?
  2. Did you even read what I just said ? I just said how to fix it ...
  3. Yeah you are right, when I'm using that code, assume there is 95% of chance that the vehicle will be on ground (and not doing barrel rolls or on a heavy mountain road )
  4. Well I understood your point of view, but as u can see, that wasn't a really basic question, and I try to set comments as much as I can so that they will be able to understand that code. But I know some guys who would just copy paste your code and coming back saying it's not working (I know it's stupid, but they do exist, specially if they are new to coding and seeing the lines of code as black magic ).
  5. @Solidsnake: You made a typo, swap the ] and the ) for math.random
  6. Just use that function: https://wiki.multitheftauto.com/wiki/Get ... ceRotation (You have to copy and paste the function into your code to be able to use it) You will call that function with the position x and y of the car, use 0 as angle (streight forward) and as distance well ... all depends of the vehicule, it won't be the same for the limousine and for the golf caddy as you can imagine. Hope it helps.
  7. Bonsai, please don't post such script and call it as "solution" to help members that are still learning. Seriously dude, did you even read your code back before clicking the "Submit" button ? At least it made me laugh Ok, try this, I made this code that will let you change settings to easilly modify the animation using interpolateBetween (first time I used this function ): local screenWidth, screenHeight = guiGetScreenSize() local startPos = {0.4, 1} --the relative position from where the image will start local endPos = {0.4, 0.875} --the relative position from where the image will stop local animType = "OutQuad" --the animation type, see [url=https://wiki.multitheftauto.com/wiki/Easing]https://wiki.multitheftauto.com/wiki/Easing[/url] local speed = 2 --the speed of the entire animation local hideTime = 3 --time in sec after the dead image will hidden (starting from the end of the anim) local animStep = 0 --do not modify, used to hold the progression of the animation local stopingTimer = nil --the distance between the line and the top of the image local lOffsetY = 0.07*screenHeight function showDeadImage() animStep = 0 --start at the step 0 addEventHandler("onClientRender", root, animateDeadImage) end addCommandHandler("dead", showDeadImage) --you can obviously delete this line function animateDeadImage() local x, y, _ = interpolateBetween( startPos[1]*screenWidth, startPos[2]*screenHeight, 0, endPos[1]*screenWidth, endPos[2]*screenHeight, 0, animStep/100, animType) dxDrawImage(x, y, 300, 50, 'images/dead_player.png', 0, 0, -120) dxDrawLine(0, y+lOffsetY, screenWidth, y+lOffsetY, tocolor( 0, 255, 153, 255 ), 2 ) animStep = animStep + speed --steping the animation if animStep >= 100 and not stopingTimer then stopingTimer = setTimer(hideDeadImage, hideTime*1000, 1) --start the timer to make hide it end end function hideDeadImage() removeEventHandler("onClientRender", root, animateDeadImage) stopingTimer = nil --reset it for our condition end I hope the comments will be enough to understand the code but ofc, ask if you don't really get something. PS: I tested the code without the image (so only with the line) and it was working fine, so let me know how it's going with the image. Regards, Citizen
  8. According to this doc, it should be possible to store float numbers in columns of type REAL. Never heard of it untill now though. If it doesn't work, then use the solidsnake's solution .
  9. I don't know if it's a bug, but it would be better if the getElementPosition could return the correct coordinate on attached element relative to the gta world. If I remember right, it returns the coordinates of the parent that they are attached to. (I was doing the same with a marker I wanted to place behind the car. The event onMarkerHit was only triggered when I was walking on the middle of the car ...) As a simple test, you could check if the postition of dummy3 is the same as veh one.
  10. Citizen

    Colored Road

    and engineLoadTXD before engineImportTXD
  11. onClientRender not To Static Image :3 but to check if got Promote and etc Of course, why checking this every 1 sec with a regular setTimer or a custom event when you can use onClientRender to check it every 33ms (at 30FPS) No seriously, it's not that important to be updated every 33secs or under. And I don't want to act as the bad guy, but some members doesn't get the difference between helping with scripts and asking for scripts. I'm pretty sure most of you will get what I mean. Best regards, Citizen
  12. You should test your webstreams with VLC to check if it can get the song name from the stream. You used: onClientSoundFinishedDownload which is only working with real files, not for streams because they never stop downloading. Use this event instead: onClientSoundStream The idea I got is that you need to wait that event before getting the metadatas of the stream. So basically, you can remove the following lines from your onClientGUIClick: - line 10 - line 18 - line 26 - line 34 - line 41 and use the onClientSoundStream event. You will likely use a setTimer too to update the new meta tags when a new song is playing. It's just an idea, it maybe doesn't work as I guessed it would. The only way to know it is to test it. Regards, Citizen
  13. You mean the vertical scroll ? if so then it works, but I just forgot to use the number of fake players (I used getElementsByType("player") so yeah). playersO = #getElementsByType ( "player" ) Why dafuq did you do that ?? I removed it wasn't suppose to come back. If you do that, then players0 will be the same all the time, even if someone joins or quit the server so please put it back (don't brake the fixes ...) local gRoot = getRootElement() local sWidth,sHeight = guiGetScreenSize() local Width,Height = 549,412 local X = (sWidth/2) - (Width/2) local Y = (sHeight/2) - (Height/2) local playerheight = 20 --Better to be here as it's a constant local nbLinesToDraw = 20 -- the number of lines that will be drawn at the same time local offset = 0 function offsetplus() -- if offset >= (#getElementsByType ( "player" ))-nbLinesToDraw then return end --Bottom Position if offset >= (#fakelist)-nbLinesToDraw then return end -- uncomment only for testing offset = offset + 1 end function offsetneg() if offset <= 0 then return end --Top Position offset = offset - 1 end local currentMoney = 0 addEventHandler ( "onClientRender", root, function ( ) local money = getPlayerMoney ( ) if ( currentMoney ~= money ) then outputChatBox ( money ) setElementData ( localPlayer, "playerMoney", money ) currentMoney = money end end) ----- Generating a list of names ------ local fakelist = {} for k=1, 40 do table.insert(fakelist, "Player"..k) end --------------------------------------- function Scoreboard() dxDrawImage(X,Y,Width,Height, "Scoreboard/images/back.png") dxDrawText("Name", X+60, Y+10, Width,Height, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) dxDrawText(playersO.."/50" ,X+525, Y-15, Width,Height, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("Ping", X+480, Y+10, Width, Height, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) dxDrawText("Geld", X+210, Y+10, Width, Height, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) dxDrawText("Fraktion", X+350, Y+10, Width, Height, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) -- local players = getElementsByType ( "player" ) local players = fakelist -- uncomment only for testing local line = 0 --the current line number - 1 for k, player in pairs(players) do -- we will draw if we are at the right offset AND if we still didn't draw [nbLinesToDraw] lines (here 20) if k > offset and line <= nbLinesToDraw then -- local ping = getPlayerPing(player) local ping = 65 -- uncomment only for testing -- local teamp = getPlayerTeam(player) local teamp = nil -- uncomment only for testing local teamn = "Keine" if teamp then teamn = getTeamName(teamp) end -- local money = tonumber ( getElementData(player, "playerMoney") ) or 0 local money = 1200 -- uncomment only for testing if (ping >= 250) then r,g,b = 255,0,0 elseif (ping >= 120) then r,g,b = 255,69,0 else r,g,b = 0,255,0 end local tmpY = Y+60+playerheight*line -- dxDrawText(getPlayerName( player ), X+60, tmpY, Width,Height, tocolor(255,255,255), 1 , "default-bold","left", "top",false, false,true,true) dxDrawText(player, X+60, tmpY, Width,Height, tocolor(255,255,255), 1 , "default-bold","left", "top",false, false,true,true) dxDrawText(ping, X+480, tmpY, Width, Height, tocolor(r,g,b), 1, "default","left", "top",false,false,true,true) dxDrawText(tostring( money ).." $", X+210, tmpY, Width, Height, tocolor(255,255,255), 1, "default","left", "top",false, false, true, true) dxDrawText(teamn, X+350, tmpY, Width, Height, tocolor(255,255,255), 1, "default","left", "top",false, false, true, true) line = line + 1 end end end function Zeit() local hours = getRealTime().hour local minutes = getRealTime().minute local seconds = getRealTime().second dxDrawText(hours..":"..minutes..":"..seconds, X-325, Y+525, Width, Height, tocolor(255,255,255), 1, "default-bold","left", "top",false, false,true,true) end addEventHandler("onClientRender", gRoot, Zeit) function open() opened = not opened if opened == true then bindKey("mouse_wheel_down", "down", offsetplus) bindKey("mouse_wheel_up", "down", offsetneg) addEventHandler("onClientRender", gRoot, Scoreboard) showChat(false) showPlayerHudComponent("all", false) removeEventHandler("onClientRender", gRoot, Zeit) else offset = 0 unbindKey("mouse_wheel_down", "down", offsetplus) unbindKey("mouse_wheel_up", "down", offsetneg) removeEventHandler("onClientRender", gRoot, Scoreboard) showPlayerHudComponent("all", true) showChat(true) addEventHandler("onClientRender", gRoot, Zeit) end end bindKey("tab","both",open) Send back a screenshot to see what we need to fix or the final result if everything is done. (There is a big empty area at the top, under the header, fix it my seting 60 lower (for example 40)) Regards, Citizen
  14. Yeah I saw some interesting things but it didn't have the code I was expected. How did you create this interior ? I want everything you did yourself to create that interior please.
  15. Wasn't that hard, hope you could do it yourself: local gRoot = getRootElement() local sWidth,sHeight = guiGetScreenSize() local Width,Height = 549,412 local X = (sWidth/2) - (Width/2) local Y = (sHeight/2) - (Height/2) local playerheight = 20 --Better to be here as it's a constant local nbLinesToDraw = 20 -- the number of lines that will be drawn at the same time local offset = 0 function offsetplus() if offset >= (#getElementsByType ( "player" ))-nbLinesToDraw then return end --Bottom Position offset = offset + 1 end function offsetneg() if offset <= 0 then return end --Top Position offset = offset - 1 end local currentMoney = 0 addEventHandler ( "onClientRender", root, function ( ) local money = getPlayerMoney ( ) if ( currentMoney ~= money ) then outputChatBox ( money ) setElementData ( localPlayer, "playerMoney", money ) currentMoney = money end end) ----- Generating a list of names ------ local fakelist = {} for k=1, 40 do table.insert(fakelist, "Player"..k) end --------------------------------------- function Scoreboard() dxDrawImage(X,Y,Width,Height, "Scoreboard/images/back.png") dxDrawText("Name", X+60, Y+10, Width,Height, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) dxDrawText(playersO.."/50" ,X+525, Y-15, Width,Height, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("Ping", X+480, Y+10, Width, Height, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) dxDrawText("Geld", X+210, Y+10, Width, Height, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) dxDrawText("Fraktion", X+350, Y+10, Width, Height, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) -- local players = getElementsByType ( "player" ) local players = fakelist -- uncomment only for testing local line = 0 --the current line number - 1 for k, player in pairs(players) do -- we will draw if we are at the right offset AND if we still didn't draw [nbLinesToDraw] lines (here 20) if k > offset and line <= nbLinesToDraw then -- local ping = getPlayerPing(player) local ping = 65 -- uncomment only for testing -- local teamp = getPlayerTeam(player) local teamp = nil -- uncomment only for testing local teamn = "Keine" if teamp then teamn = getTeamName(teamp) end -- local money = tonumber ( getElementData(player, "playerMoney") ) or 0 local money = 1200 -- uncomment only for testing if (ping >= 250) then r,g,b = 255,0,0 elseif (ping >= 120) then r,g,b = 255,69,0 else r,g,b = 0,255,0 end local tmpY = Y+60+playerheight*line -- dxDrawText(getPlayerName( player ), X+60, tmpY, Width,Height, tocolor(255,255,255), 1 , "default-bold","left", "top",false, false,true,true) dxDrawText(player, X+60, tmpY, Width,Height, tocolor(255,255,255), 1 , "default-bold","left", "top",false, false,true,true) dxDrawText(ping, X+480, tmpY, Width, Height, tocolor(r,g,b), 1, "default","left", "top",false,false,true,true) dxDrawText(tostring( money ).." $", X+210, tmpY, Width, Height, tocolor(255,255,255), 1, "default","left", "top",false, false, true, true) dxDrawText(teamn, X+350, tmpY, Width, Height, tocolor(255,255,255), 1, "default","left", "top",false, false, true, true) line = line + 1 end end end function Zeit() local hours = getRealTime().hour local minutes = getRealTime().minute local seconds = getRealTime().second dxDrawText(hours..":"..minutes..":"..seconds, X-325, Y+525, Width, Height, tocolor(255,255,255), 1, "default-bold","left", "top",false, false,true,true) end addEventHandler("onClientRender", gRoot, Zeit) function open() opened = not opened if opened == true then bindKey("mouse_wheel_down", "down", offsetplus) bindKey("mouse_wheel_up", "down", offsetneg) addEventHandler("onClientRender", gRoot, Scoreboard) showChat(false) showPlayerHudComponent("all", false) removeEventHandler("onClientRender", gRoot, Zeit) else offset = 0 unbindKey("mouse_wheel_down", "down", offsetplus) unbindKey("mouse_wheel_up", "down", offsetneg) removeEventHandler("onClientRender", gRoot, Scoreboard) showPlayerHudComponent("all", true) showChat(true) addEventHandler("onClientRender", gRoot, Zeit) end end bindKey("tab","both",open) EDIT: Fixed the render of the name
  16. Citizen

    Help panel

    If you want fast help, give us all informations we need. Here I would like the client errors if there are any. You can see them by hitting /debugscript 3 if you are logged in as admin.
  17. Ok, we are going slowly, you finally gave me the screenshot, but that one line you pasted here is not enough for me to spot the problem even if I was right about this: So you basically need to use: setElementInterior to the player with the right id. Please show me the code that is doing the teleportation and the maping (with the markers etc). For the code, you will find something like this: function someFunction( hitelement ) --some code here that I need to see end addEventHandler("onMarkerHit", root, someFunction)
  18. Citizen

    scoreboard

    why there are two times the same function ? (showcountry) The first one looks better, but I don't know if you can set images (maybe it is supporte, I hope)
  19. Ok so first, it didn't take you only 10 minutes, then your code is just the begining, because you need to modify the gamemodes that you want to make them work in only one world. Additionnaly, I would use only one event for the world selection.
  20. Citizen

    DX GUI

    So you would use a table instead of creating elements ? But then you are going far from the cegui system, on which u can use events (giving dx elements as source etc)
  21. First, it must be a server side script (you were talking about client side so I'm not sure). Then, my code was supposed to write: Starting map: in the chatbox, didn't it ? For the vote, it's maybe because you should reset it properly. Try to replace this: for v,i in ipairs(getElementsByType("player")) do VotedTable[v] = nil end by this: VotedTable = {} Not sure if it was the problem though. _________________________ (oh you wrote another post) When you are "inserting" rows into a table using specific key (here the player element) the # will always return 0 (except if you use table.insert or using numbers as key) The only way to get the real length is by doing a function like this: function tablelength(t) local count = 0 for _ in pairs(t) do count = count + 1 end return count end so: voteCount = #VotedTable will become: voteCount = tablelength(VotedTable) Hope it will fix ur script.
  22. Citizen

    DX GUI

    Exactly and I would add that you can create your own elements with createElement function on which you can then set some element datas like x, y, width, height. Then you can iterate over all your dx elements and render it according to its type (from the createElement function). You will obviously get the x, y, width, height for each dx elements to be able to render them. Then you can also create your own events like "onClientDXClick", for example, by using generic events like onClientClick then you iterate over all your dx elements, getting their position and sizes and check if the click was over a dx element. If it was, you can then use the triggerEvent function to trigger "onClientDXClick" with that element as source of this event and some extra parameters if you want. Once you did that, you will be able to do some addEventHandler for onClientDXClick and it will work as well as onClientGUIClick It's gonna be really hardcore when you will want to support parenting and to recreate some hard elements like the gridlists (no problem for vertical scrolling, but the horizontal one is real pain ). Myeah, I'm calling that hacks cuz that's cheating. That's my opinion though.
  23. Cheez3D please don't, specially if you don't know the functions you are talking about: getScreenFromWorldPosition() --nope, not needed getWorldFromScreenPosition() --nope, not needed either
  24. Did you get any error ? Try this: VotedTable = {} function OnMapStart(mapInfo, mapOptions, gameOptions) outputChatBox("Starting map: "..tostring(mapInfo.name)) RedoVotemapName = mapInfo.name or "Unknown" author = mapInfo.author or "Unknown" voteCount = 0 for v,i in ipairs(getElementsByType("player")) do VotedTable[v] = nil end NeededCountPre = getPlayerCount() / 100 NeededCount = NeededCountPre * 60 if ClearNext then Restarted = nil ClearNext = nil end if not Restarted then outputChatBox("#00aaff[Vote#00cc55Redo]: #00aaffNow enabled!", getRootElement(), 255,255,255,true) else ClearNext = true outputChatBox("#00aaff[Vote#00cc55Redo]: #00aaffRedo Already done, #00cc55disabling votes!", getRootElement(), 255,255,255,true) end end addEventHandler("onMapStarting", getRootElement(), OnMapStart()) function VoteRedo(player,cmd) if not VotedTable[player] then VotedTable[player] = player voteCount = #VotedTable outputChatBox("#00aaff[Vote#00cc55Redo]: #00aaff".. getPlayerNametagText(player).." Voted for Redo!, #00cc55Vote Count: #66ffaa[ ".. voteCount.." / "..NeededCount.." ]", getRootElement(), 255,255,255,true) if voteCount >= NeededCount then RedoVoteMap(RedoVotemapName) end else outputChatBox("#00aaff[Vote#00cc55Redo]: #00aaffYou Already #66ffaaVoted!", player, 255,255,255,true) end end addCommandHandler("vr", VoteRedo, false,false) function RedoVoteMap(mapName) mapName = tostring(mapName) if #mapQueue == 0 then outputChatBox("#00aaff[Panel]: Next Map set for Redo", getRootElement(), 255,255,255,true) else outputChatBox("#00aaff[Panel]: Maps Queued for player after Redo", getRootElement(), 255,255,255,true) end table.insert(mapQueue, 1, mapName) end
  25. mapInfo.name should work, show me how you did it.
×
×
  • Create New...