Jump to content

there is something wrong :3!


Deep thinker

Recommended Posts

i have scripting a illegal weapon factory marker but i want to show a loading progress while creating a weapon ,i have scripted it and i have checked the debugscript log and there isn't something wrong ,also i wanna hide the hud and the radar 

--client
cwm = createMarker( 1983.65601, -2413.86963, 12.54688, "cylinder", 2, 150, 0, 75, 255 )
--this creates the marker
GUIEditor_Window = {}
GUIEditor_Button = {}
GUIEditor_Memo = {}
GUIEditor_Label = {}

GUIEditor_Window[1] = guiCreateWindow(0.2726,0.3275,0.3186,0.4537,"(Weapon Factory)",true)
   guiSetVisible ( GUIEditor_Window[1],false )
            showCursor ( false )           
guiSetAlpha(GUIEditor_Window[1],1)
GUIEditor_Memo[1] = guiCreateMemo(151,51,199,46,"On button click you will w\nait for 20 second to create M4",false,GUIEditor_Window[1])
guiMemoSetReadOnly(GUIEditor_Memo[1],true)
GUIEditor_Memo[2] = guiCreateMemo(151,99,202,46,"On button click you will wait for 20 second to create AK-47",false,GUIEditor_Window[1])
guiMemoSetReadOnly(GUIEditor_Memo[2],true)
GUIEditor_Button[1] = guiCreateButton(16,59,130,41,"100M4 for 150$",false,GUIEditor_Window[1])
GUIEditor_Button[2] = guiCreateButton(15,105,130,41,"100AK-47 for 150$",false,GUIEditor_Window[1])
GUIEditor_Button[3] = guiCreateButton(17,152,130,41,"18 Gernades for 150$",false,GUIEditor_Window[1])
GUIEditor_Memo[3] = guiCreateMemo(150,148,202,46,"On button click you will wait for 20 second to create Gernade",false,GUIEditor_Window[1])
guiMemoSetReadOnly(GUIEditor_Memo[3],true)
GUIEditor_Memo[4] = guiCreateMemo(150,195,202,46,"On button click you will wait for 20 second to create Rifle",false,GUIEditor_Window[1])
guiMemoSetReadOnly(GUIEditor_Memo[4],true)
GUIEditor_Button[4] = guiCreateButton(17,197,130,41,"75 Rifle for 150$",false,GUIEditor_Window[1])
GUIEditor_Memo[5] = guiCreateMemo(150,243,202,46,"On button click you will wait for 20 second to create Sniper",false,GUIEditor_Window[1])
guiMemoSetReadOnly(GUIEditor_Memo[5],true)
GUIEditor_Button[5] = guiCreateButton(18,246,130,41,"75 Sniper for 150$",false,GUIEditor_Window[1])
GUIEditor_Memo[6] = guiCreateMemo(151,290,202,46,"On button click you will wait for 20 second to create UZI",false,GUIEditor_Window[1])
guiMemoSetReadOnly(GUIEditor_Memo[6],true)
GUIEditor_Button[6] = guiCreateButton(20,293,130,41,"200 UZI for 150$",false,GUIEditor_Window[1])
GUIEditor_Memo[7] = guiCreateMemo(150,337,202,46,"On button click you will wait for 20 second to create C.shotgun",false,GUIEditor_Window[1])
GUIEditor_Button[7] = guiCreateButton(18,340,130,41,"200 C.shotgun for 150$",false,GUIEditor_Window[1])
GUIEditor_Label[1] = guiCreateLabel(24,30,324,20,"Regards,(T-RPG)ProMax",false,GUIEditor_Window[1])
guiLabelSetColor(GUIEditor_Label[1],150,0,150)
GUIEditor_Button[11] = guiCreateButton(298,20,55,26,"Close",false,GUIEditor_Window[1])
--creates the GUI 
function ToggleCWMMenu ( hit )
  if ( hit and hit == localPlayer ) then 
  if eventName == "onClientMarkerHit" then
                    guiSetVisible ( GUIEditor_Window[1],true )
                    showCursor ( true )
                    showChat ( false )
                    showHud ( false )
                    showRadar ( false )
                    elseif eventName == "onClientMarkerLeave" then 
                    guiSetVisible ( GUIEditor_Window[1],false )
                    showCursor ( false )
                    showChat ( true )
                    showHud ( true )
                    showRadar ( true )
                    -- shows the chat and  i don't know what about the hud
            end
        end
    end
