Jump to content

مساعدة بسيطة فى انشاء ماركر


Recommended Posts

سلام عليكم 

فى المود اما بضيف

ماركر تانى فى معرض السيارات مش بيشتغل

الماركر التانى اول ماركر الى هو الاساسى الى بيشتغل الى عالمة صاحب المود

الحل اية عشان اضيف اكتر من ماركر لمعرض السيارات

 

local Key = 'F5'
vehiclesTable = {
	{ 'Super GT', 506, 10000, {-1667.31152, 1213.07727, 15.87188, -1663.62793, 1208.41748, 13.67809} },
	{ 'Windsor', 555, 66600, {-1667.31152, 1213.07727, 15.87188, -1663.62793, 1208.41748, 13.67809} },
};

local buyingMarker = createMarker( -1663.51257, 1208.61926, 6.25465, 'cylinder', 1.2, 200, 150, 50, 255 )
local buyingMarker = createMarker( -1625.49316, 1209.18298, 7.03906, 'cylinder', 1.2, 200, 150, 50, 255 )


local screenW, screenH = guiGetScreenSize()
Cplayer = getLocalPlayer(  )
setElementData( Cplayer, 'VehiclesSystem;WarpToVehicle', nil )
setElementData( root, 'vehiclesSystem;dimension', 1 )

GUIEditor = {
    checkbox = {},
    label = {},
    button = {},
    window = {},
    gridlist = {}
}

الماركر التانى

الى هو 1625 دة الى ضايفة انما اول ماركر دة بتاع صاحب المود بس  عايز اعمل اكتر من ماركر للسيارات فى كذا مدينة اتمنى تكونوا فهمتونى

كل ما بضيف ماركر ماتشتغل اللوحة الى بيشتغل بس اول ماركر

Edited by ايهاب
Link to comment
local Table = { 
	[ 1 ] = { -1663.51257, 1208.61926, 6.25465 } ,
	[ 2 ] = { -1625.49316, 1209.18298, 7.03906 }
}

for i , v in ipairs ( Table ) do 
	Marker = createMarker ( v [ 1 ] , v [ 2 ] , v [ 3 ] , 'cylinder', 1.2, 200, 150, 50, 255 )
	addEventHandler ( 'onClientMarkerHit' , Marker ,
		function ( )
			-- your code
		end 
	)
end 

 

  • Like 1
Link to comment
Just now, ^iiEcoo'x_) said:

local Table = { 
	[ 1 ] = { -1663.51257, 1208.61926, 6.25465 } ,
	[ 2 ] = { -1625.49316, 1209.18298, 7.03906 }
}

for i , v in ipairs ( Table ) do 
	Marker = createMarker ( v [ 1 ] , v [ 2 ] , v [ 3 ] , 'cylinder', 1.2, 200, 150, 50, 255 )
	addEventHandler ( 'onClientMarkerHit' , Marker ,
		function ( )
			-- your code
		end 
	)
end 

 

مش فاهم يسطا يور كود دى  احوط فيها اية باقى الاكواد الى فى الصفحة

Link to comment
1 minute ago, ^iiEcoo'x_) said:

الي يفتح اللوحة

دة الكود كامل حوطة انت كدة عشان انا متغلبطشى واسقط اى شى

local Key = 'F5'
vehiclesTable = {



	{ 'Faggio', 462, 25000, {-1667.31152, 1213.07727, 15.87188, -1663.62793, 1208.41748, 13.67809} },

	{ 'FCR-900', 521, 150000, {-1667.31152, 1213.07727, 15.87188, -1663.62793, 1208.41748, 13.67809} },
	
	{ 'Freeway', 463, 60000, {-1667.31152, 1213.07727, 15.87188, -1663.62793, 1208.41748, 13.67809} },
	{ 'NRG-500', 522, 300000, {-1667.31152, 1213.07727, 15.87188, -1663.62793, 1208.41748, 13.67809} },
	{ 'PCJ-600', 461, 300000, {-1667.31152, 1213.07727, 15.87188, -1663.62793, 1208.41748, 13.67809} },
	{ 'Sanchez', 468, 150000, {-1667.31152, 1213.07727, 15.87188, -1663.62793, 1208.41748, 13.67809} },
	{ 'Wayfarer', 586, 50000, {-1667.31152, 1213.07727, 15.87188, -1663.62793, 1208.41748, 13.67809} },
	
	




};

