Toffbrown Posted June 18, 2014 Share Posted June 18, 2014 I can not get it to work properly ----- Cient 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) triggerServerEvent ( "giveNitro", localPlayer, guiGetText( GUIEditor_gridlist[1], 1, 1)) 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 ) ----Server function() setElementData(source,"Nitro",0) setElementData(source,"Fix",0) setElementData(source,"Colour",0) end) addEventHandler("onResourceStart",resourceRoot, function() 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 ) 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 ) 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 ) addEvent("giveNitro",true) addEventHandler("giveNitro",root, function () if (tonumber(100) > 0) then if ( getPlayerMoney (source) >= 100 ) then takePlayerMoney(source, 100) local acc = getPlayerAccount ( source ) setElementData(source,"Nitro",getElementData(source,"Nitro")+number) setAccountData(acc,"Nitro",getElementData(source,"Nitro")) else outputChatBox("You do not have enough money to buy Nitro",source,255,0,0,false) end end end ) -------addEvent("givenitro",true) --addEventHandler("givenitro",root, --function (money,100) --if (tonumber(number) > 0) then --if ( getPlayerMoney (source) >= 100 ) then ---takePlayerMoney(source, 100) --local acc = getPlayerAccount ( source ) ---setElementData(source,"Nitro",getElementData(source,"Nito")+number) --setAccountData(acc,"Nitro",getElementData(source,"Nitro")) --else ---outputChatBox("You do not have enough money to buy Nitro",source,255,0,0,false) ---end --end ---end Any help would be appreciated been working on this for a day or two and going no where with it Link to comment
Karuzo Posted June 18, 2014 Share Posted June 18, 2014 Could you please tell us what doesn't work? Or just post the dbgscript 3 errors? Link to comment
Toffbrown Posted June 18, 2014 Author Share Posted June 18, 2014 its not setting the elements to the account for instance the Nitro and when i click buy it says its not added serverside when it is unless i am triggering the wrong event in serverside....? [2014-06-18 12:21:37] Starting mechupgrades [2014-06-18 12:21:37] SCRIPT ERROR: mechupgrades\s.lua:1: '<name>' expected near '(' [2014-06-18 12:21:37] ERROR: Loading script failed: mechupgrades\s.lua:1: '<name>' expected near '(' [2014-06-18 12:21:37] mechupgrades restarted successfully [2014-06-18 12:21:42] ERROR: Client ((S.W.A.T)Mr.Toff) triggered serverside event givenitro, but event is not added serverside [2014-06-18 12:22:35] ERROR: Client ((S.W.A.T)Mr.Toff) triggered serverside event givenitro, but event is not added serverside [2014-06-18 12:28:16] ADMIN: Resource 'mechupgrades' restarted by (S.W.A.T)Mr.Toff(toff) and i don't see where on line 1 it needs a close bracket Link to comment
diesel974 Posted June 18, 2014 Share Posted June 18, 2014 Im not sure if its really an error but anyway, you wrote "Cylinder" instead of "cylinder" in client script, line 1. In your debugscript, [2014-06-18 12:21:37] SCRIPT ERROR: mechupgrades\s.lua:1: '' expected near '(' = its sayin that you have not given a name to the function ( O_o or you have not name the function)( bad english, sorry ) so for example. you can write : function settingElementData () setElementData(source,"Nitro",0) setElementData(source,"Fix",0) setElementData(source,"Colour",0) end Link to comment
diesel974 Posted June 18, 2014 Share Posted June 18, 2014 And also, as far as i know, 100 is always greater than 0, isnt it ( server script, line 64) client side now, line 64 (again 64 wat a coincidence xxD) triggerServerEvent ( "giveNitro", localPlayer, guiGetText( GUIEditor_gridlist[1], 1, 1)) You are triggering the server and sending guiGetText(GUIEditor_gridlist[1], 1, 1)) as argument, still good, but in your serverside, addEvent("giveNitro",true) addEventHandler("giveNitro",root, function () if (tonumber(100) > 0) then if ( getPlayerMoney (source) >= 100 ) then takePlayerMoney(source, 100) local acc = getPlayerAccount ( source ) setElementData(source,"Nitro",getElementData(source,"Nitro")+number) setAccountData(acc,"Nitro",getElementData(source,"Nitro")) else outputChatBox("You do not have enough money to buy Nitro",source,255,0,0,false) end end end ) in line 3 here, you are not puttin the argument within brackets O_o and it should be like this : addEvent("giveNitro",true) addEventHandler("giveNitro",root, function (number) -- lets say number for example for the argument if (tonumber(100) > 0) then if ( getPlayerMoney (source) >= 100 ) then takePlayerMoney(source, 100) local acc = getPlayerAccount ( source ) setElementData(source,"Nitro",getElementData(source,"Nitro")+number) setAccountData(acc,"Nitro",getElementData(source,"Nitro")) else outputChatBox("You do not have enough money to buy Nitro",source,255,0,0,false) end end end ) Now, when i looked below your serverside, i saw line 76 to 89 and actually there is an important part in it, you had put the argument within brackets, but i dont know why you have added 100 too. Also, in your serverside script, line 68 you wrote setElementData(source,"Nitro",getElementData(source,"Nitro")+number) but number is not defined so maybe this can also be the error. Now, try to do this: addEvent("giveNitro",true) addEventHandler("giveNitro",root, function (number) -- lets say number for example 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 ) I tried to help you as much as i can, but a little advice, when you are testing try to use functions which outputs messages like outputChatBox or outputDebugString or outputServerLog for debugging, add as much as you can to see till where the codes is functionning. (again, sorry for my bad english ) Link to comment
Toffbrown Posted June 18, 2014 Author Share Posted June 18, 2014 i tried that but says the same error not executing serverside Link to comment
diesel974 Posted June 18, 2014 Share Posted June 18, 2014 aww ok line 64 client side triggerServerEvent ( "giveNitro", localPlayer, guiGetText( GUIEditor_gridlist[1], 1, 1)) try to use getLocalPlayer() instead of localPlayer. Also server side, when u use addEvent("giveNitro",true) addEventHandler("giveNitro",root, function (number) -- lets say number for example 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 ) try to add outputChatBox("this is alright",client) between line 3 and 4. If you see this in chat( this is alright) , you know that its working Link to comment
diesel974 Posted June 18, 2014 Share Posted June 18, 2014 Try to see if there are any other errors in debugscript plz, maybe i did not see any other error Link to comment
Toffbrown Posted June 18, 2014 Author Share Posted June 18, 2014 you can't use local player with server side though Link to comment
diesel974 Posted June 18, 2014 Share Posted June 18, 2014 nah LOL, i mean in the client side, change the localPlayer to getLocalPlayer() in the triggerServerEvent Link to comment
Toffbrown Posted June 18, 2014 Author Share Posted June 18, 2014 oh aha sorry about that It output fine still error [2014-06-18 19:01:39] ADMIN: Resource 'mechupgrades' restarted by Mr.Toff(toff) [2014-06-18 19:01:39] Stopping mechupgrades [2014-06-18 19:01:39] Resource 'mechupgrades' changed, reloading and starting [2014-06-18 19:01:40] Starting mechupgrades [2014-06-18 19:01:40] SCRIPT ERROR: mechupgrades\s.lua:1: '<name>' expected near '(' [2014-06-18 19:01:40] ERROR: Loading script failed: mechupgrades\s.lua:1: '<name>' expected near '(' [2014-06-18 19:01:40] mechupgrades restarted successfully [2014-06-18 19:01:54] ERROR: Client (Mr.Toff) triggered serverside event giveNitro, but event is not added serverside [2014-06-18 19:02:02] SCRIPT: Mr.Toff(toff) set his script debug mode to 3 [2014-06-18 19:02:06] ADMIN: Resource 'mechupgrades' restarted by Mr.Toff(toff) [2014-06-18 19:02:06] Stopping mechupgrades [2014-06-18 19:02:06] Starting mechupgrades [2014-06-18 19:02:06] SCRIPT ERROR: mechupgrades\s.lua:1: '<name>' expected near '(' [2014-06-18 19:02:06] ERROR: Loading script failed: mechupgrades\s.lua:1: '<name>' expected near '(' [2014-06-18 19:02:06] mechupgrades restarted successfully [2014-06-18 19:02:16] ERROR: Client (Mr.Toff) triggered serverside event giveNitro, but event is not added serverside Link to comment
diesel974 Posted June 18, 2014 Share Posted June 18, 2014 post the full script plz, both client and server side Link to comment
Toffbrown Posted June 18, 2014 Author Share Posted June 18, 2014 thanks for helping me man Client 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 ) outputChatBox("this is alright",client) 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) triggerServerEvent ( "giveNitro", getLocalPlayer(), guiGetText( GUIEditor_gridlist[1], 1, 1)) 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 ) Server function() setElementData(source,"Nitro",0) setElementData(source,"Fix",0) setElementData(source,"Colour",0) end) addEventHandler("onResourceStart",resourceRoot, function() 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 ) 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 ) 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 ) addEvent("giveNitro",true) addEventHandler("giveNitro",root, function (number) -- lets say number for example 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 ) -------addEvent("givenitro",true) --addEventHandler("givenitro",root, --function (money,100) --if (tonumber(number) > 0) then --if ( getPlayerMoney (source) >= 100 ) then ---takePlayerMoney(source, 100) --local acc = getPlayerAccount ( source ) ---setElementData(source,"Nitro",getElementData(source,"Nito")+number) --setAccountData(acc,"Nitro",getElementData(source,"Nitro")) --else ---outputChatBox("You do not have enough money to buy Nitro",source,255,0,0,false) ---end --end ---end Link to comment
Et-win Posted June 18, 2014 Share Posted June 18, 2014 function() setElementData(source,"Nitro",0) setElementData(source,"Fix",0) setElementData(source,"Colour",0) end) First rule you forgot the function his name. Also remove the ')' at the last end. But if I see the way how you script, you forgot addEventHandler? Link to comment
diesel974 Posted June 18, 2014 Share Posted June 18, 2014 man (( you forgot totally wat i told u since the beginning ok, np here it is : 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) triggerServerEvent ( "giveNitro", getLocalPlayer(), guiGetText( GUIEditor_gridlist[1], 1, 1)) 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 ) function trololo() setElementData(source,"Nitro",0) setElementData(source,"Fix",0) setElementData(source,"Colour",0) end addEventHandler("onResourceStart",resourceRoot, function() 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 ) 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 ) 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 ) addEvent("giveNitro",true) addEventHandler("giveNitro",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 ) -------addEvent("givenitro",true) --addEventHandler("givenitro",root, --function (money,100) --if (tonumber(number) > 0) then --if ( getPlayerMoney (source) >= 100 ) then ---takePlayerMoney(source, 100) --local acc = getPlayerAccount ( source ) ---setElementData(source,"Nitro",getElementData(source,"Nito")+number) --setAccountData(acc,"Nitro",getElementData(source,"Nitro")) --else ---outputChatBox("You do not have enough money to buy Nitro",source,255,0,0,false) ---end --end ---end Link to comment
Toffbrown Posted June 18, 2014 Author Share Posted June 18, 2014 Exact same error and i tried changing the Cylinder to cylinder but thats changes nothing and still says server side is not added when you guys can even clearly see i added it, Do you have an idea of how i can do it differently, i have a NPC who the player buys say nitro and then he can apply it later on to his car Link to comment
diesel974 Posted June 18, 2014 Share Posted June 18, 2014 man, i did not change Cylinder to cylinder only!!! try to compare your serverside script with the one i have given u above Link to comment
Toffbrown Posted June 18, 2014 Author Share Posted June 18, 2014 Oh i know that but it was referring to what you said previous, and still does not work IDK what we did wrong Link to comment
diesel974 Posted June 18, 2014 Share Posted June 18, 2014 Tell me something, when you used the code that i gave you, did you see this line in your chat : trololooooo giveNitro was triggered. ?????? Link to comment
diesel974 Posted June 18, 2014 Share Posted June 18, 2014 oka, now use the same code im going to give you. 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") triggerServerEvent ( "giveboomnitro", getLocalPlayer(), guiGetText( GUIEditor_gridlist[1], 1, 1)) 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 ) serverside : function trololo() setElementData(source,"Nitro",0) setElementData(source,"Fix",0) setElementData(source,"Colour",0) end addEventHandler("onResourceStart",resourceRoot, function() 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 ) 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 ) 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 ) 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 ) -------addEvent("givenitro",true) --addEventHandler("givenitro",root, --function (money,100) --if (tonumber(number) > 0) then --if ( getPlayerMoney (source) >= 100 ) then ---takePlayerMoney(source, 100) --local acc = getPlayerAccount ( source ) ---setElementData(source,"Nitro",getElementData(source,"Nito")+number) --setAccountData(acc,"Nitro",getElementData(source,"Nitro")) --else ---outputChatBox("You do not have enough money to buy Nitro",source,255,0,0,false) ---end --end ---end copy the whole code, dont do any changes in them. try it now, and plz, when you are going to post again here, put the errors in debugscript too, maybe im missing an error here Link to comment
Toffbrown Posted June 18, 2014 Author Share Posted June 18, 2014 outputChatBox("same here too") and outputChatBox("ok, here is ok too") worked but still says [2014-06-18 23:48:43] ERROR: Client (Mr.Toff) triggered serverside event giveboomnitro, but event is not added serverside Link to comment
diesel974 Posted June 18, 2014 Share Posted June 18, 2014 Check if your meta is good too, cause now, i really dont know what is going wrong I tried my maximum to help you Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now