addEventHandler("onClientMarkerHit",cwm,ToggleCWMMenu)
addEventHandler("onClientMarkerLeave",cwm,ToggleCWMMenu)
addEventHandler ('onClientGUIClick',GUIEditor_Button[11],   -- that was the closing button
    function (  )
            guiSetVisible ( GUIEditor_Window[1],false )
            showCursor ( false )
            showChat ( true )
            showRadar ( true )
            showHud ( true )
    end,false
)
--rest of buttons
addEventHandler ('onClientGUIClick',GUIEditor_Button[1],
function ()
           guiSetVisible ( GUIEditor_Window[1],false )
            showCursor ( false )
            showChat ( true )
            triggerServerEvent ("GiveM4",localPlayer)
    end,false
)
--then the second part 
function drawStaticBar()
    dxDrawRectangle((sx/2)-270, (sy/2)-22, 540.0, 44.0, tocolor(255,197,0,150), false)
    dxDrawRectangle((sx/2)-265, (sy/2)-16, 530.0, 33.0, tocolor(0,0,0,250), false)
end

function drawLoadingBar()
    if (tonumber(createPercent) >= 100) then
        removeEventHandler("onClientRender", root, drawStaticBar)
        removeEventHandler("onClientRender", root, drawLoadingBar)
        showCursor(false)
        guiSetInputEnabled(false)
    else
    dxDrawRectangle((sx/2)-261, (sy/2)-12, tonumber(createPercent)*5.22, 25.0, tocolor(0,0,235,255), true)
    end
    dxDrawBorderedText("Creating... "..tostring(createPercent).."%", (sx/2)-145, (sy/2)-15, (sy/2)-1, (sx/2)-5, tocolor(0,255,0,255),1.0,"bankgothic","left","top",false,false,true)
end


addEvent("creating",true)
addEventHandler("creating",root,
function (weaponName)
    name = tostring(weaponName)
    if isTimer(createTimer) then killTimer(createTimer) end
    trainPercent = 0
    showCursor(true)
    guiSetInputEnabled(true)
    trainTimer = setTimer(function () createPercent = createPercent +1 end, 100, 100)
    addEventHandler("onClientRender",getRootElement(),drawLoadingBar)
    addEventHandler("onClientRender",getRootElement(),drawStaticBar)
end)

--Server 


-- starting with the Event that i tiggered in the Client side
addEvent ('GiveM4',true)
addEventHandler ('GiveM4',root,
-- then i don;t know what to do:3        
function () 
if not getPlayerTeam(source) or getPlayerTeam(source) ~= getTeamFromName("Criminal") then return outputChatBox( 'You are not a criminal to create weapons',source,255,0,0 ) end   
    if getPlayerMoney(source) or getPlayerMoney(source) >= 150 then 
    triggerClientEvent(player,"creating",player,weaponName)
    setTimer( 
        function ()
        giveWeapon(client,31,100)
        end,false
        ,1000,1,client )
    takePlayerMoney(client,150)
    else
        outputChatBox('You do not have enough money to create this weapon', 255, 0, 0 )
    end
end
)    

please answer as soon as possible ,I am on fire :3.

Link to comment
--client
cwm = createMarker( 1983.65601, -2413.86963, 12.54688, "cylinder", 2, 150, 0, 75, 255 )
--this creates the marker
GUIEditor_Window = {}
GUIEditor_Button = {}
GUIEditor_Memo = {}
GUIEditor_Label = {}

