Jump to content

[HELP] GUI HEALTH WINDOW


Recommended Posts

Salam, mai ne ek script GUI phly khudd bna li hai aur ab mai es ko mazeed seekh raha hun

mai nay ek choti si script GUI k zariye banai thi jis se F2 press krny k baad ek gui panel khul

jata hai aur jab "SET HEALTH" ko click krain to health full ho jate hai, ye script chal nahi rahi mai

server.lua or client.lua yhan likh raha hun

server.lua

  
    function health() 
    setElementHealth(source, 100) 
    outputChatBox("you've been given health", source, 255, 0, 0) 
    end 
    addEvent("healthdata", true) 
    addEventHandler("healthdata", root, healthdata) 
  

client.lua

  
  
GUIEditor = { 
    button = {}, 
    window = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        GUIEditor.window[1] = guiCreateWindow(321, 197, 154, 140, "HEALTH PANEL", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
  
        GUIEditor.button[1] = guiCreateButton(10, 22, 134, 108, "GIVE HEALTH", false, GUIEditor.window[1])     
    end 
) 
    bindKey ( "F2", "down", 
        function ( ) 
            local state = ( not guiGetVisible (  GUIEditor.window[1] ) ) 
            guiSetVisible (  GUIEditor.window[1], state ) 
            showCursor ( state ) 
        end 
    ) 
  
    function health() 
        triggerServerEvent("healthdata", root, setElementHealth) 
    end 
    addEventHandler("onClientGUIClick", GUIEditor.button[1], health, false) 
  

shukriya.

Link to comment

Try this:

hp_wnd = guiCreateWindow(321, 197, 154, 140, "HEALTH PANEL", false) 
    guiWindowSetSizable(hp_wnd, false) 
hp_btn = guiCreateButton(10, 22, 134, 108, "GIVE HEALTH", false, hp_wnd) 
guiSetVisible(hp_wnd, false) 
  
bindKey ("F2", "down", 
    function () 
        local state = (not guiGetVisible(hp_wnd)) 
        guiSetVisible(hp_wnd, state) 
        showCursor(state) 
    end 
) 
  
function setHP() 
    local hp = getElementHealth(localPlayer) -- Get current HP. 
    if hp >= 100 then hp = 100 end -- A small fix for players with greater than 100 HP, like some have 200. 
    setElementHealth(localPlayer, hp+100) 
    outputChatBox("Your HP has been increased by 100.", 0, 200, 0) 
end 
addEventHandler("onClientGUIClick", hp_btn, setHP, false)  

Edited by Guest
Link to comment
Try this:
hp_wnd = guiCreateWindow(321, 197, 154, 140, "HEALTH PANEL", false) 
    guiWindowSetSizable(hp_wnd, false) 
hp_btn = guiCreateButton(10, 22, 134, 108, "GIVE HEALTH", false, hp_wnd)     
  
bindKey ("F2", "down", 
    function () 
        local state = (not guiGetVisible(hp_wnd)) 
        guiSetVisible(hp_wnd, state) 
        showCursor(state) 
    end 
) 
  
function setHP() 
    setElementHealth(localPlayer, 200) 
end 
addEventHandler("onClientGUIClick", hp_btn, health, false) 

Nai ye bilkul bhi nai work kre ga.

Is ko mene test kiya hai, kaam karta hai mera code.

client:

GUIEditor = { 
    button = {}, 
    window = {} 
} 
addEvent("showGui", true) 
addEventHandler("showGui", root, 
    function() 
        GUIEditor.window[1] = guiCreateWindow(321, 197, 154, 140, "HEALTH PANEL", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
  
        GUIEditor.button[1] = guiCreateButton(10, 22, 134, 108, "GIVE HEALTH", false, GUIEditor.window[1]) 
        showCursor(true)     
    end 
) 
  
function closeGui() 
         guiSetVisible(GUIEditor.window[1], false) 
         showCursor(false) 
end 
addEvent("closeTheGui", true) 
addEventHandler("closeTheGui", root, closeGui) 
  
function onGuiClick () 
if (source == GUIEditor.button[1]) then 
triggerServerEvent ("giveHealth", getLocalPlayer()) 
end 
end 
addEventHandler ("onClientGUIClick", getRootElement(), onGuiClick) 

server:

function showTheGui(thePlayer) 
         triggerClientEvent(thePlayer, "showGui", thePlayer) 
end 
addCommandHandler("openmenu", showTheGui) 
  
function giveHealthOnClick() 
         setElementHealth(source, 100) 
         outputChatBox("You've been given health!", source, 255, 0, 0) 
end 
addEvent("giveHealth", true) 
addEventHandler("giveHealth", getRootElement(), giveHealthOnClick) 
  
function closeGui(thePlayer)  
         triggerClientEvent(thePlayer, "closeTheGui", thePlayer) 
end 
addCommandHandler("closemenu", closeGui) 

Mere code ko gor se dekho aur tumhe samajh aa jai gi. Good luck.

Meu binds ke baare mein pakka nai hoon is liye aap /openmenu se open aur /closemenu se close kar sakte hain.

Edited by Guest
Link to comment
@ccv kiya aap mujhay batayen gey ke debugscript ne kiya error diya hai?

Mene aap ki script ko check nai kiya lekin aap ki script mein zaroor koi na koi error ho ga, aap khudi check kar ke dekh lo aur phir bata dena ke chali ya nai, lekin mere 100% work karti hai. Aap ko kuch cheezeu server side bhi karni parti hain bhai aur events ko jaga jaga trigger karna parta hai phir aap ki script smoothly chalti hai.

Link to comment
@ccv kiya aap mujhay batayen gey ke debugscript ne kiya error diya hai?

Mene aap ki script ko check nai kiya lekin aap ki script mein zaroor koi na koi error ho ga, aap khudi check kar ke dekh lo aur phir bata dena ke chali ya nai, lekin mere 100% work karti hai. Aap ko kuch cheezeu server side bhi karni parti hain bhai aur events ko jaga jaga trigger karna parta hai phir aap ki script smoothly chalti hai.

Phir smoothly nahi balkay server performance ko kharab karti hain:

Pehli baat, aap ka code raucously lengthy hai, in baton main:

- Hum addCommandHandler ko client side main bhi daal saktay hain, is se hamain server-to-client request ki zaroorat nahi hai.

- Hum setElementHealth wala function bhi client side par daal saktay hain kyun ke ye shared function hai + client-to-server request ki zaroorat nahi hai.

- Extra functions like closeGUI ko bhi serverside se call ki zaroorat nahi ho gi.

- Small tip: getLocalPlayer() ab old-age ho gya hai, is ki short form localPlayer hai jo kay ab zyada use hoti hai, dono same hain.

Also, aap ko mujhay hai 'smoothly' wali batein sikhao hi na, mera ecripting experience shayad aap se kam ho lekin maine aaj tak kisi se help nahi li aur meri scripts dekhi jayen to server ko 0.1% se zyada use nahi karti.

Haan meri script nahi chali ho gi kyun ke ye setElementHealth(localPlayer, 200) karti hai, is ko 100 karo aur check karo, phir sikhana mujhay scripting.

Link to comment
@ccv kiya aap mujhay batayen gey ke debugscript ne kiya error diya hai?

Mene aap ki script ko check nai kiya lekin aap ki script mein zaroor koi na koi error ho ga, aap khudi check kar ke dekh lo aur phir bata dena ke chali ya nai, lekin mere 100% work karti hai. Aap ko kuch cheezeu server side bhi karni parti hain bhai aur events ko jaga jaga trigger karna parta hai phir aap ki script smoothly chalti hai.

Phir smoothly nahi balkay server performance ko kharab karti hain:

Pehli baat, aap ka code raucously lengthy hai, in baton main:

- Hum addCommandHandler ko client side main bhi daal saktay hain, is se hamain server-to-client request ki zaroorat nahi hai.

- Hum setElementHealth wala function bhi client side par daal saktay hain kyun ke ye shared function hai + client-to-server request ki zaroorat nahi hai.

- Extra functions like closeGUI ko bhi serverside se call ki zaroorat nahi ho gi.

- Small tip: getLocalPlayer() ab old-age ho gya hai, is ki short form localPlayer hai jo kay ab zyada use hoti hai, dono same hain.

Also, aap ko mujhay hai 'smoothly' wali batein sikhao hi na, mera ecripting experience shayad aap se kam ho lekin maine aaj tak kisi se help nahi li aur meri scripts dekhi jayen to server ko 0.1% se zyada use nahi karti.

Haan meri script nahi chali ho gi kyun ke ye setElementHealth(localPlayer, 200) karti hai, is ko 100 karo aur check karo, phir sikhana mujhay scripting.

Aap bilkul theek keh rahe ho lekin is se aap to larai pe aa gai, mein pata nai kyun is post se offended feel kar raha hoon. Well mene aap ki woh wali cheez theek kar ke try kiya (mene 200 se 100 ko set kar diya) lekin phir bhi aap ki script kaam nai karti.

Debugscript 3: Expected function at argument 3 got nil. (16th line).

Link to comment

lol ye maine test nahi ki thi maine sirf Robin ki di hui ko edit kiya tha jis main ye bug reh gya, ab apni dekho aur meri try karo, apni ko dekho 48 lines long script hai jabke meri sirf 20 lines long, aur serverside ki zaroorat hi nahi hai, meri wali clientside par hi chalti hai.

Link to comment
lol ye maine test nahi ki thi maine sirf Robin ki di hui ko edit kiya tha jis main ye bug reh gya, ab apni dekho aur meri try karo, apni ko dekho 48 lines long script hai jabke meri sirf 20 lines long, aur serverside ki zaroorat hi nahi hai, meri wali clientside par hi chalti hai.

Serverside pe karne ka aik faida hai ke kisi ko bhi client cache se complete script nai milti. Agar aap saari cheez hi client side pe karo gay to koi bhi aap ki script ko easily steal kar le ga.

Link to comment
lol ye maine test nahi ki thi maine sirf Robin ki di hui ko edit kiya tha jis main ye bug reh gya, ab apni dekho aur meri try karo, apni ko dekho 48 lines long script hai jabke meri sirf 20 lines long, aur serverside ki zaroorat hi nahi hai, meri wali clientside par hi chalti hai.

Serverside pe karne ka aik faida hai ke kisi ko bhi client cache se complete script nai milti. Agar aap saari cheez hi client side pe karo gay to koi bhi aap ki script ko easily steal kar le ga.

Dafa maro stealers ko, dil bara rakho + compile bhi to kar saktay ho, maine jahan tak note kiya hai, script jitni choti ho utni sahi rehti hai, phir chahay wo sari client ho ya server.

Also, agar meri baatein bohat offended lageen to sorry lekin agli baar dheyan rakhna, kisi ki script mein koi bug ho to us par hasnay ke bijaye usay sahi karwana, mujhay tumhara 'Lol, lol, lol, lol' bohat offended laga tha lekin tum ne apni post edit kar ke sahi kar li, so maine bhi sorry bol diya :P

shukriya, dono chal rahi hain magar ryancit2 ki zyada easy hai
Koi baat nahi yar, anytime. btw tum ne wo OGClogin check kiya?
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...