local buyingMarker = createMarker( -1663.51257, 1208.61926, 6.25465, 'cylinder', 1.2, 200, 150, 50, 255 )


local screenW, screenH = guiGetScreenSize()
Cplayer = getLocalPlayer(  )
setElementData( Cplayer, 'VehiclesSystem;WarpToVehicle', nil )
setElementData( root, 'vehiclesSystem;dimension', 1 )

GUIEditor = {
    checkbox = {},
    label = {},
    button = {},
    window = {},
    gridlist = {}
}
GUIEditor.window[1] = guiCreateWindow((screenW - 700) / 2, (screenH - 374) / 2, 700, 374, ". : Vehicles System : .", false)
guiWindowSetSizable(GUIEditor.window[1], false)
guiSetAlpha(GUIEditor.window[1], 1.00)
guiSetVisible(GUIEditor.window[1], false)
GUIEditor.gridlist[1] = guiCreateGridList(10, 32, 511, 332, false, GUIEditor.window[1])
guiGridListAddColumn(GUIEditor.gridlist[1], "ID", 0.2)
guiGridListAddColumn(GUIEditor.gridlist[1], "Vehicle", 0.3)
guiGridListAddColumn(GUIEditor.gridlist[1], "Price", 0.3)
guiGridListAddColumn(GUIEditor.gridlist[1], "Subscription", 0.3)
GUIEditor.button[1] = guiCreateButton(531, 42, 156, 24, "Create Vehicle", false, GUIEditor.window[1])
guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFFEFB00")
GUIEditor.button[2] = guiCreateButton(531, 76, 156, 24, "Destroy Vehicle", false, GUIEditor.window[1])
guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FFFEFB00")
GUIEditor.button[3] = guiCreateButton(531, 125, 156, 24, "Lock/Unlock Vehicle", false, GUIEditor.window[1])
guiSetProperty(GUIEditor.button[3], "NormalTextColour", "FF00ADFE")
GUIEditor.button[4] = guiCreateButton(531, 159, 156, 24, "On/Off Engine", false, GUIEditor.window[1])
guiSetProperty(GUIEditor.button[4], "NormalTextColour", "FF00ADFE")
GUIEditor.button[5] = guiCreateButton(532, 193, 155, 24, "On/Off Lights", false, GUIEditor.window[1])
guiSetProperty(GUIEditor.button[5], "NormalTextColour", "FF00ADFE")
GUIEditor.button[6] = guiCreateButton(532, 242, 155, 24, "Warp To Buy Place", false, GUIEditor.window[1])
guiSetProperty(GUIEditor.button[6], "NormalTextColour", "FFFE7100")
GUIEditor.button[7] = guiCreateButton(533, 340, 154, 24, "X", false, GUIEditor.window[1])
guiSetProperty(GUIEditor.button[7], "NormalTextColour", "FFFE0000")
GUIEditor.button[8] = guiCreateButton(532, 276, 154, 24, "Sell Vehicle", false, GUIEditor.window[1])
guiSetProperty(GUIEditor.button[8], "NormalTextColour", "FFFE7100")
GUIEditor.label[1] = guiCreateLabel(531, 100, 156, 15, "ــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ", false, GUIEditor.window[1])
guiSetFont(GUIEditor.label[1], "default-bold-small")
guiLabelSetColor(GUIEditor.label[1], 176, 176, 176)
guiLabelSetHorizontalAlign(GUIEditor.label[1], "center", false)
guiLabelSetVerticalAlign(GUIEditor.label[1], "bottom")
GUIEditor.label[2] = guiCreateLabel(531, 217, 156, 15, "ــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ", false, GUIEditor.window[1])
guiSetFont(GUIEditor.label[2], "default-bold-small")
guiLabelSetColor(GUIEditor.label[2], 176, 176, 176)
guiLabelSetHorizontalAlign(GUIEditor.label[2], "center", false)
guiLabelSetVerticalAlign(GUIEditor.label[2], "bottom")
GUIEditor.checkbox[1] = guiCreateCheckBox(553, 309, 133, 21, "Warp To Vehicle", false, false, GUIEditor.window[1])
guiSetProperty(GUIEditor.checkbox[1], "NormalTextColour", "FFF9F000")
----------#Window2
buyplace = guiCreateWindow(screenW - 266 - 10, (screenH - 491) / 2, 266, 491, ". : Vehicles System : .", false)
guiWindowSetSizable(buyplace, false)
guiSetAlpha(buyplace, 1.00)
guiSetVisible(buyplace, false)
list_buyplace = guiCreateGridList(10, 29, 246, 313, false, buyplace)
guiGridListSetSortingEnabled(list_buyplace, false)
guiGridListAddColumn(list_buyplace, "#", 0.11)
guiGridListAddColumn(list_buyplace, "Vehicle", 0.5)
guiGridListAddColumn(list_buyplace, "Price", 0.5)
buy_buyplace = guiCreateButton(46, 352, 172, 22, "Buy Vehicle", false, buyplace)
guiSetProperty(buy_buyplace, "NormalTextColour", "FF00FE00")
rent_buyplace = guiCreateButton(46, 423, 172, 22, "Rent Vehicle", false, buyplace)
guiSetProperty(rent_buyplace, "NormalTextColour", "FFF5FD00")
label_buyplace = guiCreateLabel(10, 384, 246, 29, "Note : You Can Also Rent Vehicle,\nRent Time : 5 Minutes, Price : 1,000$ .", false, buyplace)
guiLabelSetColor(label_buyplace, 254, 84, 0)
guiLabelSetHorizontalAlign(label_buyplace, "center", false)
x_buyplace = guiCreateButton(46, 455, 172, 22, "X", false, buyplace)
guiSetProperty(x_buyplace, "NormalTextColour", "FFFE0005")