GUIEditor_Window[1] = guiCreateWindow(0.2726,0.3275,0.3186,0.4537,"(Weapon Factory)",true)
   guiSetVisible ( GUIEditor_Window[1],false )
            showCursor ( false )           
guiSetAlpha(GUIEditor_Window[1],1)
GUIEditor_Memo[1] = guiCreateMemo(151,51,199,46,"On button click you will w\nait for 20 second to create M4",false,GUIEditor_Window[1])
guiMemoSetReadOnly(GUIEditor_Memo[1],true)
GUIEditor_Memo[2] = guiCreateMemo(151,99,202,46,"On button click you will wait for 20 second to create AK-47",false,GUIEditor_Window[1])
guiMemoSetReadOnly(GUIEditor_Memo[2],true)
GUIEditor_Button[1] = guiCreateButton(16,59,130,41,"100M4 for 150$",false,GUIEditor_Window[1])
GUIEditor_Button[2] = guiCreateButton(15,105,130,41,"100AK-47 for 150$",false,GUIEditor_Window[1])
GUIEditor_Button[3] = guiCreateButton(17,152,130,41,"18 Gernades for 150$",false,GUIEditor_Window[1])
GUIEditor_Memo[3] = guiCreateMemo(150,148,202,46,"On button click you will wait for 20 second to create Gernade",false,GUIEditor_Window[1])
guiMemoSetReadOnly(GUIEditor_Memo[3],true)
GUIEditor_Memo[4] = guiCreateMemo(150,195,202,46,"On button click you will wait for 20 second to create Rifle",false,GUIEditor_Window[1])
guiMemoSetReadOnly(GUIEditor_Memo[4],true)
GUIEditor_Button[4] = guiCreateButton(17,197,130,41,"75 Rifle for 150$",false,GUIEditor_Window[1])
GUIEditor_Memo[5] = guiCreateMemo(150,243,202,46,"On button click you will wait for 20 second to create Sniper",false,GUIEditor_Window[1])
guiMemoSetReadOnly(GUIEditor_Memo[5],true)
GUIEditor_Button[5] = guiCreateButton(18,246,130,41,"75 Sniper for 150$",false,GUIEditor_Window[1])
GUIEditor_Memo[6] = guiCreateMemo(151,290,202,46,"On button click you will wait for 20 second to create UZI",false,GUIEditor_Window[1])
guiMemoSetReadOnly(GUIEditor_Memo[6],true)
GUIEditor_Button[6] = guiCreateButton(20,293,130,41,"200 UZI for 150$",false,GUIEditor_Window[1])
GUIEditor_Memo[7] = guiCreateMemo(150,337,202,46,"On button click you will wait for 20 second to create C.shotgun",false,GUIEditor_Window[1])
GUIEditor_Button[7] = guiCreateButton(18,340,130,41,"200 C.shotgun for 150$",false,GUIEditor_Window[1])
GUIEditor_Label[1] = guiCreateLabel(24,30,324,20,"Regards,(T-RPG)ProMax",false,GUIEditor_Window[1])
guiLabelSetColor(GUIEditor_Label[1],150,0,150)
GUIEditor_Button[11] = guiCreateButton(298,20,55,26,"Close",false,GUIEditor_Window[1])
--creates the GUI 
function ToggleCWMMenu ( hit )
  if ( hit and hit == localPlayer ) then 
  if eventName == "onClientMarkerHit" then
                    guiSetVisible ( GUIEditor_Window[1],true )
                    showCursor ( true )
                    showChat ( false )
                    showPlayerHudComponent("weapon", false)
                    showPlayerHudComponent("radar", false)
                    elseif eventName == "onClientMarkerLeave" then 
                    guiSetVisible ( GUIEditor_Window[1],false )
                    showCursor ( false )
                    showChat ( true )
                    showPlayerHudComponent("weapon", true)
                    showPlayerHudComponent("radar", true)
                    -- shows the chat and  i don't know what about the hud
            end
        end
    end
