Jump to content

math.random + spawnplayer طلب كود بـ


Recommended Posts

سلام عليكم

آبي لو آحد كتب سسبآون بآف 8

يحطه في آلآحدآثيآت آلآولي

ولو آحد تآني كتب سبآون في آلآحدآثيآت آلتآنية

ولو آحد تآلت كتب سبآون في آلآحدآثيآت آلتآلتة وآلخ .....

local RespawnPosition = {
{2,3,4},
{1,2,3},
}

addCommandHandler("respawn",
	function()
		local x, y, z = unpack(RespawnPosition[math.random(#RespawnPosition)])
		spawnPlayer ( source,x, y, z,180, 46, 0, 0)
	end
)

 

Link to comment

جرب هذا 

local positionTable,countTable = { 
[1] = {0,0,3},
[2] = {100,0,3},
[3] = {120,0,1},
},0

addCommandHandler ( "spawn" , function ( player ) 
countTable = countTable + 1 
if ( countTable >= #positionTable+1 )  then countTable = 0 end
spawnPlayer ( player ,positionTable[countTable][1],positionTable[countTable][2],positionTable[countTable][3],180, 46, 0, 0)
end ) ; 

 

Link to comment
  • 1 month later...
On 08/08/2018 at 03:45, Trefeor said:

جرب هذا 


local positionTable,countTable = { 
[1] = {0,0,3},
[2] = {100,0,3},
[3] = {120,0,1},
},0

addCommandHandler ( "spawn" , function ( player ) 
countTable = countTable + 1 
if ( countTable >= #positionTable+1 )  then countTable = 0 end
spawnPlayer ( player ,positionTable[countTable][1],positionTable[countTable][2],positionTable[countTable][3],180, 46, 0, 0)
end ) ; 

 

ظبط , بس يجي علي اخر احداثيات ويكررها مرتين

يعني لو كتبت الكوماند ينقلني ل 1

لو كتبت تاني ينقلني 2 

لو كتبت ثالث ينقلني 3

لو كتبت رابع ينقلني 3 تاني .. بعدين يعيد الجدول

ــ 

يعني اخر احداثيات تنعاد مرتين , مافي لها حل؟

Edited by Mr.Mostafa
Link to comment

استبدل ذا باللي عندك

local placeCount = 0
local RespawnPosition = {
	{ 2, 3, 4 },
	{ 1, 2, 3 },
}

addCommandHandler("respawn",
	function ( player )
		placeCount = placeCount + 1
		spawnPlayer ( player, RespawnPosition[placeCount][1], RespawnPosition[placeCount][2], RespawnPosition[placeCount][3], 180, 46, 0, 0 )
		if placeCount >= #RespawnPosition then placeCount = 0 end
	end
)

 

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