function addCarsToBuy(  )
guiGridListClear( list_buyplace )
for _, vehicle in ipairs( vehiclesTable ) do 
	local Price, value = string.gsub( vehicle[3], '^(-?%d+)(%d%d%d)', '%1,%2' )    
	local item = guiGridListAddRow( list_buyplace )
	local cN = guiGridListSetItemText( list_buyplace, item, 2, vehicle[1], false, false )
	local cP = guiGridListSetItemText( list_buyplace, item, 3, Price..'$', false, false )
	local num = guiGridListSetItemText( list_buyplace, item, 1, _..'-', false, false )
	local cD1 = guiGridListSetItemData( list_buyplace, item, 1, vehicle[4] )
	local cD2 = guiGridListSetItemData( list_buyplace, item, 2, vehicle[2] )
	local cD3 = guiGridListSetItemData( list_buyplace, item, 3, vehicle[3] )
		guiGridListSetItemColor( list_buyplace, item, 2, 200, 200, 50 )
	guiGridListSetItemColor( list_buyplace, item, 3, 50, 200, 200 )
guiGridListSetItemColor( list_buyplace, item, 1, 200, 100, 0 )
end
end
addCarsToBuy(  )

function clickElements(  )
	if ( source == GUIEditor.button[7] ) then
		guiSetVisible( GUIEditor.window[1], false )
		showCursor( false )
	elseif ( source == GUIEditor.checkbox[1] ) then
		local Sel = guiCheckBoxGetSelected( GUIEditor.checkbox[1] )
			if ( Sel == true ) then
				setElementData( Cplayer, 'VehiclesSystem;WarpToVehicle', 'Enabled' )
			else
		setElementData( Cplayer, 'VehiclesSystem;WarpToVehicle', nil )
		end
	elseif ( source == x_buyplace ) then
		fadeCamera( false )
		setTimer( fadeCamera, 1500, 1, true )
		guiSetVisible( buyplace, false )
		showCursor( false )
		setTimer( setCameraTarget, 1500, 1, Cplayer )
		triggerServerEvent( 'VehiclesSystem;createViewVehicle', Cplayer, nil, nil, nil, nil, 'close' )
		setElementDimension( Cplayer, 0 )
		addCarsToBuy(  )
	elseif ( source == list_buyplace ) then
		local Sel = guiGridListGetSelectedItem( list_buyplace )
			if ( Sel == -1 ) then return end
				local Data = guiGridListGetItemData( list_buyplace, Sel, 1 )
					local x1, y1, z1, x2, y2, z2 = unpack( Data )
				setCameraMatrix( x1, y1, z1, x2, y2, z2 )
			if ( isElement( viewvehicle ) ) then if ( getElementModel( viewvehicle ) ) == guiGridListGetItemData( list_buyplace, Sel, 2 ) then return end destroyElement( viewvehicle ) end
		triggerServerEvent( 'VehiclesSystem;createViewVehicle', Cplayer, guiGridListGetItemData( list_buyplace, Sel, 2 ), x2, y2, z2, 'view' )
	elseif ( source == rent_buyplace ) then
		local Sel = guiGridListGetSelectedItem( list_buyplace )
			if ( Sel == -1 ) then outputChatBox( '#FF0000*#FFFF00 Vehicles System #FF0000 : #FFFFFFError, Please select vehicle #FF0000!', 255, 255, 255, true ) return end
				local ID = guiGridListGetItemData( list_buyplace, Sel, 2 )
				if ( getPlayerMoney( Cplayer ) < 1000 ) then outputChatBox( '#FF0000*#FFFF00 Vehicles System #FF0000 : #FFFFFFError, You don\'t have enough money #FF0000!', 255, 255, 255, true ) return end
			guiSetVisible( buyplace, false )
			showCursor( false )
			setTimer( setCameraTarget, 1500, 1, Cplayer )
			triggerServerEvent( 'VehiclesSystem;createRentVehicle', Cplayer, ID, guiGridListGetItemText( list_buyplace, Sel, 2 ) )
			triggerServerEvent( 'VehiclesSystem;createViewVehicle', Cplayer, nil, nil, nil, nil, 'close' )
	elseif ( source == buy_buyplace ) then
		local Sel = guiGridListGetSelectedItem( list_buyplace )
			if ( Sel == -1 ) then outputChatBox( '#FF0000*#FFFF00 Vehicles System #FF0000 : #FFFFFFError, Please select vehicle #FF0000!', 255, 255, 255, true ) return end
				local ID = guiGridListGetItemData( list_buyplace, Sel, 2 )
				local vN = guiGridListGetItemText( list_buyplace, Sel, 2 )
			local Pr = guiGridListGetItemData( list_buyplace, Sel, 3 )
				if ( getPlayerMoney( Cplayer ) < Pr ) then outputChatBox( '#FF0000*#FFFF00 Vehicles System #FF0000 : #FFFFFFError, You don\'t have enough money #FF0000!', 255, 255, 255, true ) return end
		triggerServerEvent( 'VehiclesSystem;buyCurrentCar', Cplayer, ID, vN, Pr )
	elseif ( source == GUIEditor.button[1] ) then
		local Sel = guiGridListGetSelectedItem( GUIEditor.gridlist[1] )
			if ( Sel == -1 ) then outputChatBox( '#FF0000*#FFFF00 Vehicles System #FF0000 : #FFFFFFError, Please select vehicle #FF0000!', 255, 255, 255, true ) return end
			local ID = guiGridListGetItemText( GUIEditor.gridlist[1], Sel, 1 )
				triggerServerEvent( 'VehiclesSystem;createPersonalVehicle', Cplayer, ID )
			guiSetVisible( GUIEditor.window[1], false )
		showCursor( false )
		guiSetEnabled( GUIEditor.button[1], false )
		setTimer( guiSetEnabled, 2000, 1, GUIEditor.button[1], true )
	elseif ( source == GUIEditor.button[2] ) then
				triggerServerEvent( 'VehiclesSystem;destroyPersonalVehicle', Cplayer )
			guiSetEnabled( GUIEditor.button[2], false )
		setTimer( guiSetEnabled, 2000, 1, GUIEditor.button[2], true )
	elseif ( source == GUIEditor.button[3] ) then
		triggerServerEvent( 'VehiclesSystem;lock/unlockPersonalVehicle', Cplayer )
			guiSetEnabled( GUIEditor.button[3], false )
		setTimer( guiSetEnabled, 2000, 1, GUIEditor.button[3], true )
	elseif ( source == GUIEditor.button[4] ) then
		triggerServerEvent( 'VehiclesSystem;off/onPersonalVehicle', Cplayer )
			guiSetEnabled( GUIEditor.button[4], false )
		setTimer( guiSetEnabled, 2000, 1, GUIEditor.button[4], true )
	elseif ( source == GUIEditor.button[5] ) then
		triggerServerEvent( 'VehiclesSystem;off/onLightsPersonalVehicle', Cplayer )
			guiSetEnabled( GUIEditor.button[5], false )
		setTimer( guiSetEnabled, 2000, 1, GUIEditor.button[5], true )
	elseif ( source == GUIEditor.button[8] ) then
		local Sel = guiGridListGetSelectedItem( GUIEditor.gridlist[1] )
			if ( Sel == -1 ) then outputChatBox( '#FF0000*#FFFF00 Vehicles System #FF0000 : #FFFFFFError, Please select vehicle #FF0000!', 255, 255, 255, true ) return end
			local ID = guiGridListGetItemText( GUIEditor.gridlist[1], Sel, 1 )
				triggerServerEvent( 'VehiclesSystem;sellMyPersonalVehicle', Cplayer, tonumber(ID), guiGridListGetItemData( GUIEditor.gridlist[1], Sel, 3 ) )
			guiSetEnabled( GUIEditor.button[8], false )
		setTimer( guiSetEnabled, 2000, 1, GUIEditor.button[8], true )
	elseif ( source == GUIEditor.button[6] ) then
		fadeCamera( false )
		setTimer( fadeCamera, 1500, 1, true )
		setTimer( setElementPosition, 1500, 1, Cplayer, -1639.25244, 1203.28857, 8.22800 )
		guiSetVisible( GUIEditor.window[1], false )
			showCursor( false )
