Jump to content

Imposter

Members
  • Posts

    188
  • Joined

  • Last visited

Everything posted by Imposter

  1. Hey there, I am having trouble in finding the position of the exhaust tip of a car (where the nitrous is released from) and the getVehicleComponentPosition does NOT have the exhaust tip as a component. Help would be greatly appreciated. Thanks, Imposter.
  2. You never know, the problem may be here: [2013-10-26 05:04:18] ADMIN: Resource 'ReservedSlot' stopped by quark(Console.) Also, I suggest you check that resource out. May have a leak there. Or maybe he injected code?
  3. Well, you guys misunderstood, I meant, redirecting a person to a webpage by opening their browser, like Chrome. I know I could make a parser myself but that would be lengthy.
  4. Is it possible to open a browser using the game, going to a certain web address? I am trying to make an online store for my server.
  5. you can use -- to store setElementData(theVehicle, "maxVelocity", theValue); -- to obtain getElementData(theVehicle, "maxVelocity");
  6. Hmm... that is a great idea. <3
  7. I just said I needed not dx, but cegui static image.
  8. You could change their maxvelocity properties in handling when they hit the colsphere and restore it using elementdata.
  9. Hey there, is it possible to use an image from the web with guiStaticImageLoadImage? If not, can someone explain a way to do it without DX?
  10. I don't know what you mean, the first one is relevant to the size of the screen, so it is always positioned screenW-width-10 etc. Could you help me out Dealman?
  11. It is already absolute though, isn't it?
  12. Hey there, I am currently using the GUI Editor Resource and am experiencing problems with offsets when using the code that is outputted. As you can clearly see below, the offsets from left and right (for the children of the scrollpane) should be 10px each. GUIEditor = { tab = {}, staticimage = {}, edit = {}, tabpanel = {}, label = {}, button = {}, scrollpane = {}, gridlist = {}, memo = {} } addEventHandler("onClientResourceStart", resourceRoot, function() local screenW, screenH = guiGetScreenSize() GUIEditor.staticimage[1] = guiCreateStaticImage(screenW - 267 - 10, screenH - 484 - 10, 267, 484, "images/galaxys4.png", false) GUIEditor.staticimage[2] = guiCreateStaticImage(20, 51, 227, 383, "images/white.png", false, GUIEditor.staticimage[1]); GUIEditor.scrollpane[1] = guiCreateScrollPane(0, 0, 227, 383, false, GUIEditor.staticimage[2]) GUIEditor.label[1] = guiCreateLabel(10, 10, 207, 43, "Email", false, GUIEditor.scrollpane[1]) local font_0 = guiCreateFont(":SRR-Gamemode/fonts/srrheadfont.ttf") guiSetFont(GUIEditor.label[1], font_0) guiLabelSetColor(GUIEditor.label[1], 250, 195, 4) guiLabelSetHorizontalAlign(GUIEditor.label[1], "center", false) guiLabelSetVerticalAlign(GUIEditor.label[1], "center") GUIEditor.tabpanel[1] = guiCreateTabPanel(10, 60, 207, 313, false, GUIEditor.scrollpane[1]) GUIEditor.tab[1] = guiCreateTab("Inbox", GUIEditor.tabpanel[1]) GUIEditor.memo[1] = guiCreateMemo(10, 114, 187, 165, "", false, GUIEditor.tab[1]) GUIEditor.gridlist[1] = guiCreateGridList(9, 8, 188, 101, false, GUIEditor.tab[1]) guiGridListAddColumn(GUIEditor.gridlist[1], "Subject", 0.4) guiGridListAddColumn(GUIEditor.gridlist[1], "Sender", 0.4) GUIEditor.tab[2] = guiCreateTab("Send", GUIEditor.tabpanel[1]) GUIEditor.edit[1] = guiCreateEdit(6, 12, 191, 27, "Subject", false, GUIEditor.tab[2]) GUIEditor.edit[2] = guiCreateEdit(6, 49, 191, 27, "Recipient(s) (Split by \", \")", false, GUIEditor.tab[2]) GUIEditor.edit[3] = guiCreateEdit(8, 85, 189, 168, "", false, GUIEditor.tab[2]) GUIEditor.button[1] = guiCreateButton(131, 259, 66, 20, "Send", false, GUIEditor.tab[2]) end ) But this is what is shown. As you can see, the offsets are totally incorrect, and this is not what I see when designing the GUI. Is this an MTA Bug when using staticimages? I would really appreciate it if someone with knowledge of this would help me out. Thanks, NooP
  13. Oh, I will look at this now.
  14. Yeah, such as there the Nitro model is placed, there has to be a name for the component key.
  15. Hey guys, I just wanted to ask a small question. What is the key name for the component NITRO, I couldn't find it myself, any ideas?
  16. Sorry I took so long, I have exams. >_> Anyways, I can't get the peds to move, even the forward control state doesnt work. I need some way for the ped to look at the player and shoot him. The shooting works, but the looking doesn't (The ped doesn't rotate). Help would be greatly appreciated. Client.lua function setPedMoveState(thePed, theMoveState) local theLastPlayer = getElementData(thePed, "theLastPlayer"); if (isElement(theLastPlayer) == true) then local pedX, pedY, pedZ = getElementPosition(thePed); local playerX, playerY, playerZ = getElementPosition(theLastPlayer); local playerRot = getElementRotation(theLastPlayer); if (playerX) and (playerY) and (playerZ) then if(isLineOfSightClear(playerX, playerY, playerZ, pedX, pedY, pedZ, true, false, false, true, true, false, false)) then if (theMoveState == true) then setPedLookAt(thePed, playerX, playerY, playerZ, 999999999, 200, theLastPlayer); setPedAimTarget(thePed, playerX, playerY, playerZ); setPedCameraRotation(thePed, (math.deg(math.atan2((playerX - pedX), (playerY - pedY)))) % 360); setPedControlState(thePed, "sprint", true); -- This doesn't work setPedControlState(thePed, "forward", true); -- This doesn't work end else setPedControlState(thePed, "sprint", false); -- This doesn't work setPedControlState(thePed, "forward", false); -- This doesn't work end end end end addEvent("setPedMoveState", true); addEventHandler("setPedMoveState", getRootElement(), setPedMoveState); function setPedShootState(thePed, theShootState) local theLastPlayer = getElementData(thePed, "theLastPlayer"); if (isElement(theLastPlayer) == true) then setPedControlState(thePed, "fire", theShootState); end end addEvent("setPedShootState", true); addEventHandler("setPedShootState", getRootElement(), setPedShootState); Server.lua thePeds = { [0] = createPed(287, 152.85546875, 1929.802734375, 18.964239120483, 50.057220458984, true), [1] = createPed(287, 160.578125, 1908.6025390625, 18.678409576416, 30.946228027344, true), [2] = createPed(287, 185.9677734375, 1926.345703125, 17.759992599487, 181.6369934082, true), [3] = createPed(287, 204.7578125, 1898.0029296875, 17.640625, 5.5619201660156, true), [4] = createPed(287, 222.2822265625, 1897.9443359375, 17.640625, 18.388641357422, true) }; function givePedsWeapons() table.foreach(thePeds, function(theIndex) local thePed = thePeds[theIndex]; if (thePed) then giveWeapon(thePed, 31, 99999, true); end end); end addCommandHandler("gpw", givePedsWeapons); function givePedsBrains() table.foreach(thePeds, function(theIndex) setTimer(function() local thePed = thePeds[theIndex]; if (thePed) then local theLastPlayer = getElementData(thePed, "theLastPlayer"); if (theLastPlayer) and (getElementType(theLastPlayer) == "player") then if (isPedDead(theLastPlayer) == true) then local pedX, pedY, pedZ = getElementPosition(thePed); local playerX, playerY, playerZ = getElementPosition(theLastPlayer); local theDistance = getDistanceBetweenPoints3D(pedX, pedY, pedZ, playerX, playerY, playerZ); if (theDistance <= 15) then triggerClientEvent("setPedMoveState", getRootElement(), thePed, false); triggerClientEvent("setPedShootState", getRootElement(), thePed, true); elseif (theDistance > 15) and (theDistance <= 25) then triggerClientEvent("setPedMoveState", getRootElement(), thePed, true); triggerClientEvent("setPedShootState", getRootElement(), thePed, false); elseif (theDistance <= 50) then triggerClientEvent("setPedMoveState", getRootElement(), thePed, true); triggerClientEvent("setPedShootState", getRootElement(), thePed, false); else -- Get New Player! setElementData(thePed, "theLastPlayer", nil); triggerClientEvent("setPedMoveState", getRootElement(), thePed, false); triggerClientEvent("setPedShootState", getRootElement(), thePed, false); end else -- Get New Player! setElementData(thePed, "theLastPlayer", nil); triggerClientEvent("setPedMoveState", getRootElement(), thePed, false); triggerClientEvent("setPedShootState", getRootElement(), thePed, false); end else for theIndex, thePlayer in ipairs(getElementsByType("player")) do if (isPedDead(thePlayer) == false) then local pedX, pedY, pedZ = getElementPosition(thePed); local playerX, playerY, playerZ = getElementPosition(thePlayer); local theDistance = getDistanceBetweenPoints3D(pedX, pedY, pedZ, playerX, playerY, playerZ); if (theDistance <= 15) then setElementData(thePed, "theLastPlayer", thePlayer); triggerClientEvent("setPedMoveState", getRootElement(), thePed, false); triggerClientEvent("setPedShootState", getRootElement(), thePed, true); elseif (theDistance > 15) and (theDistance <= 25) then setElementData(thePed, "theLastPlayer", thePlayer); triggerClientEvent("setPedMoveState", getRootElement(), thePed, true); triggerClientEvent("setPedShootState", getRootElement(), thePed, false); elseif (theDistance <= 50) then triggerClientEvent("setPedMoveState", getRootElement(), thePed, true); triggerClientEvent("setPedShootState", getRootElement(), thePed, false); setElementData(thePed, "theLastPlayer", thePlayer); else -- Stop moving! setElementData(thePed, "theLastPlayer", nil); triggerClientEvent("setPedMoveState", getRootElement(), thePed, false); triggerClientEvent("setPedShootState", getRootElement(), thePed, false); end else -- Get New Player! setElementData(thePed, "theLastPlayer", nil); triggerClientEvent("setPedMoveState", getRootElement(), thePed, false); triggerClientEvent("setPedShootState", getRootElement(), thePed, false); end end end end end, 50, 0); end); end addCommandHandler("gpb", givePedsBrains);
  17. That doesn't work, I get errors since there is no Z position.
  18. How can I make a ped rotate towards a player?
  19. Hey is it possible to fire a Ped's weapon? getPedWeapon(thePed) returns the type, how can I get the actual element? and how can I fire it?
  20. It works when I do it with the command though. EDIT: Whatever, got it working with: thePosition = 0; function updatePosition(theSeek) thePosition = theSeek; end addEvent("updateStreamPosition", true); addEventHandler("updateStreamPosition", getRootElement(), updatePosition); function resume() if (nowPlaying) then outputMessage("Resuming!", "Radio"); setSoundPosition(nowPlaying, thePosition); end end addCommandHandler("resume", resume);
  21. Help anyone? This works, but not in the streamAudio Event: function setSongPos(cmd, seconds) local ssp = setSoundPosition(nowPlaying, seconds) if ssp then outputChatBox("Sound is now playing from: "..seconds.." Seconds!") else outputChatBox("An error has occured. Please make shore there are atleast") outputChatBox(seconds.." Seconds in this song!") end end addCommandHandler("seek", setSongPos)
  22. Well it works when I use the example(command), and that works in seconds, not milliseconds. I tried it with a timer too to see if it needed a delay, but that doesn't work either.
  23. I did that, but the music starts from 0. My Code: server.lua musicList = { }; theBaseUrl = "http://www.indigogames.net/tmhc/music/"; theStreamUrl = nil; theStreamPosition = 0; theStreamTimer = nil; function outputMessage(theMessage, theObject, theClass) if (theClass == nil) then outputChatBox("#00C3FF[TMHC]:#E0E0E0 " .. theMessage, theObject, 255, 255, 255, true); elseif (theObject == nil) then outputChatBox("#00C3FF[TMHC" .. theClass .. "]:#E0E0E0 " .. theMessage, getRootElement(), 255, 255, 255, true); else outputChatBox("#00C3FF[TMHC-" .. theClass .. "]:#E0E0E0 " .. theMessage, getRootElement(), 255, 255, 255, true); end end function onResourceStart() fetchRemote("http://www.indigogames.net/tmhc/music/index.php?mode=list", parseMusicData, "", false); end addEventHandler("onResourceStart", resourceRoot, onResourceStart); function onPlayerLogin() triggerClientEvent("streamAudio", getRootElement(), theStreamUrl, theStreamPosition); end addEventHandler("onPlayerLogin", getRootElement(), onPlayerLogin); function parseMusicData(responseData, errorNo) if (errorNo == 0) then if (string.len(responseData) > 0) then musicList = fromJSON(responseData); if (musicList == nil) then outputMessage("#FF0000A system error occurred while parsing the music list.", getRootElement(), "Radio"); return false; end else outputMessage("#FF0000A system error occurred while loading the music list.", getRootElement(), "Radio"); return false; end else outputMessage("#FF0000A system error occurred while fetching the music list.", getRootElement(), "Radio"); return false; end end function playRandomMusic(theTime) setTimer(function() local count = 0; local randomInteger = math.random(0, table.getn(musicList)); for theKey, theValue in pairs(musicList) do if ((count == randomInteger) == false) then count = count + 1; else beginStreaming(theValue); theStreamUrl = theBaseUrl .. theValue; theStreamPosition = 0; theStreamTimer = setTimer(function() theStreamPosition = theStreamPosition + 1 end, 1000, 0); return true; end end end, theTime, 1); end function beginStreaming(theFileName) for theKey, thePlayer in ipairs(getElementsByType("player")) do triggerClientEvent("streamAudio", thePlayer, theBaseUrl .. theFileName); end fetchRemote("http://www.indigogames.net/tmhc/music/index.php?mode=list", parseMusicData, "", false); -- Get new list fetchRemote("http://www.indigogames.net/tmhc/music/index.php?mode=info&filename=" .. theFileName, parseMusic, "", false); end function isPlayerAdmin(thePlayer) if ((thePlayer) and (isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin")))) then return true; else return false; end end function streamMusic(theSource, theCommand, theUrl) if ((isGuestAccount(getPlayerAccount(source)) == false) and (isPlayerAdmin(source) == true)) then -- FIx this if the server can do it! theStreamUrl = theBaseUrl .. theValue; theStreamPosition = 0; theStreamTimer = setTimer(function() theStreamPosition = theStreamPosition + 1 end, 1000, 0); for theKey, thePlayer in ipairs(getElementsByType("player")) do triggerClientEvent("streamAudio", thePlayer, theUrl); end outputMessage(getPlayerName(theSource) .. " is now streaming!", getRootElement(), "Radio"); end end addCommandHandler("stream", streamMusic); function endStreaming(theSource, theCommand) if ((isGuestAccount(getPlayerAccount(source)) == false) and (isPlayerAdmin(source) == true)) then for theKey, thePlayer in ipairs(getElementsByType("player")) do triggerClientEvent("endStream", thePlayer); end outputMessage(getPlayerName(theSource) .. "#FFFF00 has ended the radio stream!", getRootElement(), "Radio"); end end addCommandHandler("endStream", endStreaming); function refreshMusicList(theSource, theCommand) if ((isGuestAccount(getPlayerAccount(theSource)) == false) and (isPlayerAdmin(theSource) == true)) then outputMessage(getPlayerName(theSource) .. " is refreshing the music list!", getRootElement(), "Radio"); fetchRemote("http://www.indigogames.net/tmhc/music/index.php?mode=list", parseMusicData, "", false); end end addCommandHandler("refreshMusicList", refreshMusicList); function startStream(theSource, theCommand) if ((isGuestAccount(getPlayerAccount(theSource)) == false) and (isPlayerAdmin(theSource) == true)) then outputMessage(getPlayerName(theSource) .. " has started the radio stream!", getRootElement(), "Radio"); playRandomMusic(50); end end addCommandHandler("startStream", startStream); function parseMusic(responseData, errorNo) local musicData = fromJSON(responseData); if (musicData) then outputMessage("Now playing: " .. musicData["title"] .. " by " .. musicData["artist"] .. "!", getRootElement(), "Radio"); outputMessage("The next song will be played in " .. musicData["length_long"] .. "!", getRootElement(), "Radio"); playRandomMusic(tonumber(musicData["length"]) * 1000 + 3000); else playRandomMusic(tonumber(musicData["length"]) * 1000 + 3000); end end client.lua nowPlaying = nil; function streamAudio(theUrl, theSeek) if (nowPlaying) then stopSound(nowPlaying); end nowPlaying = playSound(theUrl); if (theSeek) then setSoundPosition(nowPlaying, theSeek * 1000); end end addEvent("streamAudio", true); addEventHandler("streamAudio", getRootElement(), streamAudio); function endStream() if (nowPlaying) then stopSound(nowPlaying); end end addEvent("endStream", true); addEventHandler("endStream", getRootElement(), endStream);
  24. So I have this piece of code, when the streamAudio event is triggered, the seek/sound position is sent to the client. but my problem is, it won't set. The wiki's documentation is also wrong, it says that the setSoundPostion() function uses milliseconds, but it actually uses seconds. Any help?? Client: nowPlaying = nil; function streamAudio(theUrl, theSeek) if (nowPlaying) then stopSound(nowPlaying); end nowPlaying = playSound(theUrl); if (theSeek) then setSoundPosition(nowPlaying, theSeek); end end addEvent("streamAudio", true); addEventHandler("streamAudio", getRootElement(), streamAudio); function endStream() if (nowPlaying) then stopSound(nowPlaying); end end addEvent("endStream", true); addEventHandler("endStream", getRootElement(), endStream);
×
×
  • Create New...