addEventHandler("onClientMarkerHit",cwm,ToggleCWMMenu)
addEventHandler("onClientMarkerLeave",cwm,ToggleCWMMenu)
addEventHandler ('onClientGUIClick',GUIEditor_Button[11],   -- that was the closing button
    function (  )
            guiSetVisible ( GUIEditor_Window[1],false )
            showCursor ( false )
            showChat ( true )
            showPlayerHudComponent("weapon", true)
            showPlayerHudComponent("radar", true)
    end,false
)
--rest of buttons
addEventHandler ('onClientGUIClick',GUIEditor_Button[1],
function ()
           guiSetVisible ( GUIEditor_Window[1],false )
            showCursor ( false )
            showChat ( true )
            triggerServerEvent ("GiveM4",localPlayer)
    end,false
)
--then the second part 
function drawStaticBar()
    dxDrawRectangle((sx/2)-270, (sy/2)-22, 540.0, 44.0, tocolor(255,197,0,150), false)
    dxDrawRectangle((sx/2)-265, (sy/2)-16, 530.0, 33.0, tocolor(0,0,0,250), false)
end

function drawLoadingBar()
    if (tonumber(createPercent) >= 100) then
        removeEventHandler("onClientRender", root, drawStaticBar)
        removeEventHandler("onClientRender", root, drawLoadingBar)
        showCursor(false)
        guiSetInputEnabled(false)
    else
    dxDrawRectangle((sx/2)-261, (sy/2)-12, tonumber(createPercent)*5.22, 25.0, tocolor(0,0,235,255), true)
    end
    dxDrawBorderedText("Creating... "..tostring(createPercent).."%", (sx/2)-145, (sy/2)-15, (sy/2)-1, (sx/2)-5, tocolor(0,255,0,255),1.0,"bankgothic","left","top",false,false,true)
end


addEvent("creating",true)
addEventHandler("creating",root,
function (weaponName)
    name = tostring(weaponName)
    if isTimer(createTimer) then killTimer(createTimer) end
    trainPercent = 0
    showCursor(true)
    guiSetInputEnabled(true)
    trainTimer = setTimer(function () createPercent = createPercent +1 end, 100, 100)
    addEventHandler("onClientRender",getRootElement(),drawLoadingBar)
    addEventHandler("onClientRender",getRootElement(),drawStaticBar)
end)

 

  • Like 1
Link to comment
--client
cwm = createMarker( 1983.65601, -2413.86963, 12.54688, "cylinder", 2, 150, 0, 75, 255 )
--this creates the marker
GUIEditor_Window = {}
GUIEditor_Button = {}
GUIEditor_Memo = {}
GUIEditor_Label = {}

GUIEditor_Window[1] = guiCreateWindow(0.2726,0.3275,0.3186,0.4537,"(Weapon Factory)",true)
   guiSetVisible ( GUIEditor_Window[1],false )
            showCursor ( false )           
