
idarrr
Members-
Posts
133 -
Joined
-
Last visited
-
Days Won
1
Everything posted by idarrr
-
This. addCommandHandler and this. isObjectInACLGroup
-
Np dude, PM me if you need help, maybe I can help you
-
Try this. cars = getElementsByType("vehicle",root,true) for num, car in ipairs(cars) do local carHP = math.floor (getElementHealth(car)) if carHP < 640 then local getTickStart = getTickCount () getTickStart = math.floor(getTickStart / 1000) if math.mod(getTickStart, 2) == 0 then local masina = getPedOccupiedVehicle(getLocalPlayer()) if masina then if masina == car then dxDrawImage( screenWidth - 200, 970,32,37,"images/hud/accident.png") ax = ax - 34 end end end end end
-
Yes because you are looping all vehicles that streamed by client. Try this. function createSpeedo() local theVehicle = getPedOccupiedVehicle(getLocalPlayer()) -- Check if the player is in Vehicle, if he is not in any vehicle then it will return false if theVehicle then -- If true (the player is in his Vehicle), this argument will pass this block and execute the code below local carHP = math.floor(getElementHealth(theVehicle) / 10) if carHP < 500 then dxDrawImage( screenWidth - 200, 32,32,37,"images/hud/damage.png") ax = ax - 34 end end end
-
Here you go. function createSpeedo() cars = getElementsByType("vehicle",root,true) for num, car in ipairs(cars) do local carHP = math.floor(getElementHealth(car) / 10) if carHP < 500 then local theVehicle = getPedOccupiedVehicle(getLocalPlayer()) if theVehicle then dxDrawImage( screenWidth - 200, 32,32,37,"images/hud/damage.png") ax = ax - 34 end end end end Or try this one, it's more simple and more efective. function createSpeedo() local theVehicle = getPedOccupiedVehicle(getLocalPlayer()) -- Check if the player is in Vehicle, if he is not in any vehicle then it will return false if theVehicle then -- If true (the player is in his Vehicle), this argument will pass this block and execute the code below local carHP = math.floor(getElementHealth(theVehicle) / 10) if carHP < 500 then dxDrawImage( screenWidth - 200, 32,32,37,"images/hud/damage.png") ax = ax - 34 end end end
-
I also vote for Indonesian board. Maybe I can help people there.
-
function createSpeedo() cars = getElementsByType("vehicle",root,true) for num, car in ipairs(cars) do local carHP = math.floor(getElementHealth(car) / 10) if carHP < 500 then dxDrawImage( screenWidth - 200, 32,32,37,"images/hud/damage.png") ax = ax - 34 end end end
-
EDIT: Already tried that code, doesnt work. I made this new one, work for me. If you want to draw the circle with reverse mode, set the last argument to true
-
You can't set it to minus 90 because there is no negative value for index loop, but if you want to make it draw in reverse mode (like you said draw from middle to right) here is may help. Im not testing it yet but maybe this could help. -- [Sorry for Bad English] -- I added "isReverse" argument (a boolean value), if the value is "true" then it will draw the circle to the right, default value is "false" (draw the circle to the left) function dxDrawCircle( posX, posY, radius, width, angleAmount, startAngle, stopAngle, color, postGUI, isReverse ) if ( type( posX ) ~= "number" ) or ( type( posY ) ~= "number" ) then return false end radius = type( radius ) == "number" and radius or 50 width = type( width ) == "number" and width or 5 angleAmount = type( angleAmount ) == "number" and angleAmount or 1 color = color or tocolor( 255, 255, 255, 200 ) postGUI = type( postGUI ) == "boolean" and postGUI or false isReverse = type(isReverse) == "boolean" and isReverse or false if ( stopAngle < startAngle ) then local tempAngle = stopAngle stopAngle = startAngle startAngle = tempAngle end for i = startAngle, stopAngle, angleAmount do if isReverse then -- If isReverse is true, then it will change the "i" value to negative i = -i else -- If isReverse is false(default), "i" will be positive i = i end local startX = math.cos( math.rad( i ) ) * ( radius + width ) local startY = math.sin( math.rad( i ) ) * ( radius + width ) local endX = math.cos( math.rad( i ) ) * ( radius - width ) local endY = math.sin( math.rad( i ) ) * ( radius - width ) dxDrawLine( startX + posX, startY + posY, endX + posX, endY + posY, color, width, postGUI ) end return true end -- This code below will draw the circle from mid to left (default) function drawToLeft() dxDrawCircle(screenWidth/2, screenHeight/2, 110, 7, 1, 0, 90, tocolor( 255, 255, 255, 200 ), false, false) end addEventHandler("onClientRender", getRootElement(), drawToLeft) -- This code below will draw the circle from mid to right (reverse) function drawToRight() dxDrawCircle(screenWidth/2, screenHeight/2, 110, 7, 1, 0, 90, tocolor( 255, 255, 255, 200 ), false, true) end addEventHandler("onClientRender", getRootElement(), drawToRight)
-
on line 70, source is not the button, but the window (correct me if im wrong). so it will never get passed on if source == GUIEditor.button[2] then addEventHandler("onClientGUIClick",GUIEditor.window[1],buttonClick) should be like this addEventHandler("onClientGUIClick",GUIEditor.button[2],buttonClick) You may need to add another event to handle another button. Full Code: local sx, sy = guiGetScreenSize ( ) function centerGUI ( guiElement ) local width, height = guiGetSize ( guiElement, false ) local x, y = ( sx / 2 - width / 2 ), ( sy / 2 - height / 2 ) guiSetPosition ( guiElement, x, y, false ) end GUIEditor = { tab = {}, staticimage = {}, tabpanel = {}, edit = {}, button = {}, window = {}, label = {} } GUIEditor.window[1] = guiCreateWindow(423, 331, 523, 367, "", false) guiWindowSetSizable(GUIEditor.window[1], false) centerGUI(GUIEditor.window[1]) guiSetVisible(GUIEditor.window[1],false) GUIEditor.tabpanel[1] = guiCreateTabPanel(11, 109, 502, 241, false, GUIEditor.window[1]) GUIEditor.tab[1] = guiCreateTab("Login", GUIEditor.tabpanel[1]) GUIEditor.label[1] = guiCreateLabel(27, 31, 63, 15, "Username", false, GUIEditor.tab[1]) GUIEditor.edit[1] = guiCreateEdit(100, 30, 352, 26, "", false, GUIEditor.tab[1]) GUIEditor.edit[2] = guiCreateEdit(97, 74, 355, 24, "", false, GUIEditor.tab[1]) GUIEditor.button[1] = guiCreateButton(314, 152, 153, 42, "Login", false, GUIEditor.tab[1]) GUIEditor.tab[2] = guiCreateTab("Register", GUIEditor.tabpanel[1]) GUIEditor.label[2] = guiCreateLabel(16, 26, 76, 15, "Username : ", false, GUIEditor.tab[2]) GUIEditor.label[3] = guiCreateLabel(16, 51, 60, 15, "Password : ", false, GUIEditor.tab[2]) GUIEditor.label[4] = guiCreateLabel(18, 80, 42, 15, "Email : ", false, GUIEditor.tab[2]) GUIEditor.button[2] = guiCreateButton(311, 168, 147, 39, "Register", false, GUIEditor.tab[2]) GUIEditor.edit[4] = guiCreateEdit(90, 24, 388, 27, "x", false, GUIEditor.tab[2]) GUIEditor.edit[5] = guiCreateEdit(90, 52, 388, 28, "y", false, GUIEditor.tab[2]) GUIEditor.edit[6] = guiCreateEdit(85, 79, 393, 26, "z", false, GUIEditor.tab[2]) addEvent("showHide",true) function showHide() if guiGetVisible(GUIEditor.window[1]) == true then guiSetVisible(GUIEditor.window[1],false) showCursor(false) elseif guiGetVisible(GUIEditor.window[1]) == false then guiSetVisible(GUIEditor.window[1],true) showCursor(true) end end addEventHandler("showHide",getLocalPlayer(),showHide) showHide() function buttonClick1() if source == GUIEditor.button[1] then local username = guiGetText(GUIEditor.edit[1]) local password = guiGetText(GUIEditor.edit[2]) triggerServerEvent("loginRequest",getLocalPlayer(),getLocalPlayer(),username,password) end end addEventHandler("onClientGUIClick",GUIEditor.button[1],buttonClick1) function buttonClick2() if source == GUIEditor.button[2] then local username = guiGetText(GUIEditor.edit[4]) local password = guiGetText(GUIEditor.edit[5]) local email = guiGetText(GUIEditor.edit[6]) triggerServerEvent("registerRequest",getLocalPlayer(),getLocalPlayer(),username,password,email) end end addEventHandler("onClientGUIClick",GUIEditor.button[2],buttonClick2)
-
local localPlayer = getLocalPlayer() function togglePlayerControl(weapon) toggleControl("fire", false) if isPedAiming(localPlayer) then toggleControl("fire", true) end end addEventHandler ( "onClientResourceStart", getResourceRootElement(), togglePlayerControl)
-
function tesztlel() if source ~= GUIEditorgomb1 then return end local random = math.random(1, 7) --change as appropriate if random == 1 then guiSetVisible(nyer, true) guiSetText(szveg, "Nyereményed: MINIGUN \n\nVárunk vissza 12 óra múlva. ;)\nHasználd egészséggel a nyereményed!") --guiSetVisible(GUIEditorwindow, false) triggerServerEvent("giveWeapon", getLocalPlayer(), group) local currentState = guiGetProperty( GUIEditorgomb1, "Disabled" ) if currentState == "True" then guiSetProperty( GUIEditorgomb1, "Disabled", "True" ) else guiSetProperty( GUIEditorgomb1, "Disabled", "True" ) end elseif random == 2 then guiSetVisible(nyer, true) guiSetText(szveg, "Nyereményed: GOD MODE \n\nVárunk vissza 12 óra múlva. ;)\nHasználd egészséggel a nyereményed!") function godmode ( ) cancelEvent ( ) end addEventHandler ( "onClientGUIClick", button2, function ( ) addEventHandler ( "onClientPlayerDamage", localPlayer, godmode ) toggleControl ( 'fire', false ) toggleControl ( 'action', false ) end ,false ) local currentState = guiGetProperty( GUIEditorgomb1, "Disabled" ) if currentState == "True" then guiSetProperty( GUIEditorgomb1, "Disabled", "True" ) else guiSetProperty( GUIEditorgomb1, "Disabled", "True" ) end elseif random == 3 then guiSetVisible(nyer, true) guiSetText(szveg, "Nyereményed: FEGYVERCSOMAG \n\nVárunk vissza 12 óra múlva. ;)\nHasználd egészséggel a nyereményed!") --guiSetVisible(GUIEditorwindow, false) triggerServerEvent("giveWeapon1", getLocalPlayer(), group) local currentState = guiGetProperty( GUIEditorgomb1, "Disabled" ) if currentState == "True" then guiSetProperty( GUIEditorgomb1, "Disabled", "True" ) else guiSetProperty( GUIEditorgomb1, "Disabled", "True" ) end elseif random == 4 then guiSetVisible(nyer, true) guiSetText(szveg, "Nyereményed: HALH.AUTÓ \n\nVárunk vissza 12 óra múlva. ;)\nHasználd egészséggel a nyereményed!") --guiSetVisible(GUIEditorwindow, false) local car = getPedOccupiedVehicle(localPlayer) if source == button3 then if isVehicleDamageProof(car) == false then setVehicleDamageProof(car, true) else if isVehicleDamageProof(car) == true then setVehicleDamageProof(car, false) end end end local currentState = guiGetProperty( GUIEditorgomb1, "Disabled" ) if currentState == "True" then guiSetProperty( GUIEditorgomb1, "Disabled", "True" ) else guiSetProperty( GUIEditorgomb1, "Disabled", "True" ) end elseif random == 5 then guiSetVisible(nyer, true) guiSetText(szveg, "Nyereményed: TANK \n\nVárunk vissza 12 óra múlva. ;)\nHasználd egészséggel a nyereményed!") --guiSetVisible(GUIEditorwindow, false) triggerServerEvent("tank",getLocalPlayer(),0,255,0,"Ezt a tankot addig használhatod amíg szeretnéd, vigyázz rá, mert 12 óráig nem kapsz újat.") local currentState = guiGetProperty( GUIEditorgomb1, "Disabled" ) if currentState == "True" then guiSetProperty( GUIEditorgomb1, "Disabled", "True" ) else guiSetProperty( GUIEditorgomb1, "Disabled", "True" ) end elseif random == 6 then group = "writing" triggerServerEvent("addToGroup", getLocalPlayer(), group) guiSetVisible(nyer, true) guiSetText(szveg, "Nyereményed: SZÍNESÍRÁS \n\nVárunk vissza 12 óra múlva. ;)\nHasználd egészséggel a nyereményed!") local currentState = guiGetProperty( GUIEditorgomb1, "Disabled" ) if currentState == "True" then guiSetProperty( GUIEditorgomb1, "Disabled", "True" ) else guiSetProperty( GUIEditorgomb1, "Disabled", "True" ) end elseif random == 7 then guiSetVisible(nyer, true) guiSetText(szveg, "Nyereményed: SEMMI! XD \n\nNe bánkódj!\n12 óra múlva hátha kapsz valamit! XD") local currentState = guiGetProperty( GUIEditorgomb1, "Disabled" ) if currentState == "True" then guiSetProperty( GUIEditorgomb1, "Disabled", "True" ) else guiSetProperty( GUIEditorgomb1, "Disabled", "True" ) end end end addEventHandler("onClientGUIClick", GUIEditorgomb1, tesztlel)
-
maybe you need this. takePlayerScreenShot onPlayerScreenShot
-
I don't know what are you trying to do with this code below. But if you want to draw dx on that client maybe try this code. Client: addEventHandler( "onClientRender", root, function () local localPlayer = getLocalPlayer() if getElementData(localPlayer, "OnDuty") then dxDrawTextOnElement(localPlayer,"]-Pie clan-[",1,30,255,255,255,255,3,"default-bold") end end ) function dxDrawTextOnElement(TheElement,text,height,distance,R,G,B,alpha,size,font) local distance = distance or 20 local height = height or 1 local x, y, z = getElementPosition(TheElement) local x2, y2, z2 = getCameraMatrix() local sx, sy = getScreenFromWorldPosition(x, y, z+height) if(sx) and (sy) then local distanceBetweenPoints = getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) if(distanceBetweenPoints < distance) then dxDrawText(text, sx+4, sy+4, sx, sy, tocolor(0, 0, 0, alpha or 255), (size or 1)-(distanceBetweenPoints / distance), font or "arial", "center", "center") dxDrawText(text, sx, sy, sx, sy, tocolor(R or 255, G or 255, B or 255, alpha or 255), (size or 1)-(distanceBetweenPoints / distance), font or "arial", "center", "center") end end end Server: function giveblood ( thePlayer ) if isObjectInACLGroup ( "user." ..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup ( "Admin") ) then if not getElementData(thePlayer, "OnDuty") then outputChatBox ("#1AFF00 Admin "..getPlayerName(thePlayer).."#1AFF00IS NOW - ON DUTY",root,255,255,255,true) setElementData(thePlayer, "blood",999999999) setElementData(thePlayer, "food",95) setElementData(thePlayer, "thirst",95) setElementData(thePlayer, "temperature",36.5) setElementData(thePlayer, "currentweapon_1",false) setElementData(thePlayer, "currentweapon_2",false) setElementData(thePlayer, "currentweapon_3",false) setElementData(thePlayer, "bleeding",false) setElementData(thePlayer, "brokenbone",false) setElementData(thePlayer, "pain",false) setElementData(thePlayer, "cold",false) setElementData(thePlayer, "bandit",false) setElementData(thePlayer, "humanity",2500) setElementData(thePlayer, "skin",210) setElementData(thePlayer, "OnDuty",true) end end end addCommandHandler("duty", giveblood) function bloodback(thePlayer) local account = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup("user." .. account, aclGetGroup("Admin,Moderator,Owner")) then end outputChatBox ("#FF0000 Admin "..getPlayerName(thePlayer).."#FF0000IS NOW - OFF DUTY",root,255,255,255,true) setElementData(thePlayer, "blood",12000) setElementData(thePlayer, "OnDuty",false) end addCommandHandler("offduty", bloodback)
-
This, will only loop for Online players. If there is no Online players on that group, the code won't work. --line 13 on your code for i, v in pairs ( getElementsByType ( 'player' ) ) do You need to directly add the money into database.
-
Just show me your full code
-
Try this. Client local mg = {} -- Store weapon on table function onEnter() local veh = getPedOccupiedVehicle(localPlayer) if getElementModel(veh) == 593 then toggleControl ( "brake_reverse", true ) triggerServerEvent ( "createMG_s", localPlayer, veh ) end end addEventHandler("onClientVehicleEnter", getRootElement(), onEnter) function onExit() local veh = getPedOccupiedVehicle(localPlayer) if getElementModel(veh) == 593 then triggerServerEvent ( "destroyMG_s", resourceRoot, veh ) end end addEventHandler("onClientVehicleStartExit", getRootElement(), onExit) -- If you want to add weapon on table function createMG(veh) local x,y,z = getElementPosition(veh) -- If there's any table on that Vehicle then store the weapon if mg[veh] then mg[veh]["mg1"] = createWeapon("m4", x,y,z+3) mg[veh]["mg2"] = createWeapon("m4", x,y,z+3) setWeaponFiringRate(mg[veh]["mg1"], 20) setWeaponFiringRate(mg[veh]["mg2"], 20) setWeaponClipAmmo(mg[veh]["mg1"], 99999) setWeaponClipAmmo(mg[veh]["mg2"], 99999) setWeaponState(mg[veh]["mg1"], "ready") setWeaponState(mg[veh]["mg2"], "ready") attachElements(mg[veh]["mg1"], veh, 2,0.7,-0.5,0,2,90) attachElements(mg[veh]["mg2"], veh, -1.9,0.7,-0.5,0,2,90) -- If no table on that vehicle then create the table for it and store the weapon else mg[veh] = {} mg[veh]["mg1"] = createWeapon("m4", x,y,z+3) mg[veh]["mg2"] = createWeapon("m4", x,y,z+3) setWeaponFiringRate(mg[veh]["mg1"], 20) setWeaponFiringRate(mg[veh]["mg2"], 20) setWeaponClipAmmo(mg[veh]["mg1"], 99999) setWeaponClipAmmo(mg[veh]["mg2"], 99999) setWeaponState(mg[veh]["mg1"], "ready") setWeaponState(mg[veh]["mg2"], "ready") attachElements(mg[veh]["mg1"], veh, 2,0.7,-0.5,0,2,90) attachElements(mg[veh]["mg2"], veh, -1.9,0.7,-0.5,0,2,90) end end addEvent( "createMG_c", true ) addEventHandler( "createMG_c", localPlayer, createMG ) -- If you want to destroy the weapon function destroyMG(veh) -- If there's any table on that Vehicle if mg[veh] then -- Check if the weapons are exists on table if mg[veh]["mg1"] and mg[veh]["mg2"] then -- Destroy the element destroyElement(mg[veh]["mg1"]) destroyElement(mg[veh]["mg2"]) -- Clear the table mg[veh] = nil end end end addEvent( "destroyMG_c", true ) addEventHandler( "destroyMG_c", localPlayer, destroyMG ) -- If you want to check all Weapon on table function showMeBaby(player) for k, v in pairs(mg) do outputChatBox("Weapon on Vehicle "..getVehicleName(k), player) for i, w in pairs(v) do outputChatBox(i, player) end end end addCommandHandler("showme", showMeBaby) Server function createMG_server(veh) triggerClientEvent ("createMG_c", getRootElement(), veh) end addEvent( "createMG_s", true ) addEventHandler( "createMG_s", getRootElement(), createMG_server ) function destroyMG_server(veh) triggerClientEvent ("destroyMG_c", getRootElement(), veh) end addEvent( "destroyMG_s", true ) addEventHandler( "destroyMG_s", getRootElement(), destroyMG_server )
-
You can't use table on setElementData. Read https://wiki.multitheftauto.com/wiki/Element_data The best way is using triggerClientEvent. Or if you really want to use setElementData. Only attach Country on Element Data, then declare another variable on Client Side. Server Side addEventHandler("onPlayerJoin", root, function() local country = exports.admin:getPlayerCountry(source) setElementData(source, "country", country) end) Client Side local country = getElementData(localPlayer, "country") local imgpath = ":admin/client/images/flags/"..country..".png"
-
That code above should work, it loops all the ID on DB and compare it with index, maybe the reason why the ID show up again is because you didn't insert the ID 2(after you get ID 2 as Valid ID) to database, so ID 2 still not exist on database and it show up again as valid ID.
-
Use percentage, that's simple math.
-
Use AUTO_INCREMENT on MySQL Example: CREATE TABLE `vehicles` ( `id` INT(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`) ) Or if you already have your own table, just set the default value to NOT NULL and AUTO_INCREMENT and set it as PRIMARY KEY. It will automatically generated new ID.
-
Read onColShapeHit