end
end
addEventHandler( 'onClientGUIClick', root, clickElements )

function refreshMyList( Table )
	guiGridListClear( GUIEditor.gridlist[1] )
		for i, _ in ipairs( Table ) do 
			local Price, value = string.gsub( Table[i].vehPrice / 2, '^(-?%d+)(%d%d%d)', '%1,%2' )  
			local item = guiGridListAddRow( GUIEditor.gridlist[1] )
			guiGridListSetItemText( GUIEditor.gridlist[1], item, 1, Table[i].vehID, false, false )
			guiGridListSetItemText( GUIEditor.gridlist[1], item, 2, Table[i].vehName, false, false )
			guiGridListSetItemText( GUIEditor.gridlist[1], item, 3, Price..'$', false, false )
			guiGridListSetItemText( GUIEditor.gridlist[1], item, 4, Table[i].Subscription, false, false )
			guiGridListSetItemData( GUIEditor.gridlist[1], item, 3, Table[i].vehPrice / 2 )
		end
end
addEvent( 'VehiclesSystem;putMyVehicles', true )
addEventHandler( 'VehiclesSystem;putMyVehicles', root, refreshMyList )

addEvent( 'VehiclesSystem;gridListAddRent', true )
addEventHandler( 'VehiclesSystem;gridListAddRent', root,
function( ID, veh )
	rentRow = guiGridListAddRow( GUIEditor.gridlist[1] )
			guiGridListSetItemText( GUIEditor.gridlist[1], rentRow, 1, ID, false, false )
			guiGridListSetItemText( GUIEditor.gridlist[1], rentRow, 2, veh, false, false )
			guiGridListSetItemText( GUIEditor.gridlist[1], rentRow, 3, '1,000$', false, false )
			guiGridListSetItemText( GUIEditor.gridlist[1], rentRow, 4, '5 Minutes', false, false )
			guiSetEnabled( buy_buyplace, false )
			guiSetEnabled( rent_buyplace, false )
			guiSetEnabled( list_buyplace, false )
		setTimer( function(  )
			guiGridListRemoveRow( GUIEditor.gridlist[1], rentRow )
			guiSetEnabled( buy_buyplace, true )
			guiSetEnabled( rent_buyplace, true )
			guiSetEnabled( list_buyplace, true )
		end, 300000, 1 )
end )

