-
Posts
605 -
Joined
-
Last visited
-
Days Won
1
Everything posted by JeViCo
-
you not defined specific colshape here function vehicleGodMod(player) if isPedInVehicle ( player ) and getPedOccupiedVehicleSeat( player ) == 0 then vehicle = getPedOccupiedVehicle ( player ) setVehicleDamageProof( vehicle, true ) outputChatBox ( "#FFFFFFVehicle godmode #00FF00enabled", getRootElement(), 255, 0, 0, true ) end end addEventHandler("onColShapeHit", root, vehicleGodMod) function vehicleGodMod2(player) if isPedInVehicle ( player ) and getPedOccupiedVehicleSeat( player ) == 0 then setVehicleDamageProof( vehicle, false ) outputChatBox ( "Vehicle godmode #FF0004disabled", getRootElement(), 255, 255, 255, true ) end end addEventHandler("onColShapeLeave", root, vehicleGodMod2) you should add if source == your_colshape then -- using colshape directly another idea (attach to elementData + useful function). Also, sorry) i forgot that onVehicleDamage doesn't have cancel effect so here (client-side): addEventHandler("onClientVehicleDamage",root,function() local col = isElementWithinAColShape(source) if col then if getElementData(col,"safe-zone") then cancelEvent() end end end) function isElementWithinAColShape(element) local element = element or localPlayer if element or isElement(element)then for _,colshape in ipairs(getElementsByType("colshape"))do if isElementWithinColShape(element,colshape) then return colshape end end end outputDebugString("isElementWithinAColShape - Element does not exist",1) return false end @Quenix, try both ideas and find out which one is better
-
thank you for your support ? i had some problems with my code. Now everything works amazing
-
now i have another problem :c elements don't want to destroy. I use destroyElement(window) then onClientElementDestroy triggers where i do some magic stuff and that's all. window variable is still userdata so element still exists ? or something wrong with my code
-
sorry for bothering you :с i solved this problem by using an additional table
-
@Quenix onVehicleDamage + isElementWithinColShape + cancelEvent() where colshape is your zone EVERYTNING SERVER-SIDE
-
@IIYAMA i returned :3 i figured everything out except for one: i use onClientRender event to draw DX window like that wnd.handlers.render = function() wnd:renderWindow() end addEventHandler("onClientRender", element, wnd.handlers.render) setElementData(element,"variable-data",wnd) but i can't do this because all functions disappear local dat = getElementData(source, "variable-data") removeEventHandler("onClientRender", root, dat.handlers.render) i don't know how to save them. Maybe i should not use elementData
-
What do you mean? It removed function once and spams now or what?
-
@IIYAMA same problem idk why 1-st lua file function destroyDX(element) local dx_type = getElementType(element) if dx_type == "dx-window" then JVwindow.destroy(source) elseif dx_type == "dx-button" then end end addEventHandler("onClientElementDestroy",root,function() if getElementData(source,"dxcore") == true then cancelEvent() destroyDX(source) end end) 2-nd lua file function JVwindow.destroy(element) local dat = getElementData(element, "variable-data") if #dat.main.related_elements > 0 then for _, el in ipairs(dat.main.related_elements) do destroyElement(el) end end removeEventHandler("onClientRender", root, dat.handlers.render) setmetatable(dat, nil) destroyElement(element) end errors: I thought cancelEvent() didn't work but nope print(element) returns userdata so element exists
-
wtf why did i miss it, Thank you so much
-
Can i install utf8 Lua module somehow? I need lua string-matching functions to use russian letters
-
local table1 = {"1", "2", "3"} local table2 = {"2", "3", "1"} function sameTables(tab1, tab2) local endTable = {} if #tab1 == #tab2 then for _, v in ipairs(tab1) do local check for _,v2 in ipairs(tab2) do if v2 == v then check = true break end end if not check then break return false end end else return false end end @IIYAMA can i write 'break' twice to stop both loops?
-
I checked my code and that's true - all data saved except for functions i'll try to rewrite functions using elements only and connect them with metatables with elementData
-
Hello everyone :3 I tried to make my own dx-gui system. I separate functions into several .lua files (i have a window and a button) So i used this to destroy elements in 3-rd file addEventHandler("onClientElementDestroy",root,function() if getElementData(source,"dxcore") == true then triggerEvent("destroy-"..getElementType(source),localPlayer,getElementData(source,"variable-data")) end end) -- getElementData(source,"variable-data") returns table (all info about this dx element in metatable) 1-st file: function JVbutton:destroy() -- remove stuff (button) end addEvent("destroy-dx-button",true) addEventHandler("destroy-dx-button",root,function(data) data:destroy() end) 2-nd file function JVwindow:destroy() -- remove stuff (window) end addEvent("destroy-dx-window",true) addEventHandler("destroy-dx-window",root,function(data) data:destroy() end) but i keep getting same errors: ( attempt to call method 'destroy' a nil value) What am i doing wrong?
-
Sup guys I have 2 tables with same values but they're in different order -. I'm looking for better method to compare this 2 tables without losing performance
-
that's rather hard to understand at the moment. I'll try to make some experiments with it. Thank you anyway =3
-
Hello everyone! I tried to make something like this: 1-st resource (where i calculate everything) function choosed(colors) if choosed then return colors else return false end end addEventHandler("onDGSPickerChoose", getRootElement(), choosed) 2-nd resource (where i use data to make something awesome) addEventHandler("onDGSPickerChoose", getRootElement(), function(rgba) --i use rgb stuff here end) I'm not sure that i'm doing it right
-
Thank you so much. Now i understand patterns a little bit more
-
it works! Thank you. So how did you do that? ( ) means subpattern and ^ at the beginning and $ at the end of string mean - 'match whole string from the start till the end' Am i right?
-
@TorNix~|nR you should add empty file server side with name "gui_skin.png" and add it to meta.xml with download="false" property or you'll get error on 7-th line @Ren_712 could you fix a problem above ? object_preview creates 2 objects on screen if second render target's value = true
-
Hello everyone. I've recently tried to make roleplay nickname pattern (example: Nicolas_Cage) but it doesn't work properly addCommandHandler("checkName",function(pl) local name = getPlayerName(pl) if string.match(name,"(%u?)(%l+)%_(%u?)(%l+)") then outputChatBox("rp nickname") else outputChatBox("nonrp nickname") end end) I can use Nikolas_CAgE and it'll match i used this and this wikis What am i doing wrong?
-
@SSKE use loadstring function. Example (by Tete omar): loadstring ( "outputChatBox ( \"Hello!\" )" ) you can also color them using string.find + string.gsub function (paste any #FFFFFF color)
-
you can't create object preview and save it instantly. Creating preview takes a little amount of time so you'll always get an empty image. setTimer will solve your problem @TorNix~|nR
-
@CodyJ(L) are you going to convert s.t.a.l.k.e.r: shadow of Chernobyl map or it's huge for gta?
- 154 replies
-
- lc
- carmageddon
-
(and 1 more)
Tagged with:
-
account existed i replaced it with onPlayerLogin event and solved my problem. Thanks anyway