guiSetAlpha(GUIEditor_Window[1],1)
GUIEditor_Memo[1] = guiCreateMemo(151,51,199,46,"On button click you will w\nait for 20 second to create M4",false,GUIEditor_Window[1])
guiMemoSetReadOnly(GUIEditor_Memo[1],true)
GUIEditor_Memo[2] = guiCreateMemo(151,99,202,46,"On button click you will wait for 20 second to create AK-47",false,GUIEditor_Window[1])
guiMemoSetReadOnly(GUIEditor_Memo[2],true)
GUIEditor_Button[1] = guiCreateButton(16,59,130,41,"100M4 for 150$",false,GUIEditor_Window[1])
GUIEditor_Button[2] = guiCreateButton(15,105,130,41,"100AK-47 for 150$",false,GUIEditor_Window[1])
GUIEditor_Button[3] = guiCreateButton(17,152,130,41,"18 Gernades for 150$",false,GUIEditor_Window[1])
GUIEditor_Memo[3] = guiCreateMemo(150,148,202,46,"On button click you will wait for 20 second to create Gernade",false,GUIEditor_Window[1])
guiMemoSetReadOnly(GUIEditor_Memo[3],true)
GUIEditor_Memo[4] = guiCreateMemo(150,195,202,46,"On button click you will wait for 20 second to create Rifle",false,GUIEditor_Window[1])
guiMemoSetReadOnly(GUIEditor_Memo[4],true)
GUIEditor_Button[4] = guiCreateButton(17,197,130,41,"75 Rifle for 150$",false,GUIEditor_Window[1])
GUIEditor_Memo[5] = guiCreateMemo(150,243,202,46,"On button click you will wait for 20 second to create Sniper",false,GUIEditor_Window[1])
guiMemoSetReadOnly(GUIEditor_Memo[5],true)
GUIEditor_Button[5] = guiCreateButton(18,246,130,41,"75 Sniper for 150$",false,GUIEditor_Window[1])
GUIEditor_Memo[6] = guiCreateMemo(151,290,202,46,"On button click you will wait for 20 second to create UZI",false,GUIEditor_Window[1])
guiMemoSetReadOnly(GUIEditor_Memo[6],true)
GUIEditor_Button[6] = guiCreateButton(20,293,130,41,"200 UZI for 150$",false,GUIEditor_Window[1])
GUIEditor_Memo[7] = guiCreateMemo(150,337,202,46,"On button click you will wait for 20 second to create C.shotgun",false,GUIEditor_Window[1])
GUIEditor_Button[7] = guiCreateButton(18,340,130,41,"200 C.shotgun for 150$",false,GUIEditor_Window[1])
GUIEditor_Label[1] = guiCreateLabel(24,30,324,20,"Regards,(T-RPG)ProMax",false,GUIEditor_Window[1])
guiLabelSetColor(GUIEditor_Label[1],150,0,150)
GUIEditor_Button[11] = guiCreateButton(298,20,55,26,"Close",false,GUIEditor_Window[1])
--creates the GUI 
function ToggleCWMMenu ( hit )
  if ( hit and hit == localPlayer ) then 
  if eventName == "onClientMarkerHit" then
                    guiSetVisible ( GUIEditor_Window[1],true )
                    showCursor ( true )
                    showChat ( false )
                    showPlayerHudComponent("weapon", false)
                    showPlayerHudComponent("radar", false)
                    elseif eventName == "onClientMarkerLeave" then 
                    guiSetVisible ( GUIEditor_Window[1],false )
                    showCursor ( false )
                    showChat ( true )
                    showPlayerHudComponent("weapon", true)
                    showPlayerHudComponent("radar", true)
                    -- shows the chat and  i don't know what about the hud
            end
        end
    end
addEventHandler("onClientMarkerHit",cwm,ToggleCWMMenu)
addEventHandler("onClientMarkerLeave",cwm,ToggleCWMMenu)
addEventHandler ('onClientGUIClick',GUIEditor_Button[11],   -- that was the closing button
    function (  )
            guiSetVisible ( GUIEditor_Window[1],false )
            showCursor ( false )
            showChat ( true )
            showPlayerHudComponent("weapon", true)
            showPlayerHudComponent("radar", true)
    end,false
)
--rest of buttons
addEventHandler ('onClientGUIClick',GUIEditor_Button[1],
function ()
           guiSetVisible ( GUIEditor_Window[1],false )
            showCursor ( false )
            showChat ( true )
            triggerServerEvent ("GiveM4",localPlayer)
    end,false
)
--then the second part 
function drawStaticBar()
    dxDrawRectangle((sx/2)-270, (sy/2)-22, 540.0, 44.0, tocolor(255,197,0,150), false)
    dxDrawRectangle((sx/2)-265, (sy/2)-16, 530.0, 33.0, tocolor(0,0,0,250), false)
end

