Jump to content

a lil 1 more help


Bean666

Recommended Posts

I'm getting a getelementtype nil here idk why

function acceptjob(player) 
if (getElementType(player) == "player") then 
setElementData(player, "Job", "Fishermen") 
setElementData(player, "Fishermen", true) 
outputChatBox("You are now a fisherman!", player, 255, 255, 0) 
setPlayerTeam(player, getTeamFromName("Services")) 
end 
end 
addEvent("acceptjob", true) 
addEventHandler("acceptjob", getRootElement(), acceptjob) 

client that's triggering the event

addEventHandler("onClientGUIClick",resourceRoot,function() 
    if (source == accept) then 
    guiSetVisible(window,false) 
    showCursor(false) 
    triggerServerEvent("acceptjob", localPlayer) 
    elseif ( source == cancel) then 
           guiSetVisible(window,false) 
           showCursor(false) 
       end 
   end ) 

Edited by Guest
Link to comment

I'm getting a getelementtype nil here idk why

function acceptjob(player) 
if (getElementType(player) == "player") then 
setElementData(player, "Job", "Fishermen") 
setElementData(player, "Fishermen", true) 
outputChatBox("You are now a fisherman!", player, 255, 255, 0) 
setPlayerTeam(player, getTeamFromName("Services")) 
end 
end 
addEvent("acceptjob", true) 
addEventHandler("acceptjob", getRootElement(), acceptjob) 

client that's triggering the event

addEventHandler("onClientGUIClick",resourceRoot,function() 
    if (source == accept) then 
    guiSetVisible(window,false) 
    showCursor(false) 
    triggerServerEvent("acceptjob", localPlayer) 
    elseif ( source == cancel) then 
           guiSetVisible(window,false) 
           showCursor(false) 
       end 
   end ) 

Link to comment

cuz there's no parametrs, and you don't need to use getElementType, anyway change your trigger to :

triggerServerEvent("acceptjob", localPlayer, localPlayer) 

and you can do it like this without changed :

function acceptjob() 
if (getElementType(source) == "player") then 
setElementData(source, "Job", "Fishermen") 
setElementData(source, "Fishermen", true) 
outputChatBox("You are now a fisherman!", source, 255, 255, 0) 
setPlayerTeam(source, getTeamFromName("Services")) 
end 
end 
addEvent("acceptjob", true) 
addEventHandler("acceptjob", getRootElement(), acceptjob) 

and you don't need to use getElementType too.

Link to comment

For triggerServerEvent, client is always set. i.e.:

triggerServerEvent("EventName" , localPlayer)

  • source is localPlayer
  • client is localPlayer

triggerServerEvent("EventName" , resourceRoot or root)

  • source is resourceRoot or root
  • client is localPlayer

-- Server side

function acceptjob() 
    setElementData(client, "Job", "Fishermen") 
    setElementData(client, "Fishermen", true) 
    outputChatBox("You are now a fisherman!", client, 255, 255, 0) 
    setPlayerTeam(client, getTeamFromName("Services")) 
end 
addEvent("acceptjob", true) 
addEventHandler("acceptjob", getRootElement(), acceptjob) 

-- Client side

addEventHandler("onClientGUIClick",resourceRoot,function() 
    if (source == accept) then 
        guiSetVisible(window,false) 
        showCursor(false) 
        triggerServerEvent("acceptjob", localPlayer) 
    elseif ( source == cancel) then 
           guiSetVisible(window,false) 
           showCursor(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...