addEvent( 'VehiclesSystem;hideBuyWindow', true ) addEventHandler( 'VehiclesSystem;hideBuyWindow', root, function(  ) guiSetVisible( buyplace, false ) showCursor( false ) end )
addEvent( 'VehiclesSystem;emptyMyList', true ) addEventHandler( 'VehiclesSystem;emptyMyList', root, function(  ) guiGridListClear( GUIEditor.gridlist[1] ) end )

addEventHandler( 'onClientResourceStart', resourceRoot, function(  ) triggerServerEvent( 'refreshMyListS', Cplayer ) end )

addEventHandler( 'onClientMarkerHit', buyingMarker,
function( hitElement )
if ( hitElement == Cplayer and getElementDimension( hitElement ) == 0 ) then
local x, y, z = getElementPosition( Cplayer )
if ( z <= 7.25465 ) then
guiGridListSetSelectedItem( list_buyplace, 0, 1 )
local Sel = guiGridListGetSelectedItem( list_buyplace )
	if ( Sel == -1 ) then return end
		local Data = guiGridListGetItemData( list_buyplace, Sel, 1 )
			local x1, y1, z1, x2, y2, z2 = unpack( Data )
			fadeCamera( false )
		setTimer( fadeCamera, 1500, 1, true )
				setTimer( setCameraMatrix, 1500, 1, x1, y1, z1, x2, y2, z2 )
				if ( isElement( viewvehicle ) ) then if ( getElementModel( viewvehicle ) ) == guiGridListGetItemData( list_buyplace, Sel, 2 ) then return end destroyElement( viewvehicle ) end
		triggerServerEvent( 'VehiclesSystem;createViewVehicle', Cplayer, guiGridListGetItemData( list_buyplace, Sel, 2 ), x2, y2, z2, 'view' )
setTimer( guiSetVisible, 1500, 1, buyplace, not guiGetVisible( buyplace ) )
setTimer( showCursor, 1500, 1, not isCursorShowing(  ) )
end
end
end, false )

bindKey( Key, 'down',
function(  )
	guiSetVisible( GUIEditor.window[1], not guiGetVisible( GUIEditor.window[1] ) )
	showCursor( not isCursorShowing(  ) )
end )














 

3 minutes ago, ^iiEcoo&#x27;x_) said:

الي يفتح اللوحة

شوف الرد الى حطيت فى الكود لانى مش هعرف

حوطة انت يسطا 

?

8 minutes ago, ^iiEcoo&#x27;x_) said:

الي يفتح اللوحة

.....

Edited by ايهاب
Link to comment
  • 2 weeks later...
On 26/04/2021 at 15:43, ايهاب said:

local Table = { 
	[ 1 ] = { -1663.51257, 1208.61926, 6.25465 } ,
	[ 2 ] = { -1625.49316, 1209.18298, 7.03906 }
}

for i , v in ipairs ( Table ) do 
	Marker = createMarker ( v [ 1 ] , v [ 2 ] , v [ 3 ] , 'cylinder', 1.2, 200, 150, 50, 255 )
	addEventHandler ( 'onClientMarkerHit' , Marker ,
		function ( )
			-- your code
		end 
	)
end 

 

- وضح لك Ec

  • Like 1
Link to comment

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