Jump to content

Arms Dealer Script Help


damien111

Recommended Posts

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

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

I couldnt find it :S

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? :S 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
  • 6 months later...
  • Moderators

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
  • Moderators

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
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
  • 3 weeks later...

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