function drawLoadingBar()
    if (tonumber(createPercent) >= 100) then
        removeEventHandler("onClientRender", root, drawStaticBar)
        removeEventHandler("onClientRender", root, drawLoadingBar)
        showCursor(false)
        guiSetInputEnabled(false)
    else
    dxDrawRectangle((sx/2)-261, (sy/2)-12, tonumber(createPercent)*5.22, 25.0, tocolor(0,0,235,255), true)
    end
    dxDrawBorderedText("Creating... "..tostring(createPercent).."%", (sx/2)-145, (sy/2)-15, (sy/2)-1, (sx/2)-5, tocolor(0,255,0,255),1.0,"bankgothic","left","top",false,false,true)
end


addEvent("creating",true)
addEventHandler("creating",root,
function (weaponName)
    name = tostring(weaponName)
    if isTimer(createTimer) then killTimer(createTimer) end
    trainPercent = 0
    showCursor(true)
    guiSetInputEnabled(true)
    trainTimer = setTimer(function () createPercent = createPercent +1 end, 100, 100)
    addEventHandler("onClientRender",getRootElement(),drawLoadingBar)
    addEventHandler("onClientRender",getRootElement(),drawStaticBar)
    if tonumber(createPercent) == 100 then
       showPlayerHudComponent("weapon", true)
    else
        showPlayerHudComponent("weapon", false)
        showPlayerHudComponent("radar", false)
    end
end)

 

Edited by Dimos7
Link to comment

reset server side to this

addEvent ('GiveM4',true)
addEventHandler ('GiveM4',root,
    
	function (	) 

	if not getPlayerTeam( source ) or getPlayerTeam ( source ) ~= getTeamFromName("Criminal") then return outputChatBox( 'You are not a criminal to create weapons',source,255,0,0 ) end   
 
	if getPlayerMoney ( source ) >= 150 then 

	setTimer ( giveWeapon , 1000 , 1 , source , 31 , 100 , true )

    triggerClientEvent( source ,"creating", source , getWeaponNameFromID ( 31 ) )	
	
    takePlayerMoney( source ,150 )
	
    else
	
	outputChatBox('You do not have enough money to create this weapon', source , 255, 0, 0 )
	
		end
	end
	)    

 

Edited by Abdul KariM
Link to comment

when i learn to make M4 then i will know how to make the rest ":3

Just now, Abdul KariM said:

reset server side to this


addEvent ('GiveM4',true)
addEventHandler ('GiveM4',root,
    
	function (	) 

	if not getPlayerTeam( source ) or getPlayerTeam ( source ) ~= getTeamFromName("Criminal") then return outputChatBox( 'You are not a criminal to create weapons',source,255,0,0 ) end   
 
	if getPlayerMoney ( source ) >= 150 then 

	setTimer ( giveWeapon , 1000 , 1 , source 31 , 100 , true )

    triggerClientEvent( source ,"creating", source , getWeaponNameFromID ( 31 ) )	
	
    takePlayerMoney( source ,150 )
	
    else
	
	outputChatBox('You do not have enough money to create this weapon', 255, 0, 0 )
	
		end
	end
	)    

 

this part has a lot of bugs in debugscript log 

not working

Link to comment

reset this code to your code 

addEvent("creating",true)
addEventHandler("creating",root,
function (weaponName)
    name = tostring(weaponName)
    if isTimer(trainTimer) then killTimer(trainTimer) end
    createPercent = 0
    showCursor(true)
    guiSetInputEnabled(true)
    trainTimer = setTimer(function () createPercent = createPercent +1 end, 100, 0)
    addEventHandler("onClientRender",getRootElement(),drawLoadingBar)
    addEventHandler("onClientRender",getRootElement(),drawStaticBar)
    if tonumber(createPercent) >= 100 then
       showPlayerHudComponent("weapon", true)
    else
        showPlayerHudComponent("weapon", false)
        showPlayerHudComponent("radar", false)
    end
end)

 

Edited by Abdul KariM
Link to comment

what about this, i think the bug is over here 

