Jump to content

Help With Gui Script


Evil-Cod3r

Recommended Posts

Hi iam Making a War Shop Panel but it has Problem client triggerd server side but client is not add server side

clientSide ..

  
GUIEditor_Window = {} 
GUIEditor_TabPanel = {} 
GUIEditor_Tab = {} 
GUIEditor_Button = {} 
GUIEditor_Label = {} 
GUIEditor_Image = {} 
  
GUIEditor_Window[1] = guiCreateWindow(255,151,638,373,"War_Panel By Evil-Cod3r v1.0",false) 
guiWindowSetMovable(GUIEditor_Window[1],false) 
guiWindowSetSizable(GUIEditor_Window[1],false) 
GUIEditor_TabPanel[1] = guiCreateTabPanel(9,23,620,341,false,GUIEditor_Window[1]) 
GUIEditor_Tab[1] = guiCreateTab("Weapons",GUIEditor_TabPanel[1]) 
GUIEditor_Image[1] = guiCreateStaticImage(0,0,143,81,"images/1.png",false,GUIEditor_Tab[1]) 
GUIEditor_Button[1] = guiCreateButton(6,87,139,29,"Desert Eagle",false,GUIEditor_Tab[1]) 
guiSetFont(GUIEditor_Button[1],"clear-normal") 
GUIEditor_Label[1] = guiCreateLabel(8,126,179,18,"Buy Desert Eagle For $120 ?",false,GUIEditor_Tab[1]) 
guiLabelSetColor(GUIEditor_Label[1],0,255,0) 
guiSetFont(GUIEditor_Label[1],"clear-normal") 
GUIEditor_Image[2] = guiCreateStaticImage(243,3,177,92,"images/2.png",false,GUIEditor_Tab[1]) 
GUIEditor_Button[2] = guiCreateButton(245,97,150,28,"M-4",false,GUIEditor_Tab[1]) 
guiSetFont(GUIEditor_Button[2],"clear-normal") 
GUIEditor_Label[2] = guiCreateLabel(243,130,175,22,"Buy M-4 For $ 250 ?",false,GUIEditor_Tab[1]) 
guiLabelSetColor(GUIEditor_Label[2],255,0,0) 
guiSetFont(GUIEditor_Label[2],"clear-normal") 
GUIEditor_Image[3] = guiCreateStaticImage(392,138,215,65,"images/3.png",false,GUIEditor_Tab[1]) 
GUIEditor_Button[3] = guiCreateButton(410,205,148,25,"Sniper",false,GUIEditor_Tab[1]) 
guiSetFont(GUIEditor_Button[3],"clear-normal") 
GUIEditor_Label[3] = guiCreateLabel(406,241,178,20,"Buy Sniper For $320 ?",false,GUIEditor_Tab[1]) 
guiLabelSetColor(GUIEditor_Label[3],255,0,255) 
guiSetFont(GUIEditor_Label[3],"clear-normal") 
GUIEditor_Image[4] = guiCreateStaticImage(11,172,369,128,"images/mtalogo.png",false,GUIEditor_Tab[1]) 
GUIEditor_Tab[2] = guiCreateTab("Shop",GUIEditor_TabPanel[1]) 
GUIEditor_Image[5] = guiCreateStaticImage(24,26,207,66,"images/4.png",false,GUIEditor_Tab[2]) 
GUIEditor_Button[4] = guiCreateButton(36,101,165,34,"Armor",false,GUIEditor_Tab[2]) 
guiSetFont(GUIEditor_Button[4],"clear-normal") 
GUIEditor_Label[4] = guiCreateLabel(33,148,154,22,"Buy Armor $ 2500 ?",false,GUIEditor_Tab[2]) 
guiLabelSetColor(GUIEditor_Label[4],0,0,255) 
guiSetFont(GUIEditor_Label[4],"clear-normal") 
GUIEditor_Image[6] = guiCreateStaticImage(316,21,227,78,"images/5.png",false,GUIEditor_Tab[2]) 
GUIEditor_Button[5] = guiCreateButton(332,106,173,33,"Health",false,GUIEditor_Tab[2]) 
guiSetFont(GUIEditor_Button[5],"clear-normal") 
GUIEditor_Label[5] = guiCreateLabel(330,154,158,22,"Buy Health For $ 1500 ?",false,GUIEditor_Tab[2]) 
guiLabelSetColor(GUIEditor_Label[5],0,255,255) 
guiSetFont(GUIEditor_Label[5],"clear-normal") 
GUIEditor_Image[7] = guiCreateStaticImage(19,187,530,116,"images/mtalogo.png",false,GUIEditor_Tab[2]) 
GUIEditor_Image[8] = guiCreateStaticImage(646,15,0,5,"images/3.png",false,GUIEditor_Window[1]) 
  
