Jump to content

Arggh this is doing my head in


Recommended Posts

Posted

Oka, since your meta is good, it means your serverside script has errors in it, im gonna to check that. Just dont give up!!!

Be Kind

Skype: darkwarrior.diesel

Posted

Hey, i found it, like i told you before, the serverside had some errors, thats y it was not working. Truth is you missed some end :lol: and i fixed it for you. i have put some comments to show you where you missed the ends. check it :

function trololo() 
setElementData(source,"Nitro",0) 
setElementData(source,"Fix",0) 
setElementData(source,"Colour",0) 
end 
  
addEventHandler("onResourceStart",resourceRoot, 
  
function() -- its here that the whole error is found, you had missed 3 ends LOL 
local players = getElementsByType ( "player" ) 
    for i,p in ipairs(players) do 
        setElementData(p,"NitroT",false) 
        setElementData(p,"FixT",false) 
        setElementData(p,"ColourT",false) 
        local sourceAccount = getPlayerAccount ( p ) 
        if isGuestAccount ( sourceAccount ) then 
           setElementData(p,"Nitro",0) 
           setElementData(p,"Fix",0) 
           setElementData(p,"Colour",0) 
        else 
            if (getAccountData(sourceAccount, "Nitro")) then 
                setElementData(p,"Nitro",getAccountData(sourceAccount, "Nitro")) 
            end 
            if (getAccountData(sourceAccount, "Fix")) then 
                setElementData(p,"Fix",getAccountData(sourceAccount, "Fix")) 
            end 
            if (getAccountData(sourceAccount, "Colour")) then 
                setElementData(p,"Colour",getAccountData(sourceAccount, "Colour")) 
            end 
            if not (getAccountData(sourceAccount, "Nitro")) and not (getAccountData(sourceAccount, "Fix")) and not (getAccountData(sourceAccount, "Colour")) then 
                setElementData(p,"Nitro",0) 
                setElementData(p,"Fix",0) 
                setElementData(p,"Colour",0) 
            end 
        end -- first end 
    end -- second end 
end-- third end 
  
) 
  
  
addEventHandler("onPlayerLogout",getRootElement(), 
  
function (acc) 
setAccountData(acc,"Nitro",getElementData(source,"Nitro")) 
setAccountData(acc,"Fix",getElementData(source,"Fix")) 
setAccountData(acc,"Colour",getElementData(source,"Colour")) 
setElementData(source,"Nitro",0) 
setElementData(source,"Fix",0) 
setElementData(source,"Colour",0) 
end 
) -- this part is good 
  
  
  
addEventHandler("onPlayerLogin", root, 
function ( _, theCurrentAccount) 
    if (getAccountData(theCurrentAccount, "Nitro")) then 
        setElementData(source,"Nitro",getAccountData(theCurrentAccount, "Nitro")) 
    end 
    if (getAccountData(theCurrentAccount, "Fix")) then 
        setElementData(source,"Fix",getAccountData(theCurrentAccount, "Fix")) 
    end 
    if (getAccountData(theCurrentAccount, "Colour")) then 
        setElementData(source,"Colour",getAccountData(theCurrentAccount, "Colour")) 
    end 
end 
) -- this part also is good 
  
addEvent("giveboomnitro",true) 
    addEventHandler("giveboomnitro",getRootElement(), 
    function (number) -- lets say number for example 
        outputChatBox(" trololooooo giveNitro was triggered",client) 
      if (tonumber(number) > 0) then 
                if ( getPlayerMoney (client) >= 100 ) then 
                    takePlayerMoney(client, 100) 
                    local acc = getPlayerAccount ( client ) 
                    setElementData(client,"Nitro",getElementData(client,"Nitro")+number) 
                     setAccountData(acc,"Nitro",getElementData(client,"Nitro")) 
                else 
                     outputChatBox("You do not have enough money to buy Nitro",client,255,0,0,false) 
                end 
       end 
    end 
    ) -- this part also is good 

Now try it :D and if any other errors in debug..post it

Be Kind

Skype: darkwarrior.diesel

Posted

trololooooo giveNitro was triggered was outputted thanks man now the other problem is

[2014-06-19 20:55:53] ERROR: mechupgrades\s.lua:74: attempt to compare number with nil

which is because number has no value

nJgL8wr.png

I DON'T HAVE HATERS, I JUST HAVE FANS IN DENIAL

Posted