function drawStaticBar()
    dxDrawRectangle((sx/2)-270, (sy/2)-22, 540.0, 44.0, tocolor(255,197,0,150), false)
    dxDrawRectangle((sx/2)-265, (sy/2)-16, 530.0, 33.0, tocolor(0,0,0,250), false)
end

function drawLoadingBar()
    if (tonumber(createPercent) >= 100) then
        removeEventHandler("onClientRender", root, drawStaticBar)
        removeEventHandler("onClientRender", root, drawLoadingBar)
        showCursor(false)
        guiSetInputEnabled(false)
    else
    dxDrawRectangle((sx/2)-261, (sy/2)-12, tonumber(createPercent)*5.22, 25.0, tocolor(0,0,235,255), true)
    end
    dxDrawBorderedText("Creating... "..tostring(createPercent).."%", (sx/2)-145, (sy/2)-15, (sy/2)-1, (sx/2)-5, tocolor(0,255,0,255),1.0,"bankgothic","left","top",false,false,true)
end

 

Link to comment

Client : 

--client
cwm = createMarker( 1983.65601, -2413.86963, 12.54688, "cylinder", 2, 150, 0, 75, 255 )
--this creates the marker
GUIEditor_Window = {}
GUIEditor_Button = {}
GUIEditor_Memo = {}
GUIEditor_Label = {}

GUIEditor_Window[1] = guiCreateWindow(0.2726,0.3275,0.3186,0.4537,"(Weapon Factory)",true)
   guiSetVisible ( GUIEditor_Window[1],false )
            showCursor ( false )           
guiSetAlpha(GUIEditor_Window[1],1)
GUIEditor_Memo[1] = guiCreateMemo(151,51,199,46,"On button click you will w\nait for 20 second to create M4",false,GUIEditor_Window[1])
guiMemoSetReadOnly(GUIEditor_Memo[1],true)
GUIEditor_Memo[2] = guiCreateMemo(151,99,202,46,"On button click you will wait for 20 second to create AK-47",false,GUIEditor_Window[1])
guiMemoSetReadOnly(GUIEditor_Memo[2],true)
GUIEditor_Button[1] = guiCreateButton(16,59,130,41,"100M4 for 150$",false,GUIEditor_Window[1])
GUIEditor_Button[2] = guiCreateButton(15,105,130,41,"100AK-47 for 150$",false,GUIEditor_Window[1])
GUIEditor_Button[3] = guiCreateButton(17,152,130,41,"18 Gernades for 150$",false,GUIEditor_Window[1])
GUIEditor_Memo[3] = guiCreateMemo(150,148,202,46,"On button click you will wait for 20 second to create Gernade",false,GUIEditor_Window[1])
guiMemoSetReadOnly(GUIEditor_Memo[3],true)
GUIEditor_Memo[4] = guiCreateMemo(150,195,202,46,"On button click you will wait for 20 second to create Rifle",false,GUIEditor_Window[1])
guiMemoSetReadOnly(GUIEditor_Memo[4],true)
GUIEditor_Button[4] = guiCreateButton(17,197,130,41,"75 Rifle for 150$",false,GUIEditor_Window[1])
GUIEditor_Memo[5] = guiCreateMemo(150,243,202,46,"On button click you will wait for 20 second to create Sniper",false,GUIEditor_Window[1])
guiMemoSetReadOnly(GUIEditor_Memo[5],true)
GUIEditor_Button[5] = guiCreateButton(18,246,130,41,"75 Sniper for 150$",false,GUIEditor_Window[1])
GUIEditor_Memo[6] = guiCreateMemo(151,290,202,46,"On button click you will wait for 20 second to create UZI",false,GUIEditor_Window[1])
guiMemoSetReadOnly(GUIEditor_Memo[6],true)
GUIEditor_Button[6] = guiCreateButton(20,293,130,41,"200 UZI for 150$",false,GUIEditor_Window[1])
GUIEditor_Memo[7] = guiCreateMemo(150,337,202,46,"On button click you will wait for 20 second to create C.shotgun",false,GUIEditor_Window[1])
GUIEditor_Button[7] = guiCreateButton(18,340,130,41,"200 C.shotgun for 150$",false,GUIEditor_Window[1])
GUIEditor_Label[1] = guiCreateLabel(24,30,324,20,"Regards,(T-RPG)ProMax",false,GUIEditor_Window[1])
guiLabelSetColor(GUIEditor_Label[1],150,0,150)
GUIEditor_Button[11] = guiCreateButton(298,20,55,26,"Close",false,GUIEditor_Window[1])
--creates the GUI 
function ToggleCWMMenu ( hit )
  if ( hit and hit == localPlayer ) then 
  if eventName == "onClientMarkerHit" then
                    guiSetVisible ( GUIEditor_Window[1],true )
                    showCursor ( true )
                    showChat ( false )
                    showPlayerHudComponent("weapon", false)
                    showPlayerHudComponent("radar", false)
                    elseif eventName == "onClientMarkerLeave" then 
                    guiSetVisible ( GUIEditor_Window[1],false )
                    showCursor ( false )
                    showChat ( true )
                    showPlayerHudComponent("weapon", true)
                    showPlayerHudComponent("radar", true)
                    -- shows the chat and  i don't know what about the hud
            end
        end
    end
