-
Posts
1,803 -
Joined
-
Last visited
-
Days Won
8
Everything posted by Citizen
-
Wups, my bad yeah, Anubhav fixed it. I wrote: if isSoundPaused(veh) then instead of if isSoundPaused(sound) then
-
local number = math.random ( #LoginPos ) local x, y ,z = LoginPos[number][1], LoginPos[number][2], LoginPos[number][3] local tx,ty,tz = LoginPos[number][4], LoginPos[number][5], LoginPos[number][6] setCameraMatrix (x, y, z, tx, ty, tz)
-
k, good luck with your project then
-
but WHAT should I put in setCameraMatrix (2885, 2837, 75, -500, 1010, -550)? Replace the 3 first arguments by x, y and z ? setCameraMatrix (x, y, z, -500, 1010, -550)
-
Yeah okay, so you wanted to center all rectangles to the middle as a whole (like if it was 1 block) like I did ?
-
No problem, still don't know what you really wanted though
-
Hummm okay, I'm a bit late again but the code of Solidsnake doesn't center all rectangle as a whole. So if you add 5 rectangles in your table, then the 1st one will still be rendered from the middle and the last rectangles will probably rendered out of the screen. Here is my version with a screenshot with explainations: local sx, sy = guiGetScreenSize ( ) local example = { { "test1" }, { "test2" } } function draw ( ) local width, height = 100, 50 local offsetY = 10 -- seperation between each rectangles local totalHeight = (50+offsetY)*(#example)-offsetY --(-offsetY to remove seperation of the last rectangle) local x = ( sx/2 - width/2 ) for k, value in ipairs ( example ) do local y = (sy/2 - totalHeight/2) + (height+offsetY) * (k-1) dxDrawRectangle ( x, y, width, height ) end end addEventHandler ( "onClientRender", root, draw ) The result with extra explainations: EDIT: Alright ! seems that the image can't be displayed from gyazo, is there a whitelist on that forum ? I'm gonna upload it somewhere else. EDIT2: Changed img tag
-
The code you gave us is totally useless ... We need the part of the server code that is moving the zombies.
-
Ok so, first I assume that the sound you are using is a sample that loop nicely. Let's then wait and think before going in the code. The sound must start when the engine is on and only with vehicles with the modelid 411(infernus). Then we want to play the sound in 3D and playing it for all Infernus on the server. We need to update the speed of the sound according the speed of the vehicle. We also need to update the position of the 3D sound to follow the vehicle. If the engine is off, then we have to pause the sound and resume it if the engine is on again. Here is a code I just made. With a lot of comments to let you understand what is going on (it's a client script): function updateEngineSound() -- We get a table of all vehicles on the server: local allVehicles = getElementsByType("vehicle") -- we then do a loop that will iterate over that table: for index, veh in ipairs (allVehicles) do --It's like saying: "For each vehicle, do this" -- we get the model of the vehicle local model = getElementModel(veh) -- if the model is equal to 411 then do this if model == 411 then -- if the engine is on if getVehicleEngineState(veh) then -- we get the position of that vehicle local x, y, z = getElementPosition(veh) -- we then try to get the sound we maybe created and stored as an element data -- for that vehicle. If we didn't yet, then it will return false. local sound = getElementData(veh, "engineSound") -- if the inverse of sound is true (same as: if sound is equal to false) -- Note that "not false" will give true if not sound then -- we create the sound at the veh position and loop it sound = playSound3D("sounds/song.mp3", x, y, z, true) -- we store that sound in an element data I decided to call "engineSound" setElementData(veh, "engineSound", sound) end -- if the sound is paused (because the engine was off) then if isSoundPaused(veh) then -- we "unpause" the sound setSoundPaused(sound, false) end -- we then need to get the speed local velocityX, velocityY, velocityZ = getElementVelocity(veh) -- calculate the global speed in mph from the 3 velocities: -- use pythagorean theorem to get actual velocity -- raising something to the exponent of 0.5 is the same thing as taking a square root. local actualspeed = (velocityX^2 + velocityY^2 + velocityZ^2)^(0.5) -- multiply by 50 to obtain the speed in meters per second and -- then by 111.847 to obtain the speed in meters per hour local mph = actualspeed * 50 * 111.847 -- we try to calculate the sound speed according to the mph -- I guess 80mph is the speed that the original sound sounds like and -- I also guess 0.25 is the min speed that the sound can be at to still sounds like an engine. -- I added 80/minSoundSpeed to 80 to compensate the minSoundSpeed we added local minSoundSpeed = 0.25 local soundSpeed = mph/(80+80/minSoundSpeed) + minSoundSpeed -- and then we apply it to the sound setSoundSpeed (sound, soundSpeed) -- and finally update the sound position to follow the vehicle setElementPosition(sound, x, y, z) else -- otherwise (so if the engine is off) -- we pause the sound setSoundPaused(sound, true) end -- close the "if engine was on" end -- close the "if model was 411" end -- end of the loop end setTimer(updateEngineSound, 50, 0) --repeat that function every 50 ms Hope it helps. Regards, Citizen
-
And if you are planning to access the database datas from a website for example, I'll would suggest MySQL.
-
http://lmgtfy.com/?q=mta+vehicle+upgrades
-
Can you please give us more details about your problem ? Because I didn't get it, I just understood that you are getting true as result but dunno where.
-
Yeah, just do what Bonsai just said or check that list from samp wiki: http://wiki.sa-mp.com/wiki/Pickup_IDs
-
To make ur gui 'global' for all resolutions, you have to use relative positions/sizes only. By default only the children of another gui elements are in relative. You can change that in gui editor with a right click anywhere on ur screen (but not on a gui element) and click on "Rel/Abs screen" or something similar (there are two items like this one, and it's the 1st one. And check the chat to be sure they are both to relative). As you already closed ur gui editor, just give me the line codes of the guis that are in absolute and the graphic resolution of your game when you created them. I'll be able to "translate" it in relative (nothing complicated though).
-
Oh that's pretty insane !
-
For instance, you just forgot to send the player argument which is the source of the event in the setTimer. So you had to add source after 5000, 1 But it's useless to use a function when there is only one instruction in it. So use the Solidsnake's code instead.
-
So yeah I guess he did. Try starting again your server and check the console to see something related to the mta_mysql module. When everything is setting up correctly, it should show something like this: [2014-02-17 20:56:07] MODULE: Loaded "MySQL 5.0 database module" (0.50) by "Alberto Alonso <[email protected]>" [2014-02-17 20:56:07] Starting resources... If the dlls aren't in the right folders: [2013-11-09 23:58:11] MODULE: Unable to find modules/mta_mysql.dll! [2013-11-09 23:58:11] Starting resources... Regards, Citizen
-
Ok, I see but I'm not the guy of the situation since I never used shaders. Sorry, need to wait for someone who knows about shaders
-
You need to set getPropagated argument of addEventHandler to false for all onClientGUIClick So: addEventHandler("onClientGUIClick", commandbtn, command) will become: addEventHandler("onClientGUIClick", commandbtn, command, false) Do it for all others. Regards, Citizen
-
Yeah of course, look at this code: cuboid = createColCuboid ( 2043.2, -2608, 12.6, 0.4, 13.5, 1 ) function hit1( box ) if (box == cuboid) then outputChatBox("Hey something just hitted the cuboid colshape !") if getElementType(source) == "vehicle" then outputChatBox("Oh ! and it is a vehicle !") local thePlayer = getVehicleController(source) local playerName = getPlayerName(thePlayer) outputChatBox("And the guy who is driving is "..tostring(playerName)) end end end addEventHandler ("onElementColShapeHit", getRootElement(), hit1) I added some outputs to better understand what is going on.
-
Nope, it will show show the number of players who were playing when the script has been loaded (so when you joined the server) That's a big difference ! Because you never update it anywhere. Imagine the following situation. You join the server, the script is loaded and your playersO = #getElementsByType( "player" ) will be executed and will be 1. So atm, everything is fine. Now a second player joins, that player will load that script and HIS playersO = #getElementsByType( "player" ) will be executed will return 2. Which is correct for him. But what happened to your players0 ?? Nothing, Absolutly nothing, YOUR players0 variable is still equal to 1 so for you it will still show 1/50 instead of 2/50 because you didn't update it when another player joined. Hope it's clear now. So there are two solutions: 1st solution (easy, for lazy coders), get get the number of players every time you want to draw it: local nbPlayers = #getElementsByType( "player" ) dxDrawText(nbPlayers.."/50", X, Y-15, Width, Y, tocolor(255, 255, 255, 255), 1.00, "default-bold", "right", "center", false, false, false, false, false) 2nd solution (cleaner), update the number of players everytime someone joins or quit: local nbPlayers = #getElementsByType("player") function updateNbPlayers(arg) nbPlayers = #getElementsByType("player") end addEventHandler("onClientPlayerJoin", root, updateNbPlayers) addEventHandler("onClientPlayerQuit", root, updateNbPlayers) Of course, replace players0 by nbPlayers in the dxDrawText (better name than players0) _________________________________ (just saw your #push and it isn't allowed ... and btw, I wasn't at home the whole day so ... be patient) Haha, because you broke my code dude with your dirty "fix": if tmpY > Y and tmpY < Y+400 then --I removed the code cuz it is useless to show end I made this variable: local nbLinesToDraw = 20 -- the number of lines that will be drawn at the same time Why didn't you use that variable ?? Maybe because you didn't read/understand the comment ? So if 20 lines was too much to fit the table, just modify that variable to something lower. In your case, the table only can show up to 17 lines at a time, so just set that variable to 17: local nbLinesToDraw = 17 -- the number of lines that will be drawn at the same time Test it again.
-
As far I kow, there is now way to render a part of an image using a mask. If the image is a square/rectangle, then you can just use the dxDrawImageSection function. If it's a circle or some weird shapes, then you can just edit the image to match that shape and let the background transparent. Then you can user dxDrawImage to render it. Is it possible for you to show us the image and the mask and what you want to render using that mask ? Regards, Citizen
-
Omg, why not just delete the timer ? I did it because I thought you would need it. 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 --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 end function hideDeadImage() removeEventHandler("onClientRender", root, animateDeadImage) end And just call hideDeadImage when you need to.
-
Yeah, great, but you created a useless anonymous function for that event handler. Let me explain. The addEventHandler function takes a function as 3rd argument. It's the function that will be called if that event is triggered. showDeadImage is a function too right ? so why not just give that function as 3rd argument of addEventHandler ? addEventHandler("onClientPlayerWasted", localPlayer, showDeadImage) Sure, the scripts (client and server) aren't reloaded/restarted on map change, it just deletes the objects from the previous map and create new ones for the next and showing a picture on the screen for the transition. By the way, the mta progressbar when new map is starting is just because that maps are seperated resources, that race gamemode is starting/stoping. So it will download the files that are from the map resource but the other resources are still running. Hope it's a little more clear