-
Posts
353 -
Joined
-
Last visited
-
Days Won
3
Everything posted by LoPollo
-
And i guess you execute on connect the radaron if the saved state was on... Is it possible that the problem is raised by the fact the client is still initializing? 1. Under what event do you check the saved state and execute radaron? 2. Can you try to execute the function with a delay - setTimer? just some seconds to make sure there's no relation with the initialization of the client when he connects a "line"?
-
Like the reply of @Wojak, he deserves it. He put much more effort than me. What function do you call exactly when ticking/unticking the checkbox? radaroff and radaron? Also after using that resource some times, could you check perfromancebrowser - lua memory for that resource? On load tile you create the texture and apply it, in unload you "remove if from the world" but do not destroy it
-
I'm not able to use the texture edge on a texture with dxDrawImage on a bigger texture. Wiki uses dxDrawImageSection... and it's the only way i get the edge working local useImageInsteadOfScreen = false local imageTexture = useImageInsteadOfScreen and dxCreateRenderTarget ( 300, 300, true ) or dxCreateScreenSource(300, 300) local theRenderTarget = dxCreateRenderTarget( 300, 300, true ) local sx, sy = guiGetScreenSize() sx, sy = sx / 1366, sy / 768 function init() if useImageInsteadOfScreen then dxSetRenderTarget( imageTexture ) --draw what you want on the image dxDrawRectangle( 0, 0, 300, 300 ) dxSetRenderTarget() end dxSetTextureEdge(imageTexture, "clamp") end addEventHandler( "onClientResourceStart", resourceRoot, init ) addEventHandler( "onClientRestore", root, init ) function init2() if not useImageInsteadOfScreen then dxUpdateScreenSource( imageTexture ) end dxSetRenderTarget( theRenderTarget, true ) dxDrawImageSection( 0, 0, 300, 300, -30, -30, 300+60, 300+60, imageTexture ) dxSetRenderTarget() end addEventHandler( "onClientResourceStart", resourceRoot, init2 ) addEventHandler( "onClientRestore", root, init2 ) function render() dxSetRenderTarget() dxDrawImage( 20*sx, 200*sy, 300*sx, 300*sy, theRenderTarget ) end addEventHandler( "onClientRender", root, render)
-
Why aren't you drawing the texture you loaded instead of "img/radar_map.jpg"? dxDrawImage(X - worldW/2, mH/5 + (Y - worldH/2), worldW, worldH, "img/radar_map.jpg", camZ, (x/(6000/worldW)), -(y/(6000/worldH)), tocolor(255, 255, 255, 255)) Note: i'm doing test & fail
-
try setting the edge of rt to clamp type
-
Check the syntax. handler is written Handler, and the function handleTileLoading does not exists Also are you getting the lags when switching on or off?
-
so there's not only "lag", the fps will decrease... so there's a leak. How is the "structure" of the render handler? something like check if enabled show or hide default radar show or not the custom radar ?
-
I don't think the lags are caused by the not unloaded textures or similar. It's because there's something failing, and probably in the render handler function. PS: i don't have read your code , i posted because some loaded texture will not make lags, failing functions and big tasks do.
-
less generic title please EDIT: now i'm annoyed... did you even try a fast search??? it's the... 5th result? And on google is the first, damn! Before trying to script try at least to learn how to use your pc and internet. THEN ask us, you will be welcome. I'm sorry to say this but, damn, it will reduce time to solve the problem for you and we won't WASTE time
-
can you post the code block where you draw the image? i'm not an expert so i think i should do "try and fail" and repeat, if i manage to do something useful i will post here
-
Good you fixed it, basically what @pa3ck said... I don't fully understand it since if the arg is a number then the tostring of a number (10) will return the string ("10"), a true value. Negating this in an "and" will make "and false" and thus the function should not work >.> still if it's work i don't see any reason to stay on this also be aware that passing a value that's not an element and not a number will always be processed in the "string" block (for example a table will be processed here)... so if you want to edit the code as i said (i'm talking about handling 3 types of arg... this problem started from here) to get a easier script to read, maintain and edit. But again if you consider this a waste of time since it's working don't mind
-
Uuuups tostring(vehicle) will convert the element into a string representation, even a mta element converted to string is like userdata: [someNumbers] or element: [someOtherNumber].... so we shoud check if the tostring(vehicle) is equal to vehicle (the string equivalent of the elòement is the element itself: so we're checking if the element IS a string, and not if it's possible to convert it to string - lol) replace tostring(vehicle) with tostring(vehicle) == vehicle Note: untested
-
--if #1 if vehicle and isElement(vehicle) then return k else return false end --if #2 if tostring(vehicle) then if getVehicleNameFromModel(v[i].modelID) == tostring(vehicle) then return k end else return false end If we insert a string as "vehicle" (we want to execute if #2) we must execute if #1 first. if vehicle is a string, it is a value (if vehicle will return true) but it's not an element since it's a string (so if isElement(vehicle) will return false) this means that once the "return false" is executed, the function will end, and we will never reach if #2 You should use something like this instead both are untested, also passing so many argument types as you can see makes the function much longer (however we could have made a better-styled, more compact function even in our scenario) and can also lead to confusion. Let me know if it works and if you can fix it
-
I had no time, i even right now i do not have much time. So i'm posting the script i was playing on local killstreaks = {} function onPedWastedHandler( ammo, attacker, weapon, bodypart, loss ) if attacker then local thePlayer = attacker if killstreaks[attacker] then killstreaks[attacker] = killstreaks[attacker] + 1 else killstreaks[attacker] = 1 end outputDebugString( killstreaks[attacker] ) if killstreaks[attacker] == 3 then outputChatBox (getPlayerName(attacker).." got a 3 killing-streak! Nice! (500XP reward)",thePlayer, 0,255,0) local exp = getElementData(thePlayer, "experience") or 0 setElementData(thePlayer, "experience", tonumber(exp+500)) end if killstreaks[attacker] == 5 then outputChatBox (getPlayerName(attacker).." got a 5 killing-streak! Great! (1000XP reward)",thePlayer,0,255,0) local exp = getElementData(thePlayer, "experience") setElementData(thePlayer, "experience", tonumber(exp+1000)) end if killstreaks[attacker] == 10 then outputChatBox (getPlayerName(attacker).." got a 10 killing-streak! Awesome! (2000XP reward)",thePlayer,0,255,0) local exp = getElementData(thePlayer, "experience") setElementData(thePlayer, "experience", tonumber(exp+2000)) end if killstreaks[attacker] == 15 then outputChatBox (getPlayerName(attacker).." got a 15 killing-streak! RAMPAGE! (4000XP reward)",thePlayer,0,255,0) local exp = getElementData(thePlayer, "experience") setElementData(thePlayer, "experience", tonumber(exp+4000)) end if killstreaks[source] then if killstreaks[source] >= 3 then outputChatBox (getPlayerName(attacker).." stopped the "..killstreaks[source] .." killing-streak of "..getPlayerName(source).."!",getRootElement (), 255,0,0) end end end end addEventHandler ('onPlayerWasted', root, onPedWastedHandler) addEvent("testEvent", false) addEventHandler( "testEvent", root, onPedWastedHandler) function resetKillingstreak () local player = source --it's not the first parameter, it is the source! --local killstreaks = killstreaks[player] if killstreaks[player] and ( killstreaks[player] > 0 ) then --if the killstreak exists (it may be nil) and it's higher than 0 --They have a killingstreak higher than 0 --We will want to reset the element data back to its default (that being false) killstreaks[player] = 0 --set it to 0 outputDebugString( "reset" ) end end addEventHandler("onPlayerWasted", root, resetKillingstreak) addCommandHandler( "test2", function(thePlayer,cmd,...) triggerEvent( "testEvent", thePlayer, 0, thePlayer ) end ) This is 3 days old and i did not touch it, it should work if i didn't make any more tests. This is the script i was using to control the attacker and the source of the deathHandler I used the command to add kills (without actually killing, i was alone ) without dying, and suiciding with /kill resets the killstreak since also the resetKillingstreak function gets called. NOTE: i also renamed the variable player to thePlayer, but that was for another test i removed from here... so don't mind about that change
-
I'm not an expert, but maybe it does not have effect because you are setting the edge of the texture of the map: the size of the texture and the size of the image are the same. The edge type may only apply to the part of a texture which is empty. Try applying that to the texture you draw the map texture (in you example was called "texture") on (probably a renderTarget?). I'm not expert, but if you have time you can try... it's better to do nothing and be bored
-
same, replace player head location with veh location PS: this will be relative to the vehicle IN THE WORLD
-
Ehhhm... if i understand you have 2 locations, point and ped head? - math.abs EDIT: that way what i said could be considired sarcastic, actually i'm serious: you only need to do the absolute of the subtraction of each x, each y, each z
-
Do not return false inside the loop, it will break it. If the function must return false if the vehicle is not found, that means that the whole table has been looped, and no item was the one you were looking for. so you must use the "return false" after the loop finish, when all vehicles in the table have been compared. Also i don't get this: if getVehicleNameFromModel(v[i].modelID) == tostring(vehicle) or tostring(v[i].vehicleName) == tostring(vehicle) then return v[i].vehicleName end --tostring(v[i].vehicleName) == tostring(vehicle) then return vehiclename???? --if tostring(vehicle) is equal to vehiclename the script already have it, why should you call this function? vehName: if all the table has been iterated and no item was the one you were looking for, then return getVehicleNameFromModel (after you have read what written above, basically just replace false with the name if 1. the vehicle arg was a vehicle element: get the name and return it (if it's not a vehicle element then return false) or 2. the vehicle arg was a number, return what getVehNameFromModel returns (false if not valid, name if valid - exaclty what u need)) or 3. the vehicle arg was a string, convert to number (if not valid number return false) and see No. 2 ) brand: once you're outside the loop (that means no vehicle was found) return empty string
-
just so you know, there's a scripting section in which topics like this can be made and resolved. Good luck with scripting! PS: i noticed that this is a dup of this: pls do not open another topic, just bump the old replying "bump" or "up" or "anyone?" or similar (wait at least 1 day before doing so)
-
I would suggest reading the rules before posting, we have no idea what the problem is and no idea what you want to achieve
-
I'm in a hurry so i hope i did not misunderstood or not read something. If in the script you have acces to the vehicleTable you can loop the vehicleTable for k,v in pairs(vehicleTable) do for i=1,#v do if v[i].modelID == getElementModel(theVehicle) then --example: k: "Maibatsu", v[i].vehicleName: "Penumbra" break end end end untested if you will be calling this function lots of times and performance matters you could create a variable (eg lookupTable), call function like the above to create the table in lookuptable and read this lookuptable everytime you need. that table structure should be like this: variable[theVehicleID] = {brand="someBrand", vehicleName="someName"}
-
If it does not work then i have to see it all again when i have time
-
Provide more informations, we can't read in your mind. Tell us the errors/warnings if there are, tell us if the server is a default server and if there's a resource causing this. Also give a title that represents the issue, "help" is way too much generic