addEventHandler ("onClientGUIClick", getRootElement(), 
function(button, state, absoluteX, absoluteY) 
    if ( source == GUIEditor_Button[1] ) then 
    triggerServerEvent("giveWeapon,",getLocalPlayer()) 
end 
end 
) 

ServerSide ..

  
addEvent("giveWeapon",true) 
addEventHandler("giveWeapon",root 
    function() 
local Money = getPlayerMoney(source) 
local Name = getPlayerName(getLocalPlayer()) 
if (Money >= 120 ) then 
giveWeapon ( source, 29 ) 
outputChatBox (Name .. "#FF0000Has Bought #00FF00Desert Eagle", getRootElement(), 255, 255, 255, true ) 
end 
end 
) 

Link to comment

Server

  
addEvent( 'giveWeapon',true ) 
addEventHandler( 'giveWeapon',root, 
    function( ) 
        local Money = getPlayerMoney( source ) 
        local Name = getPlayerName( source) 
        if Money >= 120 then 
            giveWeapon ( source, 29 ) 
            outputChatBox ( Name .. "#FF0000Has Bought #00FF00Desert Eagle", root, 255, 255, 255, true ) 
        end 
    end 
) 

You forgot ',' in addEventHandler.

local Name = getPlayerName(getLocalPlayer()) 

Your code

getLocalPlayer() in server side oO

Please tabulate your code!

Link to comment

Client triggerd serverSide event giveWeapon, but event is not added serverSide

Client

  
GUIEditor_Window = {} 
GUIEditor_TabPanel = {} 
GUIEditor_Tab = {} 
GUIEditor_Button = {} 
GUIEditor_Label = {} 
GUIEditor_Image = {} 
  
