damien111 Posted August 16, 2012 Share Posted August 16, 2012 i am trying to make a arms dealer script but i am not sure how to make it so the script cant tell the diffrent between the seller and buyer so it knows who to take money from who to give money to. any advice will be greatly appriciated also. Thanks in advance SERVER CODE: --server addEvent("buyAK", true) addEventHandler("buyAK",root,BuyAK47) addEvent("buyCOLT", true) addEventHandler("buyCOLT",root,BuyCOLT) addEvent("buySHOTTY", true) addEventHandler("buySHOTTY",root,BuySHOTTY) addEvent("buyMolotov", true) addEventHandler("buyMolotov",root,BuyMOLOTOV) addEvent("buySAWNOFF", true) addEventHandler("buySAWNOFF",root,BuySAWNOFF) addEvent("buyUZI", true) ddEventHandler("buyUZI",root,BuyUZI) addEvent("buyTEC9", true) addEventHandler("buyTEC9",root,BuyTEC9) addEvent("buyCBSHOTTY", true) addEventHandler("buyCBSHOTTY",root,BuyCBSHOTTY) function BuyAK47 ( ) givePlayerMoney ( source, 2000 ) giveWeapon ( source, 30, 200, false ) end function BuyCOLT ( ) givePlayerMoney ( source, 500 ) giveWeapon ( source, 22, 200, false ) end function BuySHOTTY ( ) givePlayerMoney ( source, 500 ) giveWeapon ( source, 25, 200, false ) end function BuyMOLOTOV ( ) givePlayerMoney ( source, 500 ) giveWeapon ( source, 18, 200, false ) end function BuySAWNOFF ( ) givePlayerMoney ( source, 1000 ) giveWeapon ( source, 26, 200, false ) end function BuyUZI ( ) givePlayerMoney ( source, 1000 ) giveWeapon ( source, 28, 200, false ) end function BuyTEC9 ( ) givePlayerMoney ( source, 1500 ) giveWeapon ( source, 32, 200, false ) end function BuyCBSHOTTY ( ) givePlayerMoney ( source, 3000 ) giveWeapon ( source, 27, 200, false ) end CLIENT CODE --Client GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Window[1] = guiCreateWindow(170,126,498,328,"Gun Menu",false) GUIEditor_Button[1] = guiCreateButton(16,30,219,44,"AK47 - 2000",false,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(15,84,222,42,"Colt - 500",false,GUIEditor_Window[1]) GUIEditor_Button[3] = guiCreateButton(15,135,223,42,"Molotov - 500",false,GUIEditor_Window[1]) GUIEditor_Button[4] = guiCreateButton(14,188,224,40,"Sawn Off Shotgun - 1000",false,GUIEditor_Window[1]) GUIEditor_Button[5] = guiCreateButton(14,240,225,40,"Shotgun - 500",false,GUIEditor_Window[1]) GUIEditor_Button[6] = guiCreateButton(258,28,219,44,"Uzi - 1000",false,GUIEditor_Window[1]) GUIEditor_Button[7] = guiCreateButton(258,82,219,42,"Tec9 - 1500",false,GUIEditor_Window[1]) GUIEditor_Button[8] = guiCreateButton(255,135,225,42,"Combat Shotgun - 3000",false,GUIEditor_Window[1]) GUIEditor_Button[9] = guiCreateButton(309,279,178,38,"Close",false,GUIEditor_Window[1]) addEventHandler("onClientGUIClick", GUIEditor_Button[1] , buyAK47, false) addEventHandler("onClientGUIClick", GUIEditor_Button[9] , showGUI, false) function showGUI ( ) --markerhit guiSetVisible(GUIEditor_Window[1], true) showCursor(true) end function closeGUI ( ) --cancle button guiSetVisible(GUIEditor_Window[1], false) showCursor(false) end function buyAK47 () triggerServerEvent("buyAK",localPlayer) end function buyCOLT () triggerServerEvent("buyCOLT",localPlayer) end function buySHOTTY () triggerServerEvent("buySHOTTY",localPlayer) end function buyMolotov () triggerServerEvent("buyMolotov" localPlayer) end function buySAWNOFF () triggerServerEvent("buySAWNOFF",localPlayer) end function buyUZI () triggerServerEvent("buyUZI",localPlayer) end function buyTEC9 () triggerServerEvent("buyTEC9",localPlayer) end function buyCBSHOTTY () triggerServerEvent("buyCBSHOTTY",localPlayer) end function openshop(source,command) local x, y, z = getElementPosition ( thePlayer )selling = createMarker ( x, y, z [, "Cylinder", 4.0, 255, 0, 0, 255 ] ) addEventHandler("onMarkerHit", Marker2, showGUI() end end addCommandHandler("/sell", openshop) Meta: "Damien" name="mechanic" version="0.1" type="script"/> Link to comment
Castillo Posted August 16, 2012 Share Posted August 16, 2012 The event handlers should go after functions, also, you have: "ddEventHandler" in one ( missing 'a' ). Link to comment
damien111 Posted August 16, 2012 Author Share Posted August 16, 2012 (edited) deleted Edited July 3, 2014 by Guest Link to comment
Castillo Posted August 16, 2012 Share Posted August 16, 2012 addCommandHandler("/sell", openshop) That's wrong too, it should be "sell", because the default is "/sell" already. Link to comment
damien111 Posted August 16, 2012 Author Share Posted August 16, 2012 (edited) deleted Edited July 3, 2014 by Guest Link to comment
Castillo Posted August 16, 2012 Share Posted August 16, 2012 You are creating the marker client side, others won't be able to see it. You should make the markers server side, then when a player hits, store it on a table, like: Global: sellingPlayers = { } Inside function: sellingPlayers [ markerOwner ] = thePlayerWhoHitTheMarker Link to comment
damien111 Posted August 16, 2012 Author Share Posted August 16, 2012 Ok. Then how do i make it when the marker is hit it shows the GUI Link to comment
damien111 Posted August 16, 2012 Author Share Posted August 16, 2012 Ok, im confused with the table idea, how do i do this? Can you send me to a example on wiki or another topic. Link to comment
Castillo Posted August 16, 2012 Share Posted August 16, 2012 I already posted an example, you can search for table examples in Lua at google. Link to comment
damien111 Posted August 16, 2012 Author Share Posted August 16, 2012 I couldnt find it Heres my code also, i was testing to see if the command would make the marker also how can you limit it so ppl can only make 1 marker? Sorry for all the noob questions. function openshop(source,command) local x, y, z = getElementPosition ( thePlayer ) selling = createMarker ( x, y, z [, "Cylinder", 4.0, 255, 0, 0, 255 ] ) end function spawnveh ( hitElement, matchingDimension ) local elementType = getElementType ( hitElement ) if ( elementType == "player" ) then triggerClientEvent("showGUI",localPlayer) guiSetVisible(windowjob, true) showCursor(true) end end sellingPlayers = { } function getbuyer () sellingPlayers [ markerOwner ] = thePlayerWhoHitTheMarker end addCommandHandler("sell", openshop) function BuyAK47 ( ) givePlayerMoney ( source, 2000 ) giveWeapon ( source, 30, 200, false ) end function BuyCOLT ( ) givePlayerMoney ( source, 500 ) giveWeapon ( source, 22, 200, false ) end function BuySHOTTY ( ) givePlayerMoney ( source, 500 ) giveWeapon ( source, 25, 200, false ) end function BuyMOLOTOV ( ) givePlayerMoney ( source, 500 ) giveWeapon ( source, 18, 200, false ) end function BuySAWNOFF ( ) givePlayerMoney ( source, 1000 ) giveWeapon ( source, 26, 200, false ) end function BuyUZI ( ) givePlayerMoney ( source, 1000 ) giveWeapon ( source, 28, 200, false ) end function BuyTEC9 ( ) givePlayerMoney ( source, 1500 ) giveWeapon ( source, 32, 200, false ) end function BuyCBSHOTTY ( ) givePlayerMoney ( source, 3000 ) giveWeapon ( source, 27, 200, false ) end --server addEvent("buyAK", true) addEventHandler("buyAK",root,BuyAK47) addEvent("buyCOLT", true) addEventHandler("buyCOLT",root,BuyCOLT) addEvent("buySHOTTY", true) addEventHandler("buySHOTTY",root,BuySHOTTY) addEvent("buyMolotov", true) addEventHandler("buyMolotov",root,BuyMOLOTOV) addEvent("buySAWNOFF", true) addEventHandler("buySAWNOFF",root,BuySAWNOFF) addEvent("buyUZI", true) ddEventHandler("buyUZI",root,BuyUZI) addEvent("buyTEC9", true) addEventHandler("buyTEC9",root,BuyTEC9) addEvent("buyCBSHOTTY", true) addEventHandler("buyCBSHOTTY",root,BuyCBSHOTTY) --Client GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Window[1] = guiCreateWindow(170,126,498,328,"Gun Menu",false) GUIEditor_Button[1] = guiCreateButton(16,30,219,44,"AK47 - 2000",false,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(15,84,222,42,"Colt - 500",false,GUIEditor_Window[1]) GUIEditor_Button[3] = guiCreateButton(15,135,223,42,"Molotov - 500",false,GUIEditor_Window[1]) GUIEditor_Button[4] = guiCreateButton(14,188,224,40,"Sawn Off Shotgun - 1000",false,GUIEditor_Window[1]) GUIEditor_Button[5] = guiCreateButton(14,240,225,40,"Shotgun - 500",false,GUIEditor_Window[1]) GUIEditor_Button[6] = guiCreateButton(258,28,219,44,"Uzi - 1000",false,GUIEditor_Window[1]) GUIEditor_Button[7] = guiCreateButton(258,82,219,42,"Tec9 - 1500",false,GUIEditor_Window[1]) GUIEditor_Button[8] = guiCreateButton(255,135,225,42,"Combat Shotgun - 3000",false,GUIEditor_Window[1]) GUIEditor_Button[9] = guiCreateButton(309,279,178,38,"Close",false,GUIEditor_Window[1]) addEventHandler("onClientGUIClick", GUIEditor_Button[1] , buyAK47, false) addEventHandler("onClientGUIClick", GUIEditor_Button[9] , showGUI, false) function showGUI ( ) --markerhit guiSetVisible(GUIEditor_Window[1], true) showCursor(true) end addEvent("showGUI", true) addEventHandler("showGUI",root,BuyAK47) function closeGUI ( ) --cancle button guiSetVisible(GUIEditor_Window[1], false) showCursor(false) end function buyAK47 () triggerServerEvent("buyAK",localPlayer) end function buyCOLT () triggerServerEvent("buyCOLT",localPlayer) end function buySHOTTY () triggerServerEvent("buySHOTTY",localPlayer) end function buyMolotov () triggerServerEvent("buyMolotov" localPlayer) end function buySAWNOFF () triggerServerEvent("buySAWNOFF",localPlayer) end function buyUZI () triggerServerEvent("buyUZI",localPlayer) end function buyTEC9 () triggerServerEvent("buyTEC9",localPlayer) end function buyCBSHOTTY () triggerServerEvent("buyCBSHOTTY",localPlayer) end Link to comment
panos144 Posted March 5, 2013 Share Posted March 5, 2013 SCRIPT ERROR:armsdealer/server.lua:3: unexpected symbol near ',' WARNING: Loading script failed: armsdealer/server.lua:3: unexpected symbol near ',' Link to comment
Moderators IIYAMA Posted March 6, 2013 Moderators Share Posted March 6, 2013 selling = createMarker ( x, y, z [, "Cylinder", 4.0, 255, 0, 0, 255 ] ) must be: selling = createMarker ( x, y, z, "Cylinder", 4.0, 255, 0, 0, 255 ) He forgot to remove the " [] " from the wiki. Link to comment
panos144 Posted March 6, 2013 Share Posted March 6, 2013 now it say: WARNING: armsdealer/server.lua:3: Bad argument 'createMarker' WARNING: armsdealer/server.lua:3: Bad argument 'getElementPosition' Link to comment
Moderators IIYAMA Posted March 6, 2013 Moderators Share Posted March 6, 2013 (edited) omfg server side. selling = createMarker (getElementPosition ( source ) , "Cylinder", 4.0, 255, 0, 0, 255 ) UPDATED Edited March 6, 2013 by Guest Link to comment
panos144 Posted March 6, 2013 Share Posted March 6, 2013 nothing again it say: WARNING: armsdealer/server.lua:3: Bad argument 'createMarker' WARNING: armsdealer/server.lua:3: Bad argument 'getElementPosition' Link to comment
panos144 Posted March 6, 2013 Share Posted March 6, 2013 now it isn't say nothing but i can't sell Link to comment
Moderators IIYAMA Posted March 6, 2013 Moderators Share Posted March 6, 2013 use: outputDeBugString ("till here"), in your code. so you can see with /debugscript 3 what went wrong. Link to comment
panos144 Posted March 6, 2013 Share Posted March 6, 2013 the resource you mean? if no then can you send me the code plase? Link to comment
Moderators IIYAMA Posted March 6, 2013 Moderators Share Posted March 6, 2013 I mean add this in your code so scripters can help you more. Because I am not going to read your whole script. I have other things to do. 1 add outputDeBugString in your script. Like this: function myfunction outputDebugString ("myfunction got started") end 2 : login as admin 3 : write /debugscript 3 and see how far your script goes, etc. Link to comment
iPrestege Posted March 6, 2013 Share Posted March 6, 2013 I mean add this in your code so scripters can help you more. Because I am not going to read your whole script. I have other things to do.1 add outputDeBugString in your script. Like this: function myfunction outputDebugString ("myfunction got started") end 2 : login as admin 3 : write /debugscript 3 and see how far your script goes, etc. () ?? Link to comment
panos144 Posted March 28, 2013 Share Posted March 28, 2013 now working but if i start the arms dealer script then the window open to my screen and it doesn't close Link to comment
iPrestege Posted March 28, 2013 Share Posted March 28, 2013 Post the part that does not work with you here. 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