Jump to content

[ مهمة [ مشكلة


Recommended Posts

السلام عليكم

وين المشكلة هنا

local mission = {}
	function addPlayers(player,Table)
		if not getPlayerTable (player,mission) then
			table.insert(player,Table)
			setElementData(player,'Mission',true)
	end
end
local marker = createMarker(2027.60059, 1007.15759, 10.82031,'cylinder',2,0,255,0,150)
	local Mission = "false"
	
addEventHandler ( "onMarkerHit" , root ,
		function (player)
			if source == marker then 
		exports["dxmessages"]:outputDx(player,"Hi "..getPlayerName(player).." #FFFFFFthe mission not started yet","error")
				if ( Mission == 'false' ) then
		return
		end
	end
end)

function openMission (player)
thetimer = setTimer(function()
		exports["dxmessages"]:outputDx(player,"the mission started","success")
				 Mission = "true"
	end , 5000 , 1 )
end)

addEventHandler('onMarkerHIT',root,function (aPlayer)
if getElementType (aPlayer) == 'player' and not isPedInVehicle (aPlayer) then
if Mission == false then return end exports["dxmessages"]:outputDx(aPlayer,"the mission was closed","info")
if ( Mission == 'true' ) then
setElementDimension ( aPlayer, 100 )
setElementPosition(aPlayer,-2690.51367, 1289.90479, 55.42969)
		exports["dxmessages"]:outputDx(player,"this join this mission , Good Luck","success")
	setElementFrozen(aPlayer,true)
      	setElementData(player,'missionR',true)
			setTimer ( function ()
					Mission = false 
				for _ , plr in ipairs ( getElementsByType ( "player" )  ) do
			if getElementData ( plr , "MissionR" == true) then
		setElementFrozen ( plr , false ) 
		exports["dxmessages"]:outputDx(player,"the mission was stated","info")
        end
		end
        end , 5000, 1 )
    end
  end
end
)








 

Link to comment
1 minute ago, Talis said:

السلام عليكم

وين المشكلة هنا


local mission = {}
	function addPlayers(player,Table)
		if not getPlayerTable (player,mission) then
			table.insert(player,Table)
			setElementData(player,'Mission',true)
	end
end
local marker = createMarker(2027.60059, 1007.15759, 10.82031,'cylinder',2,0,255,0,150)
	local Mission = "false"
	
addEventHandler ( "onMarkerHit" , root ,
		function (player)
			if source == marker then 
		exports["dxmessages"]:outputDx(player,"Hi "..getPlayerName(player).." #FFFFFFthe mission not started yet","error")
				if ( Mission == 'false' ) then
		return
		end
	end
end)

function openMission (player)
thetimer = setTimer(function()
		exports["dxmessages"]:outputDx(player,"the mission started","success")
				 Mission = "true"
	end , 5000 , 1 )
end)

addEventHandler('onMarkerHIT',root,function (aPlayer)
if getElementType (aPlayer) == 'player' and not isPedInVehicle (aPlayer) then
if Mission == false then return end exports["dxmessages"]:outputDx(aPlayer,"the mission was closed","info")
if ( Mission == 'true' ) then
setElementDimension ( aPlayer, 100 )
setElementPosition(aPlayer,-2690.51367, 1289.90479, 55.42969)
		exports["dxmessages"]:outputDx(player,"this join this mission , Good Luck","success")
	setElementFrozen(aPlayer,true)
      	setElementData(player,'missionR',true)
			setTimer ( function ()
					Mission = false 
				for _ , plr in ipairs ( getElementsByType ( "player" )  ) do
			if getElementData ( plr , "MissionR" == true) then
		setElementFrozen ( plr , false ) 
		exports["dxmessages"]:outputDx(player,"the mission was stated","info")
        end
		end
        end , 5000, 1 )
    end
  end
end
)








 

 

وعليكم السلام وش تبي تسوي بالضبط ؟

  • Like 1
Link to comment
12 minutes ago, Talis said:

@#,+( _xiRoc[K]; > ابي اسوي مهمة واتدرب عليها بس , بسوي مهمة جري

الحين المشكلة بعد 2 ثانية ماتشتغل المهمة 

