Adde Posted February 26, 2013 Share Posted February 26, 2013 Hello I have a big problem... On my zombie server players can buy weapons for etc 12000$ and reconnect or kill a zombie then they get their money back. It happends every time. I looked through "weaponshop" and script for problems but I couldn´t find anything and I tried to find out in wich script the bug was, but i didn´t find it. Some suggestions? Link to comment
DiSaMe Posted February 26, 2013 Share Posted February 26, 2013 Are you setting the money on the client rather than server? If you do, then you're not really setting it - client-side money functions only change the value which the player sees, not the one which is kept in the server. Link to comment
Adde Posted February 26, 2013 Author Share Posted February 26, 2013 Aha okay. The "takePlayerMoney" is in client and "giveWeapon" is in server. Sooo I must switch these so Money is set as server and weapon in client? Link to comment
Moderators IIYAMA Posted February 26, 2013 Moderators Share Posted February 26, 2013 no, everything server. Gui of course client etc. Link to comment
Adde Posted February 26, 2013 Author Share Posted February 26, 2013 aaha. Okay, so that´s why it don´t work. But I can´t separate money and move it to server. It´s together with gui in client. The original script is from community "weapon_shop" and I can not script good if I say so. The wierd is that there was no complaining in script comments. I have it like this: Server: marker1 = createMarker (295.48,-80.38,1000.51,"cylinder",1.5,0,0,225,100) marker2 = createMarker (295.48,-80.38,1000.51,"cylinder",1.5,0,0,225,100) marker3 = createMarker (295.48,-80.38,1000.51,"cylinder",1.5,0,0,225,100) marker4 = createMarker (295.09,-37.74,1000.51,"cylinder",1.5,0,0,225,100) marker5 = createMarker (204.6255,1860.6245,12.14,"cylinder",1.5,0,0,225,100) marker6 = createMarker (-3469.75,-204.72,11.70,"cylinder",1.5,0,0,225,100) blip1 = createBlip (237.61,-176.39,1.4,6,2,0,0,0,0,0,180) blip2 = createBlip (2161.68,944.79,11,6,2,0,0,0,0,0,180) blip3 = createBlip (-2624.31,208.57,4.6,6,2,0,0,0,0,0,180) blip4 = createBlip (1368.11,-1279.78,13.54,6,2,0,0,0,0,0,180) blip5 = createBlip (204.6255,1860.6245,13.14,6,2,0,0,0,0,0,180) ped1 = createPed (179,295,-83,1001.51 ) ped2 = createPed (179,295,-40.3,1001.51 ) ped3 = createPed (179,295.4,-82.6,1001.51 ) ped4 = createPed (179,295.4,-82.6,1001.51 ) setElementInterior(ped1,4) setElementInterior(ped2,1) setElementInterior(ped3,4) setElementInterior(ped4,4) setElementDimension(ped1,0) setElementDimension(ped2,0) setElementDimension(ped3,2) setElementDimension(ped4,4) setElementFrozen(ped1,true) setElementFrozen(ped2,true) setElementFrozen(ped3,true) setElementFrozen(ped4,true) setElementInterior (marker1,4) setElementInterior (marker2,4) setElementInterior (marker3,4) setElementInterior (marker4,1) setElementInterior (marker5,0) setElementInterior (marker6,0) setElementDimension (marker1,0) setElementDimension (marker2,2) setElementDimension (marker3,4) setElementDimension (marker4,0) setElementDimension (marker5,0) setElementDimension (marker6,0) function showGUI (jugador) if (source == marker1) then triggerClientEvent (jugador,"showGUI",getRootElement(),jugador) elseif (source == marker2) then triggerClientEvent (jugador,"showGUI",getRootElement(),jugador) elseif (source == marker3) then triggerClientEvent (jugador,"showGUI",getRootElement(),jugador) elseif (source == marker4) then triggerClientEvent (jugador,"showGUI",getRootElement(),jugador) elseif (source == marker5) then triggerClientEvent (jugador,"showGUI",getRootElement(),jugador) elseif (source == marker6) then triggerClientEvent (jugador,"showGUI",getRootElement(),jugador) end end addEventHandler ("onMarkerHit",getRootElement(),showGUI) function give45 () giveWeapon (source,22,51,true) end addEvent("give45",true) addEventHandler("give45",getRootElement(),give45) function givesilenced () giveWeapon (source,23,51,true) end addEvent("givesilenced",true) addEventHandler("givesilenced",getRootElement(),givesilenced) function givedeagle () giveWeapon (source,24,21,true) end addEvent("givedeagle",true) addEventHandler("givedeagle",getRootElement(),givedeagle) function givesh () giveWeapon (source,25,50,true) end addEvent("givesh",true) addEventHandler("givesh",getRootElement(),givesh) function giveso () giveWeapon (source,26,25,true) end addEvent("giveso",true) addEventHandler("giveso",getRootElement(),giveso) function giveSP () giveWeapon (source,27,35,true) end addEvent("giveSP",true) addEventHandler("giveSP",getRootElement(),giveSP) function givetec () giveWeapon (source,32,200,true) end addEvent("givetec",true) addEventHandler("givetec",getRootElement(),givetec) function giveuzi () giveWeapon (source,28,200,true) end addEvent("giveuzi",true) addEventHandler("giveuzi",getRootElement(),giveuzi) function givemp5 () giveWeapon (source,29,120,true) end addEvent("givemp5",true) addEventHandler("givemp5",getRootElement(),givemp5) function givem4 () giveWeapon (source,31,200,true) end addEvent("givem4",true) addEventHandler("givem4",getRootElement(),givem4) function giveak () giveWeapon (source,30,120,true) end addEvent("giveak",true) addEventHandler("giveak",getRootElement(),giveak) function givecs () giveWeapon (source,33,40,true) end addEvent("givecs",true) addEventHandler("givecs",getRootElement(),givecs) function gives () giveWeapon (source,34,40,true) end addEvent("gives",true) addEventHandler("gives",getRootElement(),gives) function givenade () giveWeapon (source,16,20,true) end addEvent("givenade",true) addEventHandler("givenade",getRootElement(),givenade) function givesat () giveWeapon (source,40,1,true) giveWeapon (source,39,10,true) end addEvent("givesat",true) addEventHandler("givesat",getRootElement(),givesat) function givecoc () giveWeapon (source,18,20,true) end addEvent("givecoc",true) addEventHandler("givecoc",getRootElement(),givecoc) function givegas () giveWeapon (source,17,10,true) end addEvent("givegas",true) addEventHandler("givegas",getRootElement(),givegas) function givekatana () giveWeapon (source,8,1,true) end addEvent("givekatana",true) addEventHandler("givekatana",getRootElement(),givekatana) function giveknife () giveWeapon (source,4,1,true) end addEvent("giveknife",true) addEventHandler("giveknife",getRootElement(),giveknife) function givemoto () giveWeapon (source,9,1,true) end addEvent("givemoto",true) addEventHandler("givemoto",getRootElement(),givemoto) function givex () giveWeapon (source,42,1000,true) end addEvent("givex",true) addEventHandler("givex",getRootElement(),givex) function givenv () giveWeapon (source,44,1,true) end addEvent("givenv",true) addEventHandler("givenv",getRootElement(),givenv) Client: GUIEditor_Window = {} GUIEditor_TabPanel = {} GUIEditor_Tab = {} GUIEditor_Button = {} addEventHandler ("onClientResourceStart",getResourceRootElement(getThisResource()), function() GUIEditor_Window[1] = guiCreateWindow(0.2,0.1602,0.6285,0.5862,"Weapons Shop (By Ruma)",true) guiSetAlpha(GUIEditor_Window[1],1) GUIEditor_Window[2] = guiCreateWindow(0.25,0.35,0.5,0.2,"UPS!",true) guiSetAlpha(GUIEditor_Window[2],1) guiBringToFront(GUIEditor_Window[2]) label = guiCreateLabel (0.35,0.25,0.5,0.2,"Not enough money for that weapon",true,GUIEditor_Window[2]) button = guiCreateButton (0.35,0.6,0.3,0.2,"ok",true,GUIEditor_Window[2]) GUIEditor_TabPanel[1] = guiCreateTabPanel(0.0161,0.1006,0.9678,0.8786,true,GUIEditor_Window[1]) guiSetAlpha(GUIEditor_TabPanel[1],1) GUIEditor_Tab[1] = guiCreateTab("Pistols",GUIEditor_TabPanel[1]) guiSetAlpha(GUIEditor_Tab[1],1) guiCreateStaticImage (0.051,0.2,0.2,0.25,"images/pistol.png",true,GUIEditor_Tab[1]) guiCreateStaticImage (0.4,0.2,0.2,0.25,"images/silenced.png",true,GUIEditor_Tab[1]) guiCreateStaticImage (0.75,0.2,0.2,0.25,"images/deagle.png",true,GUIEditor_Tab[1]) GUIEditor_Button[1] = guiCreateButton(0.025,0.5,0.2493,0.0934,"Pistol $free",true,GUIEditor_Tab[1]) guiSetAlpha(GUIEditor_Button[1],1) guiSetFont(GUIEditor_Button[1],"default-bold-small") GUIEditor_Button[2] = guiCreateButton(0.3786,0.5,0.2493,0.0934,"Silenced $500",true,GUIEditor_Tab[1]) guiSetAlpha(GUIEditor_Button[2],1) guiSetFont(GUIEditor_Button[2],"default-bold-small") GUIEditor_Button[3] = guiCreateButton(0.7204,0.5,0.2493,0.0934,"Desert Eagle $1000",true,GUIEditor_Tab[1]) guiSetAlpha(GUIEditor_Button[3],1) guiSetFont(GUIEditor_Button[3],"default-bold-small") GUIEditor_Tab[2] = guiCreateTab("Shotguns",GUIEditor_TabPanel[1]) guiSetAlpha(GUIEditor_Tab[2],1) guiCreateStaticImage (0.051,0.2,0.2,0.25,"images/shotgun.png",true,GUIEditor_Tab[2]) guiCreateStaticImage (0.4,0.2,0.2,0.25,"images/sawnoff.png",true,GUIEditor_Tab[2]) guiCreateStaticImage (0.75,0.2,0.2,0.25,"images/SPAZ-12.png",true,GUIEditor_Tab[2]) GUIEditor_Button[4] = guiCreateButton(0.025,0.5,0.2493,0.0934,"Shotgun $900",true,GUIEditor_Tab[2]) guiSetAlpha(GUIEditor_Button[4],1) guiSetFont(GUIEditor_Button[4],"default-bold-small") GUIEditor_Button[5] = guiCreateButton(0.3786,0.5,0.2493,0.0934,"Sawn off $1400",true,GUIEditor_Tab[2]) guiSetAlpha(GUIEditor_Button[5],1) guiSetFont(GUIEditor_Button[5],"default-bold-small") GUIEditor_Button[6] = guiCreateButton(0.7204,0.5,0.2493,0.0934,"SPAZ-12 $2200",true,GUIEditor_Tab[2]) guiSetAlpha(GUIEditor_Button[6],1) guiSetFont(GUIEditor_Button[6],"default-bold-small") GUIEditor_Tab[3] = guiCreateTab("SMG",GUIEditor_TabPanel[1]) guiSetAlpha(GUIEditor_Tab[3],1) guiCreateStaticImage (0.051,0.2,0.2,0.25,"images/tec9.png",true,GUIEditor_Tab[3]) guiCreateStaticImage (0.4,0.2,0.2,0.25,"images/uzi.png",true,GUIEditor_Tab[3]) guiCreateStaticImage (0.75,0.2,0.2,0.25,"images/mp5.png",true,GUIEditor_Tab[3]) GUIEditor_Button[7] = guiCreateButton(0.025,0.5,0.2493,0.0934,"TEC-9 $400",true,GUIEditor_Tab[3]) guiSetAlpha(GUIEditor_Button[7],1) guiSetFont(GUIEditor_Button[7],"default-bold-small") GUIEditor_Button[8] = guiCreateButton(0.3786,0.5,0.2493,0.0934,"Uzi $1400",true,GUIEditor_Tab[3]) guiSetAlpha(GUIEditor_Button[8],1) guiSetFont(GUIEditor_Button[8],"default-bold-small") GUIEditor_Button[9] = guiCreateButton(0.7204,0.5,0.2493,0.0934,"MP5 $1600",true,GUIEditor_Tab[3]) guiSetAlpha(GUIEditor_Button[9],1) guiSetFont(GUIEditor_Button[9],"default-bold-small") GUIEditor_Tab[4] = guiCreateTab("Rifle",GUIEditor_TabPanel[1]) guiSetAlpha(GUIEditor_Tab[4],1) guiCreateStaticImage (0.2,0.2,0.2,0.25,"images/M4.png",true,GUIEditor_Tab[4]) guiCreateStaticImage (0.58,0.2,0.2,0.25,"images/AK-47.png",true,GUIEditor_Tab[4]) GUIEditor_Button[10] = guiCreateButton(0.18,0.5,0.2493,0.0934,"M4 $5000",true,GUIEditor_Tab[4]) guiSetAlpha(GUIEditor_Button[10],1) guiSetFont(GUIEditor_Button[10],"default-bold-small") GUIEditor_Button[11] = guiCreateButton(0.556,0.5,0.2493,0.0934,"AK-47 $4000",true,GUIEditor_Tab[4]) guiSetAlpha(GUIEditor_Button[11],1) guiSetFont(GUIEditor_Button[11],"default-bold-small") GUIEditor_Tab[5] = guiCreateTab("Sniper",GUIEditor_TabPanel[1]) guiSetAlpha(GUIEditor_Tab[5],1) guiCreateStaticImage (0.2,0.2,0.2,0.25,"images/rifle.png",true,GUIEditor_Tab[5]) guiCreateStaticImage (0.58,0.2,0.2,0.25,"images/sniper.png",true,GUIEditor_Tab[5]) GUIEditor_Button[12] = guiCreateButton(0.18,0.5,0.2493,0.0934,"Country Sniper $2000",true,GUIEditor_Tab[5]) guiSetAlpha(GUIEditor_Button[12],1) guiSetFont(GUIEditor_Button[12],"default-bold-small") GUIEditor_Button[13] = guiCreateButton(0.556,0.5,0.2493,0.0934,"Sniper $5000",true,GUIEditor_Tab[5]) guiSetAlpha(GUIEditor_Button[13],1) guiSetFont(GUIEditor_Button[13],"default-bold-small") GUIEditor_Tab[7] = guiCreateTab("Thrown",GUIEditor_TabPanel[1]) guiSetAlpha(GUIEditor_Tab[7],1) guiCreateStaticImage (0.18,0.08,0.2,0.25,"images/teargas.png",true,GUIEditor_Tab[7]) guiCreateStaticImage (0.18,0.62,0.2,0.25,"images/nade.png",true,GUIEditor_Tab[7]) guiCreateStaticImage (0.61,0.08,0.2,0.25,"images/satchel.png",true,GUIEditor_Tab[7]) guiCreateStaticImage (0.61,0.62,0.2,0.25,"images/molotov.png",true,GUIEditor_Tab[7]) GUIEditor_Button[18] = guiCreateButton(0.1511,0.8861,0.2493,0.0934,"Granade $2000",true,GUIEditor_Tab[7]) guiSetAlpha(GUIEditor_Button[18],1) guiSetFont(GUIEditor_Button[18],"default-bold-small") GUIEditor_Button[19] = guiCreateButton(0.58022,0.34,0.2493,0.0934,"Satchel $2000",true,GUIEditor_Tab[7]) guiSetAlpha(GUIEditor_Button[19],1) guiSetFont(GUIEditor_Button[19],"default-bold-small") GUIEditor_Button[20] = guiCreateButton(0.58022,0.8884,0.2493,0.0934,"Coctel $1000",true,GUIEditor_Tab[7]) guiSetAlpha(GUIEditor_Button[20],1) guiSetFont(GUIEditor_Button[20],"default-bold-small") GUIEditor_Button[21] = guiCreateButton(0.1511,0.34,0.2493,0.0934,"Tear Gas $2000",true,GUIEditor_Tab[7]) guiSetAlpha(GUIEditor_Button[21],1) guiSetFont(GUIEditor_Button[21],"default-bold-small") GUIEditor_Tab[8] = guiCreateTab("Special",GUIEditor_TabPanel[1]) guiSetAlpha(GUIEditor_Tab[8],1) guiCreateStaticImage (0.18,0.08,0.2,0.25,"images/fireextintor.png",true,GUIEditor_Tab[8]) guiCreateStaticImage (0.18,0.62,0.2,0.25,"images/katana.png",true,GUIEditor_Tab[8]) guiCreateStaticImage (0.61,0.08,0.2,0.25,"images/night.png",true,GUIEditor_Tab[8]) guiCreateStaticImage (0.61,0.62,0.2,0.25,"images/chainsaw.png",true,GUIEditor_Tab[8]) GUIEditor_Button[22] = guiCreateButton(0.1511,0.8861,0.2493,0.0934,"Katana $600",true,GUIEditor_Tab[8]) guiSetAlpha(GUIEditor_Button[22],1) guiSetFont(GUIEditor_Button[22],"default-bold-small") GUIEditor_Button[24] = guiCreateButton(0.58022,0.8884,0.2493,0.0934,"Chain Saw $1200",true,GUIEditor_Tab[8]) guiSetAlpha(GUIEditor_Button[24],1) guiSetFont(GUIEditor_Button[24],"default-bold-small") GUIEditor_Button[25] = guiCreateButton(0.1511,0.34,0.2493,0.0934,"Extintor $1000",true,GUIEditor_Tab[8]) guiSetAlpha(GUIEditor_Button[25],1) guiSetFont(GUIEditor_Button[25],"default-bold-small") GUIEditor_Button[26] = guiCreateButton(0.58022,0.34,0.2493,0.0934,"Night Vision $600",true,GUIEditor_Tab[8]) guiSetAlpha(GUIEditor_Button[26],1) guiSetFont(GUIEditor_Button[26],"default-bold-small") GUIEditor_Button[29] = guiCreateButton(0.85,0.0574,0.1453,0.0854,"Exit",true,GUIEditor_Window[1]) guiSetAlpha(GUIEditor_Button[29],1) guiSetFont(GUIEditor_Button[29],"default-bold-small") GUIEditor_Button[30] = guiCreateButton(0,0,0.2453,0.0854,"Exit",true,GUIEditor_Window[2]) guiSetAlpha(GUIEditor_Button[30],1) guiSetFont(GUIEditor_Button[30],"default-bold-small") guiSetVisible (GUIEditor_Window[1],false) guiSetVisible (GUIEditor_Window[2],false) end) addEventHandler("onClientGUIClick",getRootElement(), function (player) if (source == GUIEditor_Button[29]) then guiSetVisible (GUIEditor_Window[1],false) showCursor (false) elseif (source == GUIEditor_Button[30]) then guiSetVisible (GUIEditor_Window[2],false) showCursor (false) elseif (source == GUIEditor_Button[1]) then money = getPlayerMoney (source) if (money >= 0) then player = getLocalPlayer() outputChatBox ("You bought a Pistol $0",225,225,0) takePlayerMoney(0) triggerServerEvent ("give45",getLocalPlayer(),give45) else guiSetVisible(GUIEditor_Window[2],true) guiSetVisible(GUIEditor_Window[1],false) end elseif (source == GUIEditor_Button[2]) then money = getPlayerMoney (source) if (money >= 500) then player = getLocalPlayer() outputChatBox ("You bought a Silenced $500",225,225,0) takePlayerMoney(500) triggerServerEvent ("givesilenced",getLocalPlayer(),givesilenced) else guiSetVisible(GUIEditor_Window[1],false) guiSetVisible(GUIEditor_Window[2],true) end elseif (source == GUIEditor_Button[3]) then money = getPlayerMoney (source) if (money >= 1000) then player = getLocalPlayer() outputChatBox ("You bought a Desert Eagle $1000",225,225,0) takePlayerMoney(1000) triggerServerEvent ("givedeagle",getLocalPlayer(),givedeagle) else guiSetVisible(GUIEditor_Window[1],false) guiSetVisible(GUIEditor_Window[2],true) end elseif (source == GUIEditor_Button[4]) then money = getPlayerMoney (source) if (money >= 900) then player = getLocalPlayer() outputChatBox ("You bought a Shotgun $900",225,225,0) takePlayerMoney(900) triggerServerEvent ("givesh",getLocalPlayer(),givesh) else guiSetVisible(GUIEditor_Window[1],false) guiSetVisible(GUIEditor_Window[2],true) end elseif (source == GUIEditor_Button[5]) then money = getPlayerMoney (source) if (money >= 1400) then player = getLocalPlayer() outputChatBox ("You bought a Sawn Off $1400",225,225,0) takePlayerMoney(1400) triggerServerEvent ("giveso",getLocalPlayer(),giveso) else guiSetVisible(GUIEditor_Window[1],false) guiSetVisible(GUIEditor_Window[2],true) end elseif (source == GUIEditor_Button[6]) then money = getPlayerMoney (source) if (money >= 2200) then player = getLocalPlayer() outputChatBox ("You bought a SPAZ-12 $2200",225,225,0) takePlayerMoney(2200) triggerServerEvent ("giveSP",getLocalPlayer(),giveSP) else guiSetVisible(GUIEditor_Window[1],false) guiSetVisible(GUIEditor_Window[2],true) end elseif (source == GUIEditor_Button[7]) then money = getPlayerMoney (source) if (money >= 400) then player = getLocalPlayer() outputChatBox ("You bought a Tec-9 $400",225,225,0) takePlayerMoney(400) triggerServerEvent ("givetec",getLocalPlayer(),givetec) else guiSetVisible(GUIEditor_Window[1],false) guiSetVisible(GUIEditor_Window[2],true) end elseif (source == GUIEditor_Button[8]) then money = getPlayerMoney (source) if (money >= 1400) then player = getLocalPlayer() outputChatBox ("You bought a Uzi $1400",225,225,0) takePlayerMoney(1400) triggerServerEvent ("giveuzi",getLocalPlayer(),giveuzi) else guiSetVisible(GUIEditor_Window[1],false) guiSetVisible(GUIEditor_Window[2],true) end elseif (source == GUIEditor_Button[9]) then money = getPlayerMoney (source) if (money >= 1600) then player = getLocalPlayer() outputChatBox ("You bought a MP5 $1600",225,225,0) takePlayerMoney(1600) triggerServerEvent ("givemp5",getLocalPlayer(),givemp5) else guiSetVisible(GUIEditor_Window[1],false) guiSetVisible(GUIEditor_Window[2],true) end elseif (source == GUIEditor_Button[11]) then money = getPlayerMoney (source) if (money >= 4000) then player = getLocalPlayer() outputChatBox ("You bought an AK-47 $4000",225,225,0) takePlayerMoney(4000) triggerServerEvent ("giveak",getLocalPlayer(),giveak) else guiSetVisible(GUIEditor_Window[1],false) guiSetVisible(GUIEditor_Window[2],true) end elseif (source == GUIEditor_Button[10]) then money = getPlayerMoney (source) if (money >= 5000) then player = getLocalPlayer() outputChatBox ("You bought a M4 $5000",225,225,0) Link to comment
Castillo Posted February 26, 2013 Share Posted February 26, 2013 It's really simple, you must add after "giveWeapon" the function to take the money, e.g: function givesilenced ( ) giveWeapon ( client, 23, 51, true ) takePlayerMoney ( client, 500 ) end addEvent("givesilenced",true) addEventHandler("givesilenced",getRootElement(),givesilenced) Link to comment
Adde Posted February 26, 2013 Author Share Posted February 26, 2013 Aha, yes that was very simple, thx 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