Sign in to follow this  
HeK

[HELP] Event not added clientside

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

Share this post


Link to post

On marker hit.

Edited by Guest

Share this post


Link to post

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 
) 

Share this post


Link to post

Thanks a lot Castillo, that fixed all my problems and you made the script much 'easier' to work with, sorry for bothering and thanks a lot for your time.

Share this post


Link to post

Another thing Castillo, how do i make it that vehicles cannot open the GUI and that when a player presses the button he has to wait about 3 seconds for it to be "clickable" again. Sorry for bothering s:

Share this post


Link to post

When hit the marker, check if the player is on a vehicle with:

isPedInVehicle 

About waiting timer, you can either use timers:

setTimer 
isTimer 

or calculate the time passed with:

getTickCount 

Share this post


Link to post

I tried with setTimer, but i didn't understand that much about it, i tried to make it in client side but it didn't work. Could you explain how i should do it for a GUI?

Share this post


Link to post

You can disable the button after bought, then set a 3 seconds timer to enable it again.

Use:

setTimer 
guiSetEnabled 

Share this post


Link to post

I made it that i can disable each button, but the problem is that i can use the other buttons.

How can i disable every button at the same time?

Edited by Guest

Share this post


Link to post

Or... instead of disabling each button, just set a timer, and when try to buy again, check if that timer is still alive with isTimer.

Share this post


Link to post

Alright i've done it, thanks a lot and sorry for bothering.

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.