ادري الكود ناقص لاكن انا بكمل الباقي اذا حليت هالمشكلة ^

 

بعيدا عن الاكواد في شوية خبصات في الاكواد و بعض الفنكشنات


 

getPlayerTable -- ?

onMarkerHIT = onMarkerHit

if source == marker then 
exports["dxmessages"]:outputDx(player,"Hi "..getPlayerName(player).." #FFFFFFthe mission not started yet","error")
if ( Mission == 'false' ) then
return

-- هنا اتوقع انك تبي اذا راح للماركر والمهم ما بدأت يطلعله كذا وانت حاط الكلام قبل التحقق ^
-- + ماليه داعي تكرر حدث onMarkerHit تقدر تختصر

addEventHandler('onMarkerHIT',root,function (aPlayer) 

-- ولاحظت في هذا الحدث انك حاط روت يعني لكل الماركرات بسبب انك ماحطيت if source ^
-- يعني الفنكشنات بتصير ع اي ماركر تروح له

function openMission (player)
thetimer = setTimer(function()
		exports["dxmessages"]:outputDx(player,"the mission started","success")
				 Mission = "true"
	end , 5000 , 1 )
end)

-- وعندك في هالحدث قوس زايد ^

addEventHandler('onMarkerHIT',root,function (aPlayer)
if getElementType (aPlayer) == 'player' and not isPedInVehicle (aPlayer) then
if Mission == false then return end exports["dxmessages"]:outputDx(aPlayer,"the mission was closed","info")
if ( Mission == 'true' ) then
setElementDimension ( aPlayer, 100 )
setElementPosition(aPlayer,-2690.51367, 1289.90479, 55.42969)
		exports["dxmessages"]:outputDx(player,"this join this mission , Good Luck","success")
	setElementFrozen(aPlayer,true)
      	setElementData(player,'missionR',true)
			setTimer ( function ()
					Mission = false 
				for _ , plr in ipairs ( getElementsByType ( "player" )  ) do
			if getElementData ( plr , "MissionR" == true) then
		setElementFrozen ( plr , false ) 
		exports["dxmessages"]:outputDx(player,"the mission was stated","info")
        end
		end
        end , 5000, 1 )
    end
  end
end
)
      
-- وهنا player مو معرفة ^

-- والخ

 

Edited by #,+( _xiRoc[K]; >
  • Like 1
Link to comment
local mission = {}
	function addPlayers(player,Table)
		if not getPlayerTable (player,mission) then
			table.insert(player,Table)
			setElementData(player,'Mission',true)
	end
end
local marker = createMarker(2027.60059, 1007.15759, 10.82031,'cylinder',2,0,255,0,150)
	 Mission = "false"
	
addEventHandler ( "onMarkerHit" , resourceRoot ,
		function (player)
			if source == marker then 
						if ( Mission == 'false' ) then
		exports["dxmessages"]:outputDx(player,"Hi "..getPlayerName(player).." #FFFFFFthe mission not started yet","error")
		return
		end
	end
end)

function openMission (player)
thetimer = setTimer(function()
		exports["dxmessages"]:outputDx(player,"the mission started","success")
				local Mission = "true"
	end , 5000 , 1 )
end

addEventHandler('onMarkerHit',resourceRoot,
function (aPlayer)
if getElementType (aPlayer) == 'player' and not isPedInVehicle (aPlayer) then
if Mission == false then return end
if ( Mission == 'true' ) then
setElementDimension ( aPlayer, 100 )
setElementPosition(aPlayer,-2690.51367, 1289.90479, 55.42969)
		exports["dxmessages"]:outputDx(player,"this join was mission , Good Luck","success")
	setElementFrozen(aPlayer,true)
      	setElementData(player,'missionR',true)
			setTimer ( function ()
					Mission = false 
				for _ , plr in ipairs ( getElementsByType ( "player" )  ) do
			if getElementData ( plr , "MissionR" == true) then
		setElementFrozen ( plr , false ) 
		exports["dxmessages"]:outputDx(aplayer,"the mission was stated","info")
        end
		end
        end , 5000, 1 )
    end
  end
end
)

 

بخصوص getPlayerTable

