Jump to content

[HELP] Event not added clientside


HeK

Recommended Posts

I'm having these errors in debugscript 3, it says "ERROR: Server triggered clientside event hideVendorGUI, but event is not added clientside". I have checked it and it is added in clientside.

What should i do?

Edited by Guest
Link to comment

Your script has many problems, I've fixed them for you, but next time use debugscript ( /debugscript 3 in-game ).

-- client side:

GUIEditor = { 
    button = {}, 
    window = {} 
} 
  
GUIEditor.window[1] = guiCreateWindow(510, 418, 264, 162, "Chilli Dogs Vendor", false) 
guiWindowSetSizable(GUIEditor.window[1], false) 
guiSetVisible(GUIEditor.window[1],false) 
GUIEditor.button[1] = guiCreateButton(19,42,108,31, "Chili | 5HP | $10", false, GUIEditor.window[1]) 
GUIEditor.button[2] = guiCreateButton(101, 129, 65, 21, "Close", false, GUIEditor. window[1]) 
GUIEditor.button[3] = guiCreateButton(137, 42, 108, 31, "Ace | 10HP | $15", false, GUIEditor. window[1]) 
GUIEditor.button[4] = guiCreateButton(137, 88, 114, 31, "Mega | 20HP | $20", false, GUIEditor. window[1]) 
GUIEditor.button[5] = guiCreateButton(13, 88, 114, 31, "Super | 25HP | $25", false, GUIEditor. window[1]) 
  
function showVendorGUI ( ) 
    guiSetVisible ( GUIEditor.window[1], true ) 
    showCursor ( true ) 
end 
addEvent ( "showVendorGUI", true ) 
addEventHandler ( "showVendorGUI", getRootElement(), showVendorGUI ) 
  
addEvent ( "hideVendorGUI", true ) 
addEventHandler ( "hideVendorGUI", getRootElement(), 
    function ( ) 
        guiSetVisible ( GUIEditor.window[1], false ) 
        showCursor ( false ) 
    end 
) 
  
addEventHandler ( "onClientGUIClick", getRootElement(), 
    function ( ) 
        if ( source == GUIEditor.button[2] ) then 
            guiSetVisible ( GUIEditor.window[1], false ) 
            showCursor ( false ) 
        elseif ( source == GUIEditor.button[1] ) then 
            triggerServerEvent ( "buyFood", localPlayer, 10 ) 
        elseif ( source == GUIEditor.button[3] ) then 
            triggerServerEvent ( "buyFood", localPlayer, 15 ) 
        elseif ( source == GUIEditor.button[4] ) then 
            triggerServerEvent ( "buyFood", localPlayer, 20 ) 
        elseif ( source == GUIEditor.button[5] ) then 
            triggerServerEvent ( "buyFood", localPlayer, 25 ) 
        end 
    end 
) 

-- server side:

--Markers 
vendor1 = createMarker ( 999.921, -1850.50, 11.8, "cylinder", 1.2, 100, 0, 0, 115 ) 
vendor2 = createMarker ( 388.86, -2073.04, 6.8, "cylinder", 1.2, 100, 0, 0, 115 ) 
  
--Vendors 
ped1 = createPed ( 168, 1000.78 ,-1848.05, 12.82 ) 
ped2 = createPed ( 168, 388.86, -2070.44, 8 ) 
setPedRotation ( ped1, 155 ) 
setPedRotation ( ped2, 180 ) 
  
function showGUI ( hitPlayer ) 
    triggerClientEvent ( hitPlayer, "showVendorGUI", getRootElement(), hitPlayer ) 
end 
addEventHandler ( "onMarkerHit", vendor1, showGUI ) 
addEventHandler ( "onMarkerHit", vendor2, showGUI ) 
  
function hideGUI ( leavePlayer ) 
    triggerClientEvent ( leavePlayer, "hideVendorGUI", leavePlayer ) 
end 
addEventHandler ( "onMarkerLeave", vendor1, hideGUI ) 
addEventHandler ( "onMarkerLeave", vendor2, hideGUI ) 
  
addEvent ( "buyFood", true ) 
addEventHandler ( "buyFood", root, 
    function ( cost ) 
        if ( getPlayerMoney ( client ) < cost ) then 
            return outputChatBox ( "You don't have enough money!", client, 255, 0, 0 ) 
        end 
  
        if ( cost == 10 ) then 
            outputChatBox ( "(Local) Vendor: There you go sir, have a nice day.", client, 225, 230, 0 ) 
        elseif ( cost == 15 ) then 
            outputChatBox ( "(Local) Vendor: There you go sir, have a nice day.", client, 225, 230, 0 ) 
        elseif ( cost == 20 ) then 
            outputChatBox ( "(Local) Vendor: There you go sir, have a nice day.", client, 225, 230, 0 ) 
        elseif ( cost == 25 ) then 
            outputChatBox ( "(Local) Vendor: There you go sir, have a nice day.", client, 225, 230, 0 ) 
        end 
        takePlayerMoney ( client, cost ) 
        setElementHealth ( client, ( getElementHealth ( client ) + cost ) ) 
    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...