Thanks that worked and it should be taking the money off me, and i have it defined

local acc = getPlayerAccount ( client )

nJgL8wr.png

I DON'T HAVE HATERS, I JUST HAVE FANS IN DENIAL

Posted
Thanks that worked and it should be taking the money off me, and i have it defined

local acc = getPlayerAccount ( client )

If 'number' is not a number but nill, then that won't happen, because he skips that part of the code by then.

EDIT:

triggerServerEvent ( "giveboomnitro", getLocalPlayer(), guiGetText( GUIEditor_gridlist[1], 1, 1)) 

Are you sure the guiGetText is correct? Because I think he is getting the GridList now?

Posted

i will post a picture of my GUI (first time using GUI with an Account so sorry of my difficulties)

xbyDSjQ.png

nJgL8wr.png

I DON'T HAVE HATERS, I JUST HAVE FANS IN DENIAL

Posted

Check if players money is more than 100 then if it is then take 100 else it outputs and says "You do not have enough money to buy Nitro"

nJgL8wr.png

I DON'T HAVE HATERS, I JUST HAVE FANS IN DENIAL

Posted

i used an example off another resource

addEvent("givecred",true)  
addEventHandler("givecred",root,  
function (money,number) 
if (tonumber(number) > 0) then 
if ( getPlayerMoney (source) >= money ) then 
takePlayerMoney(source, money) 
local acc = getPlayerAccount ( source ) 
setElementData(source,"credi",getElementData(source,"credit")+number) 
setAccountData(acc,"credit",getElementData(source,"credit")) 
end 
end 
end  
)   
  

this was what it originally was

nJgL8wr.png

I DON'T HAVE HATERS, I JUST HAVE FANS IN DENIAL

Posted

Serverside:

function trololo() 
setElementData(source,"Nitro",0) 
setElementData(source,"Fix",0) 
setElementData(source,"Colour",0) 
end 
  
addEventHandler("onResourceStart",resourceRoot, 
  
function() -- its here that the whole error is found, you had missed 3 ends LOL 
local players = getElementsByType ( "player" ) 
    for i,p in ipairs(players) do 
        setElementData(p,"NitroT",false) 
        setElementData(p,"FixT",false) 
        setElementData(p,"ColourT",false) 
        local sourceAccount = getPlayerAccount ( p ) 
        if isGuestAccount ( sourceAccount ) then 
           setElementData(p,"Nitro",0) 
           setElementData(p,"Fix",0) 
           setElementData(p,"Colour",0) 
        else 
            if (getAccountData(sourceAccount, "Nitro")) then 
                setElementData(p,"Nitro",getAccountData(sourceAccount, "Nitro")) 
            end 
            if (getAccountData(sourceAccount, "Fix")) then 
                setElementData(p,"Fix",getAccountData(sourceAccount, "Fix")) 
            end 
            if (getAccountData(sourceAccount, "Colour")) then 
                setElementData(p,"Colour",getAccountData(sourceAccount, "Colour")) 
            end 
            if not (getAccountData(sourceAccount, "Nitro")) and not (getAccountData(sourceAccount, "Fix")) and not (getAccountData(sourceAccount, "Colour")) then 
                setElementData(p,"Nitro",0) 
                setElementData(p,"Fix",0) 
                setElementData(p,"Colour",0) 
            end 
        end -- first end 
    end -- second end 
end-- third end 
  
) 
  
  
addEventHandler("onPlayerLogout",getRootElement(), 
  
function (acc) 
setAccountData(acc,"Nitro",getElementData(source,"Nitro")) 
setAccountData(acc,"Fix",getElementData(source,"Fix")) 
setAccountData(acc,"Colour",getElementData(source,"Colour")) 
setElementData(source,"Nitro",0) 
setElementData(source,"Fix",0) 
setElementData(source,"Colour",0) 
end 
) -- this part is good 
  
  
  
addEventHandler("onPlayerLogin", root, 
function ( _, theCurrentAccount) 
    if (getAccountData(theCurrentAccount, "Nitro")) then 
        setElementData(source,"Nitro",getAccountData(theCurrentAccount, "Nitro")) 
    end 
    if (getAccountData(theCurrentAccount, "Fix")) then 
        setElementData(source,"Fix",getAccountData(theCurrentAccount, "Fix")) 
    end 
    if (getAccountData(theCurrentAccount, "Colour")) then 
        setElementData(source,"Colour",getAccountData(theCurrentAccount, "Colour")) 
    end 
end 
) -- this part also is good 
  