جبته من هالموضوع

مدري صح ولا غلط خخ

Edited by Talis
Link to comment

طيب وش هو

getPlayerTable

هل هو فنشكن مفيد ولا انت جايبنه كذا o.O

وليش حاط جدول في البداية دامك ماستخدمته

+ في حدث الماركر الثاني للحين ماستخدمت if source

يعني بتصير الفنكشنات ع كل الماركرات


#Edit:

مثال

جرب كذا :

local marker = createMarker(2027.60059, 1007.15759, 10.82031,'cylinder',2,0,255,0,150)

function getPlayersInMission ( plr )
local plrs = {

}
        if ( isElement ( plr ) and ( getElementType ( plr ) == "player" ) and ( getElementData ( plr, "MissionR" ) == true ) ) then
            table.insert ( plrs, plr )
        end
    return plrs
end

function isPlayerInMission ( num, plr )
    if ( isElement ( plr ) and ( getElementType ( plr ) == "player" ) ) then
        if ( num == 2 ) then
            if ( getElementData ( plr, "MissionR" ) == true ) then
        return true
    else
        return false
    end
        else
            if ( getElementData ( plr, "MissionP" ) == true ) then
        return true
    else
        return false
            end
        end
    end
end

addEventHandler ( "onMarkerHit", resourceRoot, function ( player )
            if ( source == marker ) and ( getElementType ( player ) == "player" ) then 
                if ( isPlayerInMission ( 1, player ) == true ) then
        exports["dxmessages"]:outputDx ( player,"Hi "..getPlayerName(player).." #FFFFFFthe mission not started yet", "error" )
    else
        if not ( isPedInVehicle ( player ) ) then
        exports["dxmessages"]:outputDx ( player, "this join was mission , Good Luck", "success" )
          setElementData ( player, 'MissionR', true )
        setElementData ( player, 'MissionP', true )
    end
        end
    end
end )