GUIEditor_Window[1] = guiCreateWindow(255,151,638,373,"War_Panel By Evil-Cod3r v1.0",false) 
guiWindowSetMovable(GUIEditor_Window[1],false) 
guiWindowSetSizable(GUIEditor_Window[1],false) 
GUIEditor_TabPanel[1] = guiCreateTabPanel(9,23,620,341,false,GUIEditor_Window[1]) 
GUIEditor_Tab[1] = guiCreateTab("Weapons",GUIEditor_TabPanel[1]) 
GUIEditor_Image[1] = guiCreateStaticImage(0,0,143,81,"images/1.png",false,GUIEditor_Tab[1]) 
GUIEditor_Button[1] = guiCreateButton(6,87,139,29,"Desert Eagle",false,GUIEditor_Tab[1]) 
guiSetFont(GUIEditor_Button[1],"clear-normal") 
GUIEditor_Label[1] = guiCreateLabel(8,126,179,18,"Buy Desert Eagle For $120 ?",false,GUIEditor_Tab[1]) 
guiLabelSetColor(GUIEditor_Label[1],0,255,0) 
guiSetFont(GUIEditor_Label[1],"clear-normal") 
GUIEditor_Image[2] = guiCreateStaticImage(243,3,177,92,"images/2.png",false,GUIEditor_Tab[1]) 
GUIEditor_Button[2] = guiCreateButton(245,97,150,28,"M-4",false,GUIEditor_Tab[1]) 
guiSetFont(GUIEditor_Button[2],"clear-normal") 
GUIEditor_Label[2] = guiCreateLabel(243,130,175,22,"Buy M-4 For $ 250 ?",false,GUIEditor_Tab[1]) 
guiLabelSetColor(GUIEditor_Label[2],255,0,0) 
guiSetFont(GUIEditor_Label[2],"clear-normal") 
GUIEditor_Image[3] = guiCreateStaticImage(392,138,215,65,"images/3.png",false,GUIEditor_Tab[1]) 
GUIEditor_Button[3] = guiCreateButton(410,205,148,25,"Sniper",false,GUIEditor_Tab[1]) 
guiSetFont(GUIEditor_Button[3],"clear-normal") 
GUIEditor_Label[3] = guiCreateLabel(406,241,178,20,"Buy Sniper For $320 ?",false,GUIEditor_Tab[1]) 
guiLabelSetColor(GUIEditor_Label[3],255,0,255) 
guiSetFont(GUIEditor_Label[3],"clear-normal") 
GUIEditor_Image[4] = guiCreateStaticImage(11,172,369,128,"images/mtalogo.png",false,GUIEditor_Tab[1]) 
GUIEditor_Tab[2] = guiCreateTab("Shop",GUIEditor_TabPanel[1]) 
GUIEditor_Image[5] = guiCreateStaticImage(24,26,207,66,"images/4.png",false,GUIEditor_Tab[2]) 
GUIEditor_Button[4] = guiCreateButton(36,101,165,34,"Armor",false,GUIEditor_Tab[2]) 
guiSetFont(GUIEditor_Button[4],"clear-normal") 
GUIEditor_Label[4] = guiCreateLabel(33,148,154,22,"Buy Armor $ 2500 ?",false,GUIEditor_Tab[2]) 
guiLabelSetColor(GUIEditor_Label[4],0,0,255) 
guiSetFont(GUIEditor_Label[4],"clear-normal") 
GUIEditor_Image[6] = guiCreateStaticImage(316,21,227,78,"images/5.png",false,GUIEditor_Tab[2]) 
GUIEditor_Button[5] = guiCreateButton(332,106,173,33,"Health",false,GUIEditor_Tab[2]) 
guiSetFont(GUIEditor_Button[5],"clear-normal") 
GUIEditor_Label[5] = guiCreateLabel(330,154,158,22,"Buy Health For $ 1500 ?",false,GUIEditor_Tab[2]) 
guiLabelSetColor(GUIEditor_Label[5],0,255,255) 
guiSetFont(GUIEditor_Label[5],"clear-normal") 
GUIEditor_Image[7] = guiCreateStaticImage(19,187,530,116,"images/mtalogo.png",false,GUIEditor_Tab[2]) 
GUIEditor_Image[8] = guiCreateStaticImage(646,15,0,5,"images/3.png",false,GUIEditor_Window[1]) 
  
addEventHandler ("onClientGUIClick", getRootElement(), 
function(button, state, absoluteX, absoluteY) 
    if ( source == GUIEditor_Button[1] ) then 
    triggerServerEvent("giveWeapon,",getLocalPlayer()) 
end 
end 
) 
  
addEvent ( "playSound" , true ) 
addEventHandler ( "playSound" , root , 
function() 
playSound ( "sounds/Buy.mp3" , false ) 
end) 

  
addEvent( 'giveWeapon',true ) 
addEventHandler( 'giveWeapon',root, 
    function( ) 
        local Money = getPlayerMoney( source ) 
        local Name = getPlayerName( source) 
        if Money >= 120 then 
            giveWeapon ( source, 29 ) 
            triggerClientEvent ( source, "playSound" , source ) 
            outputChatBox ( Name .. "#FF0000Has Bought #00FF00Desert Eagle", root, 255, 255, 255, true ) 
        end 
    end 
) 

Link to comment
  
GUIEditor_Window = {} 
GUIEditor_TabPanel = {} 
GUIEditor_Tab = {} 
GUIEditor_Button = {} 
GUIEditor_Label = {} 
GUIEditor_Image = {} 
  