addEvent("giveboomnitro",true) 
    addEventHandler("giveboomnitro",getRootElement(), 
    function (gtype, price) -- lets say number for example 
        outputChatBox(" trololooooo giveNitro was triggered",client) 
        if (tonumber(price) ~= nil) then 
            if (tonumber(price) > 0) then 
                if ( getPlayerMoney (client) >= tonumber(price) ) then 
                    if (gtype == "Colour") then 
                        --Code for colour 
                                                outputChatBox("Give colour", source) 
                    elseif (gtype == "Nitro") then 
                        --Code for nitro 
                                                outputChatBox("Give nitro", source) 
                    elseif (gtype == "Repair") then 
                        --Code for repair 
                                                outputChatBox("Give repair", source) 
                    end 
                    --takePlayerMoney(client, tonumber(price)) 
                    --local acc = getPlayerAccount ( client ) 
                    --setElementData(client,"Nitro",getElementData(client,"Nitro")+number) 
                    -- setAccountData(acc,"Nitro",getElementData(client,"Nitro")) 
                else 
                     outputChatBox("You do not have enough money to buy Nitro",client,255,0,0,false) 
                end 
            end 
       end 
    end 
    ) -- this part also is good 

Clientside:

local marker = createMarker( 1220.8000488281, -1427.3000488281, 12.39999961853, "cylinder", 1.5, 0, 0, 0, 0) 
    ----local ped = createPed(305,1220.8000488281, -1427.5999755859, 13.39999961853) 
    createBlip (2000.763671875, 1539.0169677734, 13.5859375, 23 ,2 ) 
    
    myFont = dxCreateFont( "BEBAS.ttf", 20 )  -- Create custom font 
      
      
      
    GUIEditor_Button = {} 
    GUIEditor_Memo = {} 
    GUIEditor_gridlist = {} 
      
            windowjob = guiCreateWindow(392, 176, 408, 437, "Parts", false) 
            guiWindowSetSizable(windowjob, false) 
            guiSetVisible(windowjob, false) 
            GUIEditor_Memo[1] = guiCreateMemo(25, 27, 367, 108, "This is the Vehicle Upgrades store, you can buy these objects to apply to your vehicle of any sort", false, windowjob) 
            guiMemoSetReadOnly(GUIEditor_Memo[1], true) 
            GUIEditor_gridlist[1] = guiCreateGridList(21, 258, 366, 111, false, windowjob) 
            guiGridListAddColumn(GUIEditor_gridlist[1], "Upgrades", 0.5) 
            guiGridListAddColumn(GUIEditor_gridlist[1], "Price", 0.5) 
            for i = 1, 3 do 
                guiGridListAddRow(GUIEditor_gridlist[1]) 
            end 
            guiGridListSetItemText(GUIEditor_gridlist[1], 0, 1, "Colour", false, false) 
            guiGridListSetItemText(GUIEditor_gridlist[1], 0, 2, "$100", false, false) 
            guiGridListSetItemText(GUIEditor_gridlist[1], 1, 1, "Nitro", false, false) 
            guiGridListSetItemText(GUIEditor_gridlist[1], 1, 2, "$1000", false, false) 
            guiGridListSetItemText(GUIEditor_gridlist[1], 2, 1, "Repair", false, false) 
            guiGridListSetItemText(GUIEditor_gridlist[1], 2, 2, "$250", false, false) 
            GUIEditor_Button[2] = guiCreateButton(206, 379, 174, 48, "Cancel", false, windowjob) 
            GUIEditor_Button[1] = guiCreateButton(21, 379, 175, 48, "Buy!", false, windowjob) 
            
    function GuiOpen(hitElement) 
                    setElementData ( localPlayer, "ownskin", getElementModel (localPlayer)  ) 
        if getElementType(hitElement) == "player" and (hitElement == localPlayer) then 
        if not guiGetVisible(windowjob) then 
            guiSetVisible(windowjob, true) 
                          showCursor(true) 
                      end 
                 end 
            end 
            addEventHandler("onClientMarkerHit", marker, GuiOpen) 
              
            function GuiClose(leaveElement) 
            
                 if getElementType(leaveElement) == "player" and (leaveElement == localPlayer) then 
                      if guiGetVisible(windowjob) then 
                           guiSetVisible(windowjob, false) 
                           showCursor(false) 
                      end 
                 end 
            end 
            addEventHandler("onClientMarkerLeave", marker, GuiClose) 
            
            function removeUpWindow() 
            guiSetVisible(windowjob, false) 
            showCursor(false) 
                  
            end 
            addEventHandler("onClientGUIClick", GUIEditor_Button[2] , removeUpWindow, false) 
            
            function removeUpWindow() 
            guiSetVisible(windowjob, false) 
            showCursor(false) 
             outputChatBox("ok, here is ok too") 
             local gSelectedRow, gSelectedColumn = guiGetSelectedItem(GUIEditor_gridlist[1]) 
            triggerServerEvent ( "giveboomnitro", getLocalPlayer(), --[[what to give:]]guiGridListGetItemText(GUIEditor_gridlist[1], gSelectedRow, 1) ,--[[price:]]string.gsub(guiGridListGetItemText(GUIEditor_gridlist[1], gSelectedRow, 2), "%D", "")) 
            outputChatBox("same here too") 
            end 
            
            addEventHandler("onClientGUIClick", GUIEditor_Button[2] , removeUpWindow, false) 
            
      
         local maxDistance = 12 -- the distance showing 3dtext 
       local ped = createPed (305,1220.8000488281, -1427.5999755859, 13.39999961853) 
          
         addEventHandler ( "onClientRender", root, 
            function ( ) 
         local pX, pY, pZ = getElementPosition ( localPlayer ) 
                local pedX, pedY, pedZ = getElementPosition ( ped ) 
                local distance = getDistanceBetweenPoints3D ( pX, pY, pZ, pedX, pedY, pedZ ) 
                
                if ( distance <= 15 ) then 
                    local x, y = getScreenFromWorldPosition ( pedX, pedY, pedZ ) 
                    if ( x and y ) then 
                    dxDrawText( "Upgrades", x, y+1.5, _, _, tocolor( 255, 255, 0, 255 ), 1, myFont, "center", "center" ) 
                    end 
                end 
            end 
        ) 