function openMission ( )
    for _ ,plr in ipairs ( getElementsByType ( "player" ) ) do
        exports["dxmessages"]:outputDx ( plr, "the mission will start after 5 seconds", "info" )
            setElementData ( plr, 'MissionP', false )
                if ( isPlayerInMission ( 2, plr ) == true ) then
            setElementDimension ( plr, 100 )
        setElementPosition ( plr, -2690.51367, 1289.90479, 55.42969 )
            setElementFrozen( plr, true )
                    setTimer ( function (    )
                    setElementData ( plr, 'MissionR', false )
                setElementFrozen ( plr , false ) 
            exports["dxmessages"]:outputDx ( plr, "the mission was stated", "info" )
                exports["dxmessages"]:outputDx ( plr, "Players in the mission :", "info" )
            exports["dxmessages"]:outputDx ( plr, #getPlayersInMission ( plr ), "info" )
            end , 5000, 1 )
        end
    end
end

 

طبعا لازم اذا تبي تشغل الوضيفة تسوي كذا مثلا

 

addCommandHandler ( "Start", function ( )
    openMission ( )
end )

 

Edited by #,+( _xiRoc[K]; >
  • Like 1
Link to comment
20 minutes ago, #,+( _xiRoc[K]; > said:

مثال

جرب كذا :


local marker = createMarker(2027.60059, 1007.15759, 10.82031,'cylinder',2,0,255,0,150)

function getPlayersInMission ( plr )
local plrs = {

}
        if ( isElement ( plr ) and ( getElementType ( plr ) == "player" ) and ( getElementData ( plr, "MissionR" ) == true ) ) then
            table.insert ( plrs, plr )
        end
    return plrs
end

function isPlayerInMission ( num, plr )
    if ( isElement ( plr ) and ( getElementType ( plr ) == "player" ) ) then
        if ( num == 2 ) then
            if ( getElementData ( plr, "MissionR" ) == true ) then
        return true
    else
        return false
    end
        else
            if ( getElementData ( plr, "MissionP" ) == true ) then
        return true
    else
        return false
            end
        end
    end
end

addEventHandler ( "onMarkerHit", resourceRoot, function ( player )
            if ( source == marker ) and ( getElementType ( player ) == "player" ) then 
                if ( isPlayerInMission ( 1, player ) == true ) then
        exports["dxmessages"]:outputDx ( player,"Hi "..getPlayerName(player).." #FFFFFFthe mission not started yet", "error" )
    else
        if not ( isPedInVehicle ( player ) ) then
        exports["dxmessages"]:outputDx ( player, "this join was mission , Good Luck", "success" )
          setElementData ( player, 'MissionR', true )
        setElementData ( player, 'MissionP', true )
    end
        end
    end
end )

function openMission ( )
    for _ ,plr in ipairs ( getElementsByType ( "player" ) ) do
        exports["dxmessages"]:outputDx ( plr, "the mission will start after 5 seconds", "info" )
            setElementData ( plr, 'MissionP', false )
                if ( isPlayerInMission ( 2, plr ) == true ) then
            setElementDimension ( plr, 100 )
        setElementPosition ( plr, -2690.51367, 1289.90479, 55.42969 )
            setElementFrozen( plr, true )
                    setTimer ( function (    )
                    setElementData ( plr, 'MissionR', false )
                setElementFrozen ( plr , false ) 
            exports["dxmessages"]:outputDx ( plr, "the mission was stated", "info" )
                exports["dxmessages"]:outputDx ( plr, "Players in the mission :", "info" )
            exports["dxmessages"]:outputDx ( plr, #getPlayersInMission ( plr ), "info" )
            end , 5000, 1 )
        end
    end
end

 

طبعا لازم اذا تبي تشغل الوضيفة تسوي كذا مثلا

 


addCommandHandler ( "Start", function ( )
    openMission ( )
end )

 

انا حاليا برا البيت لا رجعت بجرب

Link to comment

جرب عدلت الوظيفة وضفت لها كم شي :

 

local marker = createMarker ( 2488.88281, -1675.15833, 13.33595, "cylinder", 1.5, 255, 255, 255, 255 )

plrs = {

}

function setPlayerInMission ( plr )
		if ( isElement ( plr ) and ( getElementType ( plr ) == "player" ) and ( getElementData ( plr, "MissionR" ) == true ) ) then
		table.insert ( plrs, plr )
	end
end


function getPlayersInMission (  )
	return plrs
end

function isPlayerInMission ( num, plr )
	if ( isElement ( plr ) and ( getElementType ( plr ) == "player" ) ) then
		if ( num == 2 ) then
			if ( getElementData ( plr, "MissionR" ) == true ) then
		return true
	else
		return false
	end
		else
			if ( num == 1 ) then
			if ( getElementData ( plr, "MissionP" ) == true ) then
		return true
	else
		return false
			end
		end
		end
	end
end

function endRace ( plr )
if ( getElementData ( plr, "datap" ) == true ) then
	setElementDimension ( plr, 0 )
		setElementPosition ( plr, 2486.92505, -1665.90735, 13.34375 )
			exports["dxmessages"]:outputDx ( plr, " The mission end and the winner is : " .. getElementData ( root, "Winner" ), "info" )
		setElementData ( plr, "datap", false )
		destroyElement ( marker1 )
plrs = {

}
	end
end

addEventHandler ( "onMarkerHit", resourceRoot, function ( player )
			if ( source == marker ) and ( getElementType ( player ) == "player" ) then 
				if ( isPlayerInMission ( 1, player ) == true ) then
		exports["dxmessages"]:outputDx ( player,"Hi "..getPlayerName(player).." #FFFFFFthe mission not started yet", "error" )
	else
		if not ( isPedInVehicle ( player ) ) then
		exports["dxmessages"]:outputDx ( player, "this join was mission , Good Luck", "success" )
      	setElementData ( player, 'MissionR', true )
		setElementData ( player, 'MissionP', true )
		setPlayerInMission ( player )
    end
		end
			elseif ( source == marker1 ) and ( getElementType ( player ) == "player" ) then
				setElementData ( root, "Winner", getPlayerName ( player ) )
				for i, v in ipairs ( getElementsByType ( "player" ) ) do
			endRace ( v )
plrs = {

}
		end
	end
end )

function openMission ( )
	for _ ,plr in ipairs ( getElementsByType ( "player" ) ) do
		exports["dxmessages"]:outputDx ( plr, "the mission will start after 5 seconds", "info" )
			setElementData ( plr, 'MissionP', false )
				if ( isPlayerInMission ( 2, plr ) == true ) then
			 marker1 = createMarker ( -2662.63989, 1175.23840, 55.42969, "cylinder", 1.5, 255, 255, 255, 255 )
			setElementDimension ( plr, 100 )
			setElementDimension ( marker1, 100 )
		setElementPosition ( plr, -2690.51367, 1289.90479, 55.42969 )
			setElementFrozen( plr, true )
					setTimer ( function (	)
					setElementData ( plr, 'MissionR', false )
				setElementFrozen ( plr , false ) 
				setElementData ( plr, "datap", true )
			exports["dxmessages"]:outputDx ( plr, "the mission was stated", "info" )
				exports["dxmessages"]:outputDx ( plr, "Players in the mission :", "info" )
					plrsz = getPlayersInMission ( )
						for i = 1, #plrsz do
					exports["dxmessages"]:outputDx ( plr, getPlayerName ( plrsz [ i ] ), "info" )
				end
			end , 5000, 1 )
		end
	end
end

addEventHandler ( "onResourceStop", resourceRoot, function (	)
	for _ ,plr in ipairs ( getElementsByType ( "player" ) ) do
		setElementData ( plr, 'MissionP', false )
	setElementData ( plr, 'MissionR', false )
	end
end )

addCommandHandler ( "Start", function ( )
	openMission ( )
end )

 

Edited by #,+( _xiRoc[K]; >
  • Like 1
Link to comment
8 hours ago, Talis said:

@#,+( _xiRoc[K]; > الله يعطيك الف عافية 

الحين عندي سؤالين كيف اخلي اذا دخل لاعب واحد مايدخله المهمة

السؤال الثاني هل الكل يشوف الرسالة ؟ واذا ايه كيف اخلي اللي في المهمة فقط يشوفون الرسالة

 

اي رسالة بالضبط ؟ انا خليت الي داخل يشوفون هذي الرسائل

 

exports["dxmessages"]:outputDx ( plr, "the mission was stated", "info" )

exports["dxmessages"]:outputDx ( plr, "Players in the mission :", "info" )

plrsz = getPlayersInMission ( )

for i = 1, #plrsz do

exports["dxmessages"]:outputDx ( plr, getPlayerName ( plrsz [ i ] ), "info" )
  
-------------
  
exports["dxmessages"]:outputDx ( plr, " The mission end and the winner is : " .. getElementData ( root, "Winner" ), "info" )

 

بقاية الرسائل الكل يشوفهم

  • Like 1
Link to comment
12 minutes ago, Talis said:

سويت يحط رقم قبل اسم اللاعب لاكن محاولاتي باتت بالفشل


					plrsz = getPlayersInMission ( )
						for i = 1, #plrsz do
					exports["dxmessages"]:outputDx ( plr, ["..i.."](getPlayerName ( plrsz [ i ] ), "info" ))

 

جرب

		plrsz = getPlayersInMission ( )
						for i = 1, #plrsz do
					exports["dxmessages"]:outputDx ( plr,'['..i..']'..(getPlayerName ( plrsz [ i ] ), "info" ))
 

 

  • Like 1
Link to comment
14 hours ago, Talis said:

@#,+( _xiRoc[K]; > الله يعطيك الف عافية 

الحين عندي سؤالين كيف اخلي اذا دخل لاعب واحد مايدخله المهمة

السؤال الثاني هل الكل يشوف الرسالة ؟ واذا ايه كيف اخلي اللي في المهمة فقط يشوفون الرسالة

 

بالنسبة لسؤالك الأول تسوي تحقق تجيب في طول الجدول ب # اذا كان عدد الاعبين == 0 او == 1 تسوي return end

  • Like 1
Link to comment
9 minutes ago, Talis said:

	     givePlayerMoney(Winner,math.random("50000","300000"))

اعذروني بس وش المشكلة هنا

 

انت حاط سترنق المفروض تشيل السترنق لو تلاحض الساينتكس 

bool givePlayerMoney ( player thePlayer, int amount )

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