gghvcffcv Posted April 1, 2014 Share Posted April 1, 2014 (edited) Hey my friends the problem is if someone do /stopsell it deletes the marker of the other dealer, and no of the dealer that did /stopsell and The dealers can create more than 1 marker Help please server: function consoleCreateMarker ( thePlayer, commandName ) if ( thePlayer ) then local x, y, z = getElementPosition ( thePlayer ) theMarker = createMarker ( x, y, z - 1, "cylinder", 1.5, 255, 0, 0, 170 ) if ( theMarker ) then setElementData(theMarker, "markerType", "WeaponShop") setElementFrozen( thePlayer, true ) outputConsole ( "Marker created successfully", thePlayer ) else outputConsole ( "Failed to create marker", thePlayer ) end end end addCommandHandler ( "sell", consoleCreateMarker ) function para( thePlayer, commandName ) setElementFrozen( thePlayer, false ) destroyElement( theMarker ) end addCommandHandler ("stopsell", para) --------------------------------------------------------------------------------------------------------------------------------------- function cerrarr ( marker ) if not marker then return end destroyElement ( marker ) end addEvent( "cerrarr", true ) addEventHandler( "cerrarr", root, cerrarr ) --------------------------------------------------------------------------------------------------------------------------------------- function armaAA ( hitElement1 ) if ( getPlayerMoney(source) >= 2000 ) then takePlayerMoney ( source, 2000 ) giveWeapon ( source, 31, 100 ) end end addEvent( "armaAA", true ) addEventHandler( "armaAA", root, armaAA ) --------------------------------------------------------------------------------------------------------------------------------------- function armaBB ( hitElement1 ) if ( getPlayerMoney(source) >= 2000 ) then takePlayerMoney ( source, 2000 ) giveWeapon ( source, 30, 100 ) end end addEvent( "armaBB", true ) addEventHandler( "armaBB", root, armaBB ) --------------------------------------------------------------------------------------------------------------------------------------- function armaCC ( hitElement1 ) if ( getPlayerMoney(source) >= 4000 ) then takePlayerMoney ( source, 4000 ) giveWeapon ( source, 34, 30 ) end end addEvent( "armaCC", true ) addEventHandler( "armaCC", root, armaCC ) --------------------------------------------------------------------------------------------------------------------------------------- function armaDD ( hitElement1 ) if ( getPlayerMoney(source) >= 500 ) then takePlayerMoney ( source, 500 ) giveWeapon ( source, 16, 1 ) end end addEvent( "armaDD", true ) addEventHandler( "armaDD", root, armaDD ) --------------------------------------------------------------------------------------------------------------------------------------- function armaEE( hitElement1 ) if ( getPlayerMoney(source) >= 200 ) then takePlayerMoney ( source, 200 ) giveWeapon ( source, 32, 100 ) end end addEvent( "armaEE", true ) addEventHandler( "armaEE", root, armaEE ) --------------------------------------------------------------------------------------------------------------------------------------- function armaFF( hitElement1 ) if ( getPlayerMoney(source) >= 200 ) then takePlayerMoney ( source, 200 ) giveWeapon ( source, 28, 100 ) end end addEvent( "armaFF", true ) addEventHandler( "armaFF", root, armaFF ) --------------------------------------------------------------------------------------------------------------------------------------- function armaGG( hitElement1 ) if ( getPlayerMoney(source) >= 200 ) then takePlayerMoney ( source, 200 ) giveWeapon ( source, 26, 50 ) end end addEvent( "armaGG", true ) addEventHandler( "armaGG", root, armaGG ) --------------------------------------------------------------------------------------------------------------------------------------- function armaHH( hitElement1 ) if ( getPlayerMoney(source) >= 200 ) then takePlayerMoney ( source, 200 ) giveWeapon ( source, 23, 100 ) end end addEvent( "armaHH", true ) addEventHandler( "armaHH", root, armaHH ) --------------------------------------------------------------------------------------------------------------------------------------- function armaII( hitElement1 ) if ( getPlayerMoney(source) >= 2000 ) then takePlayerMoney ( source, 2000 ) giveWeapon ( source, 24, 50 ) end end addEvent( "armaII", true ) addEventHandler( "armaII", root, armaII ) client: local inMarker addEventHandler("onClientMarkerLeave", resourceRoot, function( hitElement ) if not hitElement == localPlayer then return end inMarker = nil end) addEventHandler("onClientMarkerLeave", resourceRoot, function( hitElement ) if not hitElement == localPlayer then return end inMarker = source end) addEventHandler("onClientMarkerHit", resourceRoot, function( hitElement ) local markerType = getElementData(source, "markerType") if hitElement == localPlayer and markerType and markerType == "WeaponShop" then panel = guiCreateWindow(510, 197, 352, 396, "Arms Dealer", false) guiWindowSetSizable(panel, false) armaA = guiCreateButton(10, 28, 129, 30, "M4", false, panel) armaB = guiCreateButton(10, 68, 129, 30, "AK-47", false, panel) armaC = guiCreateButton(10, 108, 129, 30, "Sniper", false, panel) armaD = guiCreateButton(10, 148, 129, 30, "Grenade", false, panel) armaE = guiCreateButton(10, 188, 129, 30, "Tec-9", false, panel) armaF = guiCreateButton(10, 228, 129, 30, "Uzi", false, panel) armaG = guiCreateButton(10, 268, 129, 30, "Sawn-Off", false, panel) armaH = guiCreateButton(10, 308, 129, 30, "Silenced", false, panel) armaI = guiCreateButton(10, 348, 129, 30, "Deagle", false, panel) cerrar = guiCreateButton(166, 25, 169, 352, "Close", false, panel) guiSetFont(cerrar, "sa-gothic") showCursor (true) addEventHandler ("onClientGUIClick", armaA, armaAA, false) addEventHandler ("onClientGUIClick", armaB, armaBB, false) addEventHandler ("onClientGUIClick", armaC, armaCC, false) addEventHandler ("onClientGUIClick", armaD, armaDD, false) addEventHandler ("onClientGUIClick", armaE, armaEE, false) addEventHandler ("onClientGUIClick", armaF, armaFF, false) addEventHandler ("onClientGUIClick", armaG, armaGG, false) addEventHandler ("onClientGUIClick", armaH, armaHH, false) addEventHandler ("onClientGUIClick", armaI, armaII, false) addEventHandler ("onClientGUIClick", cerrar, cerrarr, false) end end) function cerrarr ( hitElement ) showCursor ( false ) guiSetVisible (panel, false ) end function armaAA ( hitElement ) showCursor ( true ) triggerServerEvent ( "armaAA", localPlayer ) end function armaBB ( hitElement ) showCursor ( true ) triggerServerEvent ( "armaBB", localPlayer ) end function armaCC ( hitElement ) showCursor ( true ) triggerServerEvent ( "armaCC", localPlayer ) end function armaDD ( hitElement ) showCursor ( true ) triggerServerEvent ( "armaDD", localPlayer ) end function armaEE ( hitElement ) showCursor ( true ) triggerServerEvent ( "armaEE", localPlayer ) end function armaDD ( hitElement ) showCursor ( true ) triggerServerEvent ( "armaDD", localPlayer ) end function armaFF ( hitElement ) showCursor ( true ) triggerServerEvent ( "armaFF", localPlayer ) end function armaGG ( hitElement ) showCursor ( true ) triggerServerEvent ( "armaGG", localPlayer ) end function armaHH ( hitElement ) showCursor ( true ) triggerServerEvent ( "armaHH", localPlayer ) end function armaII ( hitElement ) showCursor ( true ) triggerServerEvent ( "armaII", localPlayer ) end Edited April 2, 2014 by Guest Link to comment
gghvcffcv Posted April 2, 2014 Author Share Posted April 2, 2014 Could someone Help me? Link to comment
KaduRo Posted April 2, 2014 Share Posted April 2, 2014 could you please put the code inside so we can see better ! Link to comment
gghvcffcv Posted April 2, 2014 Author Share Posted April 2, 2014 Could someone help with with this please? Link to comment
WhoAmI Posted April 2, 2014 Share Posted April 2, 2014 Well, set data to this marker with dealer's nick or something, and then check if the player who wants stop sell is the right man. Link to comment
gghvcffcv Posted April 2, 2014 Author Share Posted April 2, 2014 Well, set data to this marker with dealer's nick or something, and then check if the player who wants stop sell is the right man. How could i do that? Link to comment
gghvcffcv Posted April 2, 2014 Author Share Posted April 2, 2014 With setElementData. Like this?: function para( thePlayer ) if getPlayerName ( thePlayer ) then if getElementData( theMarker, "markerType" ) then setElementFrozen( thePlayer, false ) destroyElement ( theMarker ) end end end addCommandHandler ("stopsell", para)) Link to comment
Arnold-1 Posted April 2, 2014 Share Posted April 2, 2014 (edited) function sad (player) setElementData(theMarker,"owner",getPlayerName(player).."'s Marker") end Edited April 2, 2014 by Guest Link to comment
iPrestege Posted April 2, 2014 Share Posted April 2, 2014 function sad (player) setElementData(theMarker,"owner",getPlayerName(thePlayer).."'s Marker") end player and thePlayer thePlayer isn't defined anywhere in you're code. Link to comment
gghvcffcv Posted April 2, 2014 Author Share Posted April 2, 2014 function sad (player) setElementData(theMarker,"owner",getPlayerName(thePlayer).."'s Marker") end Not working Link to comment
Arnold-1 Posted April 2, 2014 Share Posted April 2, 2014 function sad (player) setElementData(theMarker,"owner",getPlayerName(thePlayer).."'s Marker") end player and thePlayer thePlayer isn't defined anywhere in you're code. ahh, mistake sorry. edited. Link to comment
pa3ck Posted April 2, 2014 Share Posted April 2, 2014 What about table? Wouldn't it be much handier? local markers = {} function consoleCreateMarker ( thePlayer, commandName ) if not markers [ thePlayer ] then local x, y, z = getElementPosition ( thePlayer ) markers [ thePlayer ] = createMarker ( x, y, z - 1, "cylinder", 1.5, 255, 0, 0, 170 ) if ( markers [ thePlayer ] ) then setElementData(markers [ thePlayer ], "markerType", "WeaponShop") setElementFrozen( thePlayer, true ) outputConsole ( "Marker created successfully", thePlayer ) else outputConsole ( "Failed to create marker", thePlayer ) end else outputChatBox ( "You're selling already.", thePlayer, 255, 0, 0 ) end end addCommandHandler ( "sell", consoleCreateMarker, false, false ) function para( thePlayer, commandName ) if markers [ thePlayer ] then setElementFrozen( thePlayer, false ) destroyElement( markers [ thePlayer ] ) markers [ thePlayer ] = nil else outputChatBox ( "You haven't started selling yet.", thePlayer, 255, 0, 0) end end addCommandHandler ("stopsell", para, false, false) Link to comment
gghvcffcv Posted April 4, 2014 Author Share Posted April 4, 2014 What about table? Wouldn't it be much handier? local markers = {} function consoleCreateMarker ( thePlayer, commandName ) if not markers [ thePlayer ] then local x, y, z = getElementPosition ( thePlayer ) markers [ thePlayer ] = createMarker ( x, y, z - 1, "cylinder", 1.5, 255, 0, 0, 170 ) if ( markers [ thePlayer ] ) then setElementData(markers [ thePlayer ], "markerType", "WeaponShop") setElementFrozen( thePlayer, true ) outputConsole ( "Marker created successfully", thePlayer ) else outputConsole ( "Failed to create marker", thePlayer ) end else outputChatBox ( "You're selling already.", thePlayer, 255, 0, 0 ) end end addCommandHandler ( "sell", consoleCreateMarker, false, false ) function para( thePlayer, commandName ) if markers [ thePlayer ] then setElementFrozen( thePlayer, false ) destroyElement( markers [ thePlayer ] ) markers [ thePlayer ] = nil else outputChatBox ( "You haven't started selling yet.", thePlayer, 255, 0, 0) end end addCommandHandler ("stopsell", para, false, false) Forgot say Thanks to you ty 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