GUIEditor_Window[1] = guiCreateWindow(255,151,638,373,"War_Panel By Evil-Cod3r v1.0",false) 
guiWindowSetMovable(GUIEditor_Window[1],false) 
guiWindowSetSizable(GUIEditor_Window[1],false) 
GUIEditor_TabPanel[1] = guiCreateTabPanel(9,23,620,341,false,GUIEditor_Window[1]) 
GUIEditor_Tab[1] = guiCreateTab("Weapons",GUIEditor_TabPanel[1]) 
GUIEditor_Image[1] = guiCreateStaticImage(0,0,143,81,"images/1.png",false,GUIEditor_Tab[1]) 
GUIEditor_Button[1] = guiCreateButton(6,87,139,29,"Desert Eagle",false,GUIEditor_Tab[1]) 
guiSetFont(GUIEditor_Button[1],"clear-normal") 
GUIEditor_Label[1] = guiCreateLabel(8,126,179,18,"Buy Desert Eagle For $120 ?",false,GUIEditor_Tab[1]) 
guiLabelSetColor(GUIEditor_Label[1],0,255,0) 
guiSetFont(GUIEditor_Label[1],"clear-normal") 
GUIEditor_Image[2] = guiCreateStaticImage(243,3,177,92,"images/2.png",false,GUIEditor_Tab[1]) 
GUIEditor_Button[2] = guiCreateButton(245,97,150,28,"M-4",false,GUIEditor_Tab[1]) 
guiSetFont(GUIEditor_Button[2],"clear-normal") 
GUIEditor_Label[2] = guiCreateLabel(243,130,175,22,"Buy M-4 For $ 250 ?",false,GUIEditor_Tab[1]) 
guiLabelSetColor(GUIEditor_Label[2],255,0,0) 
guiSetFont(GUIEditor_Label[2],"clear-normal") 
GUIEditor_Image[3] = guiCreateStaticImage(392,138,215,65,"images/3.png",false,GUIEditor_Tab[1]) 
GUIEditor_Button[3] = guiCreateButton(410,205,148,25,"Sniper",false,GUIEditor_Tab[1]) 
guiSetFont(GUIEditor_Button[3],"clear-normal") 
GUIEditor_Label[3] = guiCreateLabel(406,241,178,20,"Buy Sniper For $320 ?",false,GUIEditor_Tab[1]) 
guiLabelSetColor(GUIEditor_Label[3],255,0,255) 
guiSetFont(GUIEditor_Label[3],"clear-normal") 
GUIEditor_Image[4] = guiCreateStaticImage(11,172,369,128,"images/mtalogo.png",false,GUIEditor_Tab[1]) 
GUIEditor_Tab[2] = guiCreateTab("Shop",GUIEditor_TabPanel[1]) 
GUIEditor_Image[5] = guiCreateStaticImage(24,26,207,66,"images/4.png",false,GUIEditor_Tab[2]) 
GUIEditor_Button[4] = guiCreateButton(36,101,165,34,"Armor",false,GUIEditor_Tab[2]) 
guiSetFont(GUIEditor_Button[4],"clear-normal") 
GUIEditor_Label[4] = guiCreateLabel(33,148,154,22,"Buy Armor $ 2500 ?",false,GUIEditor_Tab[2]) 
guiLabelSetColor(GUIEditor_Label[4],0,0,255) 
guiSetFont(GUIEditor_Label[4],"clear-normal") 
GUIEditor_Image[6] = guiCreateStaticImage(316,21,227,78,"images/5.png",false,GUIEditor_Tab[2]) 
GUIEditor_Button[5] = guiCreateButton(332,106,173,33,"Health",false,GUIEditor_Tab[2]) 
guiSetFont(GUIEditor_Button[5],"clear-normal") 
GUIEditor_Label[5] = guiCreateLabel(330,154,158,22,"Buy Health For $ 1500 ?",false,GUIEditor_Tab[2]) 
guiLabelSetColor(GUIEditor_Label[5],0,255,255) 
guiSetFont(GUIEditor_Label[5],"clear-normal") 
GUIEditor_Image[7] = guiCreateStaticImage(19,187,530,116,"images/mtalogo.png",false,GUIEditor_Tab[2]) 
GUIEditor_Image[8] = guiCreateStaticImage(646,15,0,5,"images/3.png",false,GUIEditor_Window[1]) 
  