addEventHandler("onClientMarkerHit",cwm,ToggleCWMMenu)
addEventHandler("onClientMarkerLeave",cwm,ToggleCWMMenu)
addEventHandler ('onClientGUIClick',GUIEditor_Button[11],   -- that was the closing button
    function (  )
            guiSetVisible ( GUIEditor_Window[1],false )
            showCursor ( false )
            showChat ( true )
            showPlayerHudComponent("weapon", true)
            showPlayerHudComponent("radar", true)
    end,false
)
--rest of buttons
addEventHandler ('onClientGUIClick',GUIEditor_Button[1],
function ()
           guiSetVisible ( GUIEditor_Window[1],false )
            showCursor ( false )
            showChat ( true )
            triggerServerEvent ("GiveM4",localPlayer)
    end,false

	)

local sx , sy = guiGetScreenSize (	)
	
--then the second part 
function drawStaticBar()
    dxDrawRectangle((sx/2)-270, (sy/2)-22, 540.0, 44.0, tocolor(255,197,0,150), false)
    dxDrawRectangle((sx/2)-265, (sy/2)-16, 530.0, 33.0, tocolor(0,0,0,250), false)
end

function drawLoadingBar()
    if (tonumber(createPercent) >= 100) then
        removeEventHandler("onClientRender", root, drawStaticBar)
        removeEventHandler("onClientRender", root, drawLoadingBar)
        showCursor(false)
        guiSetInputEnabled(false)
    else
    dxDrawRectangle((sx/2)-261, (sy/2)-12, tonumber(createPercent)*5.22, 25.0, tocolor(0,0,235,255), true)
    end
    dxDrawBorderedText("Creating... "..tostring(createPercent).."%", (sx/2)-145, (sy/2)-15, (sy/2)-1, (sx/2)-5, tocolor(0,255,0,255),1.0,"bankgothic","left","top",false,false,true)
end


addEvent("creating",true)
addEventHandler("creating",root,
function (weaponName)
    name = tostring(weaponName)
    if isTimer(trainTimer) then killTimer(trainTimer) end
    createPercent = 0
    showCursor(true)
    guiSetInputEnabled(true)
    trainTimer = setTimer(function () createPercent = createPercent +1 end, 100, 0)
    addEventHandler("onClientRender",getRootElement(),drawLoadingBar)
    addEventHandler("onClientRender",getRootElement(),drawStaticBar)
    if tonumber(createPercent) >= 100 then
       showPlayerHudComponent("weapon", true)
    else
        showPlayerHudComponent("weapon", false)
        showPlayerHudComponent("radar", false)
    end
end)

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...