I edited the script a bit. It gets what is selected in the gridlist and it sends it to the server. (With the price) (Not tested) I added outputChatBox for you to check or it outputs the correct selected item.

Posted

Thanks again,

It says

line 66 a nil value

local gSelectedRow, gSelectedColumn = guiGetSelectedItem(GUIEditor_gridlist[1])

nJgL8wr.png

I DON'T HAVE HATERS, I JUST HAVE FANS IN DENIAL

Posted
local marker = createMarker( 1220.8000488281, -1427.3000488281, 12.39999961853, "cylinder", 1.5, 0, 0, 0, 0) 
    ----local ped = createPed(305,1220.8000488281, -1427.5999755859, 13.39999961853) 
    createBlip (2000.763671875, 1539.0169677734, 13.5859375, 23 ,2 ) 
    
    myFont = dxCreateFont( "BEBAS.ttf", 20 )  -- Create custom font 
      
      
      
    GUIEditor_Button = {} 
    GUIEditor_Memo = {} 
    GUIEditor_gridlist = {} 
      
            windowjob = guiCreateWindow(392, 176, 408, 437, "Parts", false) 
            guiWindowSetSizable(windowjob, false) 
            guiSetVisible(windowjob, false) 
            GUIEditor_Memo[1] = guiCreateMemo(25, 27, 367, 108, "This is the Vehicle Upgrades store, you can buy these objects to apply to your vehicle of any sort", false, windowjob) 
            guiMemoSetReadOnly(GUIEditor_Memo[1], true) 
            GUIEditor_gridlist[1] = guiCreateGridList(21, 258, 366, 111, false, windowjob) 
            guiGridListAddColumn(GUIEditor_gridlist[1], "Upgrades", 0.5) 
            guiGridListAddColumn(GUIEditor_gridlist[1], "Price", 0.5) 
            for i = 1, 3 do 
                guiGridListAddRow(GUIEditor_gridlist[1]) 
            end 
            guiGridListSetItemText(GUIEditor_gridlist[1], 0, 1, "Colour", false, false) 
            guiGridListSetItemText(GUIEditor_gridlist[1], 0, 2, "$100", false, false) 
            guiGridListSetItemText(GUIEditor_gridlist[1], 1, 1, "Nitro", false, false) 
            guiGridListSetItemText(GUIEditor_gridlist[1], 1, 2, "$1000", false, false) 
            guiGridListSetItemText(GUIEditor_gridlist[1], 2, 1, "Repair", false, false) 
            guiGridListSetItemText(GUIEditor_gridlist[1], 2, 2, "$250", false, false) 
            GUIEditor_Button[2] = guiCreateButton(206, 379, 174, 48, "Cancel", false, windowjob) 
            GUIEditor_Button[1] = guiCreateButton(21, 379, 175, 48, "Buy!", false, windowjob) 
            
    function GuiOpen(hitElement) 
                    setElementData ( localPlayer, "ownskin", getElementModel (localPlayer)  ) 
        if getElementType(hitElement) == "player" and (hitElement == localPlayer) then 
        if not guiGetVisible(windowjob) then 
            guiSetVisible(windowjob, true) 
                          showCursor(true) 
                      end 
                 end 
            end 
            addEventHandler("onClientMarkerHit", marker, GuiOpen) 
              
            function GuiClose(leaveElement) 
            
                 if getElementType(leaveElement) == "player" and (leaveElement == localPlayer) then 
                      if guiGetVisible(windowjob) then 
                           guiSetVisible(windowjob, false) 
                           showCursor(false) 
                      end 
                 end 
            end 
            addEventHandler("onClientMarkerLeave", marker, GuiClose) 
            
            function removeUpWindow() 
            guiSetVisible(windowjob, false) 
            showCursor(false) 
                  
            end 
            addEventHandler("onClientGUIClick", GUIEditor_Button[2] , removeUpWindow, false) 
            
            function removeUpWindow() 
            guiSetVisible(windowjob, false) 
            showCursor(false) 
             outputChatBox("ok, here is ok too") 
             local gSelectedRow, gSelectedColumn = guiGridListGetSelectedItem(GUIEditor_gridlist[1]) 
            triggerServerEvent ( "giveboomnitro", getLocalPlayer(), --[[what to give:]]guiGridListGetItemText(GUIEditor_gridlist[1], gSelectedRow, 1) ,--[[price:]]string.gsub(guiGridListGetItemText(GUIEditor_gridlist[1], gSelectedRow, 2), "%D", "")) 
            outputChatBox("same here too") 
            end 
            
            addEventHandler("onClientGUIClick", GUIEditor_Button[2] , removeUpWindow, false) 
            
      
         local maxDistance = 12 -- the distance showing 3dtext 
       local ped = createPed (305,1220.8000488281, -1427.5999755859, 13.39999961853) 
          
         addEventHandler ( "onClientRender", root, 
            function ( ) 
         local pX, pY, pZ = getElementPosition ( localPlayer ) 
                local pedX, pedY, pedZ = getElementPosition ( ped ) 
                local distance = getDistanceBetweenPoints3D ( pX, pY, pZ, pedX, pedY, pedZ ) 
                
                if ( distance <= 15 ) then 
                    local x, y = getScreenFromWorldPosition ( pedX, pedY, pedZ ) 
                    if ( x and y ) then 
                    dxDrawText( "Upgrades", x, y+1.5, _, _, tocolor( 255, 255, 0, 255 ), 1, myFont, "center", "center" ) 
                    end 
                end 
            end 
        ) 

Oops, sorry :3

Posted

Ah that worked and i did not know you could have two

shotcuts to equal another function

"local gSelectedRow, gSelectedColumn" Cool

it works but does not take players money, i don't really need the checking of the players cash

nJgL8wr.png

I DON'T HAVE HATERS, I JUST HAVE FANS IN DENIAL

Posted
Ah that worked and i did not know you could have two

shotcuts to equal another function

"local gSelectedRow, gSelectedColumn" Cool

it works but does not take players money, i don't really need the checking of the players cash

I know, as you can see I putted '--' before the code. (This means the whole line is not read-able by the script) If the outputten of selected item works, add what you want in the code.

(

if (gtype == "Colour") then 
                        --Code for colour 
                        outputChatBox("Give colour", source) 
                    elseif (gtype == "Nitro") then 
                        --Code for nitro 
                        outputChatBox("Give nitro", source) 
                    elseif (gtype == "Repair") then 
                        --Code for repair 
                        outputChatBox("Give repair", source) 
                    end 

)

Posted

thanks for helping me, im greatly thankful for your help.

sorry if i might need your help again :) :3

nJgL8wr.png

I DON'T HAVE HATERS, I JUST HAVE FANS IN DENIAL

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