addEventHandler ("onClientGUIClick", getRootElement(), 
function(button, state, absoluteX, absoluteY) 
    if ( source == GUIEditor_Button[1] ) then 
    triggerServerEvent("giveWeapon",getLocalPlayer()) 
end 
end 
) 
  
addEvent ( "playSound" , true ) 
addEventHandler ( "playSound" , root , 
function() 
playSound ( "sounds/Buy.mp3" , false ) 
end) 

Your mistake :

You trigger with this event name "giveWeapon,",but should be "giveWeapon".

Link to comment

Kenix its Possble to Playe sound for example if i have Mutch Money and Buy Gun Play Sound else PlaySound Error ??

GUIEditor_Window = {} 
GUIEditor_TabPanel = {} 
GUIEditor_Tab = {} 
GUIEditor_Button = {} 
GUIEditor_Label = {} 
GUIEditor_Image = {} 
  
GUIEditor_Window[1] = guiCreateWindow(255,151,638,373,"War_Panel By Evil-Cod3r v1.0",false) 
guiWindowSetMovable(GUIEditor_Window[1],false) 
guiWindowSetSizable(GUIEditor_Window[1],false) 
GUIEditor_TabPanel[1] = guiCreateTabPanel(9,23,620,341,false,GUIEditor_Window[1]) 
GUIEditor_Tab[1] = guiCreateTab("Weapons",GUIEditor_TabPanel[1]) 
GUIEditor_Image[1] = guiCreateStaticImage(0,0,143,81,"images/1.png",false,GUIEditor_Tab[1]) 
GUIEditor_Button[1] = guiCreateButton(6,87,139,29,"Desert Eagle",false,GUIEditor_Tab[1]) 
guiSetFont(GUIEditor_Button[1],"clear-normal") 
GUIEditor_Label[1] = guiCreateLabel(8,126,179,18,"Buy Desert Eagle For $120 ?",false,GUIEditor_Tab[1]) 
guiLabelSetColor(GUIEditor_Label[1],0,255,0) 
guiSetFont(GUIEditor_Label[1],"clear-normal") 
GUIEditor_Image[2] = guiCreateStaticImage(243,3,177,92,"images/2.png",false,GUIEditor_Tab[1]) 
GUIEditor_Button[2] = guiCreateButton(245,97,150,28,"M-4",false,GUIEditor_Tab[1]) 
guiSetFont(GUIEditor_Button[2],"clear-normal") 
GUIEditor_Label[2] = guiCreateLabel(243,130,175,22,"Buy M-4 For $ 250 ?",false,GUIEditor_Tab[1]) 
guiLabelSetColor(GUIEditor_Label[2],255,0,0) 
guiSetFont(GUIEditor_Label[2],"clear-normal") 
GUIEditor_Image[3] = guiCreateStaticImage(392,138,215,65,"images/3.png",false,GUIEditor_Tab[1]) 
GUIEditor_Button[3] = guiCreateButton(410,205,148,25,"Sniper",false,GUIEditor_Tab[1]) 
guiSetFont(GUIEditor_Button[3],"clear-normal") 
GUIEditor_Label[3] = guiCreateLabel(406,241,178,20,"Buy Sniper For $320 ?",false,GUIEditor_Tab[1]) 
guiLabelSetColor(GUIEditor_Label[3],255,0,255) 
guiSetFont(GUIEditor_Label[3],"clear-normal") 
GUIEditor_Image[4] = guiCreateStaticImage(11,172,369,128,"images/mtalogo.png",false,GUIEditor_Tab[1]) 
GUIEditor_Tab[2] = guiCreateTab("Shop",GUIEditor_TabPanel[1]) 
GUIEditor_Image[5] = guiCreateStaticImage(24,26,207,66,"images/4.png",false,GUIEditor_Tab[2]) 
GUIEditor_Button[4] = guiCreateButton(36,101,165,34,"Armor",false,GUIEditor_Tab[2]) 
guiSetFont(GUIEditor_Button[4],"clear-normal") 
GUIEditor_Label[4] = guiCreateLabel(33,148,154,22,"Buy Armor $ 2500 ?",false,GUIEditor_Tab[2]) 
guiLabelSetColor(GUIEditor_Label[4],0,0,255) 
guiSetFont(GUIEditor_Label[4],"clear-normal") 
GUIEditor_Image[6] = guiCreateStaticImage(316,21,227,78,"images/5.png",false,GUIEditor_Tab[2]) 
GUIEditor_Button[5] = guiCreateButton(332,106,173,33,"Health",false,GUIEditor_Tab[2]) 
guiSetFont(GUIEditor_Button[5],"clear-normal") 
GUIEditor_Label[5] = guiCreateLabel(330,154,158,22,"Buy Health For $ 1500 ?",false,GUIEditor_Tab[2]) 
guiLabelSetColor(GUIEditor_Label[5],0,255,255) 
guiSetFont(GUIEditor_Label[5],"clear-normal") 
GUIEditor_Image[7] = guiCreateStaticImage(19,187,530,116,"images/mtalogo.png",false,GUIEditor_Tab[2]) 
GUIEditor_Image[8] = guiCreateStaticImage(646,15,0,5,"images/3.png",false,GUIEditor_Window[1]) 
  
