FWCentral Posted November 16, 2011 Share Posted November 16, 2011 Hey im creating an arms dealer script and im not sure how i can get the marker directly in front of the player that wants to sell at the moment its just inside the player using getElementPosition Also, I can take the players money but how do i give the other player that is selling money? Link to comment
TAPL Posted November 16, 2011 Share Posted November 16, 2011 what? selling money? maybe you mean this givePlayerMoney and to marker use this attachElements Link to comment
FWCentral Posted November 16, 2011 Author Share Posted November 16, 2011 Hey thanks for the reply, i wrote that at like 4am haha. Anyway ill try using that and get back here. Link to comment
FWCentral Posted November 16, 2011 Author Share Posted November 16, 2011 Meh i cant get it to work, Sorry to double post but no one will reply if i edit. server: function sell(source, commaneName) local x,y,z = getElementPosition(source) thearmsmark = createMarker( x, y, z, "cylinder", 1.5, 255, 255, 0, 170 ) --setElementData(thearmsmark, "owner", getPlayerName(source)) setElementParent(thearmsmark, source) end addCommandHandler("sell", sell) addEvent("buygunuzi",true) function buyuzi(source) if isElementWithinMarker(source, thearmsmark) then local seller = getElementParent(thearmsmark) takePlayerMoney(source, 170) giveWeapon(source,28,50,false) end end addEventHandler("buygunuzi",getRootElement(),buyuzi) Client: local weapon = guiGridListGetItemText ( weapongridlist, guiGridListGetSelectedItem ( weapongridlist ),1) if weapon == "Uzi" then local money = getPlayerMoney(getLocalPlayer()) if (money > 170) then triggerServerEvent("buygunuzi", getLocalPlayer()) else end end The client side works fine but i get an error at: if isElementWithinMarker(source, thearmsmark) then Link to comment
TAPL Posted November 16, 2011 Share Posted November 16, 2011 local weapon = guiGridListGetItemText ( weapongridlist, guiGridListGetSelectedItem ( weapongridlist ),1) if weapon == "Uzi" then local money = getPlayerMoney() if (money > 170) then triggerServerEvent("buygunuzi", getLocalPlayer()) else end end function sell(source, commaneName) local x,y,z = getElementPosition(source) thearmsmark = createMarker( x, y, z, "cylinder", 1.5, 255, 255, 0, 170 ) --setElementData(thearmsmark, "owner", getPlayerName(source)) setElementParent(thearmsmark, source) end addCommandHandler("sell", sell) addEvent("buygunuzi",true) function buyuzi() if isElementWithinMarker(source, thearmsmark) then local seller = getElementParent(thearmsmark) takePlayerMoney(source, 170) giveWeapon(source,28,50,false) end end addEventHandler("buygunuzi",getRootElement(),buyuzi) Link to comment
FWCentral Posted November 16, 2011 Author Share Posted November 16, 2011 where was the error? Link to comment
TAPL Posted November 16, 2011 Share Posted November 16, 2011 local money = getPlayerMoney(getLocalPlayer()) local money = getPlayerMoney() ================================================== function buyuzi(source) function buyuzi() Link to comment
12p Posted November 16, 2011 Share Posted November 16, 2011 FWCentral, please read carefully this: https://wiki.multitheftauto.com/wiki/GetPlayerMoney Link to comment
FWCentral Posted May 21, 2012 Author Share Posted May 21, 2012 Back to this again I got a problem, When i create the marker i made it like this trying to put it in a table: thearmsmark = {} thearmsmark[getPlayerName(source)] = createMarker( x, y, z, "cylinder", 1.2, 255, 0, 0, 170 ) it creates the first marker and lets the player sell fine, but then when you try to do it a second time it wont let you, It will create the marker but you cant buy from the player and im not sure whats up with it because there is no errors Link to comment
Castillo Posted May 21, 2012 Share Posted May 21, 2012 Maybe posting the whole script would help. P.S: Never use player names, players keep's changing their name, better use the player element itself. Link to comment
FWCentral Posted May 21, 2012 Author Share Posted May 21, 2012 Selling: thearmsmark = {} function sell(source, commaneName) setElementFrozen(source, true) local x,y,z = getElementPosition(source) thearmsmark[source] = createMarker( x, y, z, "cylinder", 1.2, 255, 0, 0, 170 ) setElementData(source,"SellingArms", true) setElementData(thearmsmark[source], "ownedby", getPlayerName(source)) end Buying: function buy(source) local x,y,z = getElementPosition(source) local colshape1 = createColSphere(x-3,y+3,z-4,10) local players = getElementsWithinColShape ( colshape1, "player" ) for i,seller in ipairs(players) do if getElementData(seller, "SellingArms") == true then if isElementWithinMarker(source, thearmsmark[seller]) then setElementData(source,"BuyingArmsFrom", getPlayerName(seller)) triggerClientEvent("showarmspanelARMS", source) destroyElement(colshape1) else end end end end changed it to the element too thanks Link to comment
X-SHADOW Posted May 21, 2012 Share Posted May 21, 2012 function buy() local x,y,z = getElementPosition(source) local colshape1 = createColSphere(x-3,y+3,z-4,10) local players = getElementsWithinColShape ( colshape1, "player" ) for i,seller in ipairs(players) do if getElementData(seller, "SellingArms") == true then if isElementWithinMarker(source, thearmsmark[seller]) then setElementData(source,"BuyingArmsFrom", getPlayerName(seller)) triggerClientEvent("showarmspanelARMS", source) destroyElement(colshape1) end end end end Link to comment
FWCentral Posted May 21, 2012 Author Share Posted May 21, 2012 the buy works the first time so say i type /sell then anyone can buy from me, But then if i stop selling sell again no one can buy. Link to comment
X-SHADOW Posted May 21, 2012 Share Posted May 21, 2012 i dont get what you mean you want if you type /sell every player can buy? and when you type / buy every player can sell ? Link to comment
FWCentral Posted May 21, 2012 Author Share Posted May 21, 2012 No i mean 1. I type /sell - It creates the marker and players can come and /buy 2. I stop selling the marker is destroyed 3. i try to /sell again - the marker comes but when a player types /buy they cant Link to comment
X-SHADOW Posted May 21, 2012 Share Posted May 21, 2012 can you pm me the full script ? Link to comment
FWCentral Posted May 21, 2012 Author Share Posted May 21, 2012 Why what else is needed? the rest is just the gui and giving weapons+money and removing all of the markers that are "ownedby" the player Link to comment
Jaysds1 Posted May 21, 2012 Share Posted May 21, 2012 try this: thearmsmark = {} function sell(source, commaneName) setElementFrozen(source, true) local x,y,z = getElementPosition(source) thearmsmark[source] = createMarker( x, y, z, "cylinder", 1.2, 255, 0, 0, 170 ) setElementData(source,"SellingArms", true) setElementData(thearmsmark[source], "ownedby", getPlayerName(source)) end function buy(source) local x,y,z = getElementPosition(source) local colshape1 = createColSphere(x-3,y+3,z-4,10) for i,seller in ipairs(getElementsWithinColShape ( colshape1, "player" )) do if getElementData(seller, "SellingArms") == true then if isElementWithinMarker(source, thearmsmark[seller]) then setElementData(source,"BuyingArmsFrom", getPlayerName(seller)) triggerClientEvent(source,"showarmspanelARMS",root) destroyElement(colshape1) else end end end end BTW, Why do you need the colshape? Link to comment
FWCentral Posted May 21, 2012 Author Share Posted May 21, 2012 to get the players name that's selling to put it in the thearmsmark[seller] part and for some reason if a player stands in front of the seller then they type /sell they can /buy Link to comment
Jaysds1 Posted May 21, 2012 Share Posted May 21, 2012 Can you pm me the server, so I can go on it? EDIT: It's fixed 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