addEventHandler ("onClientGUIClick", getRootElement(), 
function(button, state, absoluteX, absoluteY) 
    if ( source == GUIEditor_Button[1] ) then 
    triggerServerEvent("giveWeapon",getLocalPlayer()) 
    takePlayerMoney ( source , tonumber(120) ) 
end 
end 
) 
  
addEvent ( "playSound" , true ) 
addEventHandler ( "playSound" , root , 
function() 
playSound ( "sounds/Buy.mp3" , false ) 
end) 

  
addEvent( 'giveWeapon',true ) 
addEventHandler( 'giveWeapon',root, 
    function( ) 
        local Money = getPlayerMoney( source ) 
        local Name = getPlayerName( source) 
        if Money >= 120 then 
            giveWeapon ( source, 29 ) 
            triggerClientEvent ( source, "playSound" , source ) 
            outputChatBox ( Name .. "#FF0000Has Bought --- > #00FF00Desert Eagle", root, 255, 255, 255, true ) 
            else 
            outputChatBox("#ff0000You Dont Have #00ff00$120 To Buy This Weapons", source, root, 255, 255, 255, true) 
        end 
    end 
) 

Link to comment

Server

addEvent( 'giveWeapon',true ) 
addEventHandler( 'giveWeapon',root, 
    function( ) 
        local Money = getPlayerMoney( source ) 
        local Name = getPlayerName( source) 
        if Money >= 120 then 
            giveWeapon ( source, 29 ) 
            triggerClientEvent ( source, "playSound" , source,'sounds/Buy.mp3' ) 
            outputChatBox ( Name .. "#FF0000Has Bought --- > #00FF00Desert Eagle", root, 255, 255, 255, true ) 
        else 
            triggerClientEvent ( source, "playSound" , source,'sounds/error.mp3' ) 
            outputChatBox( "#ff0000You Dont Have #00ff00$120 To Buy This Weapons", source, root, 255, 255, 255, true )   
        end 
    end 
) 

Client

addEvent ( "playSound" , true ) 
addEventHandler ( "playSound" , root , 
    function( filepath ) 
        playSound ( tostring( filepath ), false ) 
    end 
) 

Not forget add your sound to meta.xml

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...