Jump to content

hi spawn ramdom i't not work


zen13

Recommended Posts

hi spawn i't not work

    local spawnPositions = { 
{214.0243072509+math.random(-5,5),1911.436889648+math.random(-5,5),17.640625}, 
{268.290039062+math,random(-5,5),2489.9414062+math,random(-5,5),16.383375}, 
{268.290039062+math,random(-5,5),2489.9214062+math,random(-5,5),16.383375}, 
} 
  
local x, y, z = spawnPositions[number][1], spawnPositions[number][2], spawnPositions[number][3] 
  spawnPlayer(player, x, y, z, math.random(0, 360), 73, 0, 0) 
  
  
  

Help me piz

Link to comment
-- Note: Not Tested 
local spawnPositions = { 
{214.0243072509+math.random(-5,5),1911.436889648+math.random(-5,5),17.640625}, 
{268.290039062+math,random(-5,5),2489.9414062+math,random(-5,5),16.383375}, 
{268.290039062+math,random(-5,5),2489.9214062+math,random(-5,5),16.383375}, 
} 
  
function spawnThePlayer ( player ) 
    local number = math.random ( #spawnPositions  ) 
    local x, y, z = spawnPositions[number][1], spawnPositions[number][2], spawnPositions[number][3] 
    spawnPlayer(player, x, y, z, math.random(0, 360), 73, 0, 0) 
end 
  
addEventHandler ( "onPlayerLogin", root, function ( ) spawnThePlayer  ( source ) end ) 
  

Link to comment

help me i want

first login and death use random spawn

214.0243072509+math.random(-5,5),1911.436889648+math.random(-5,5),17.640625

268.290039062+math,random(-5,5),2489.9414062+math,random(-5,5),16.383375

now i can make one spawn

--[[  
P-spawn by B!ERPuNK 
Edited and added starting mission 
  
Thanks B!ERPuNK. 
]]-- 
  
  
function afterLogin(p) 
setTimer(function(p) 
    local source = p 
    local account = getPlayerAccount(source) 
    if barracks and homeBlip then  
        destroyElement(barracks)  
        destroyElement(homeBlip)  
        barracks, homeBlip = nil, nil 
    end 
    if showMarker then 
        destroyElement(showMarker) 
        showMarker = nil 
    end 
    if not getAccountData(account,"tutorial") then 
        spawnPlayer(source,214.0243072509+math.random(-5,5),1911.436889648+math.random(-5,5),17.640625) 
    local account = getPlayerAccount(p) 
setAccountData(account,"tutorial",true) 
        setCameraTarget(source) 
        fadeCamera(source,true,5)      
        attachElements(showMarker,source,0,0,-2) 
        outputChatBox("ยินดีตอนรับเข้าสู่ Project Black ",source,255,255,0,true) 
        outputChatBox("กด F9 เพื่อดูวิธีการเล่น!",source,255,255,0,true) 
        giveWeapon(p,22,50,true) 
   setPedSkin(p,66 , true)  
        -- Some zombies to give the player a little difficulty 
        createZombie(2827.2592773438, -2351.7189941406, 19.205839157104) 
        createZombie(2838.8562011719, -2345.6728515625, 19.205837249756) 
        createZombie(2827.9130859375, -2361.0776367188, 22.798677444458) 
        createZombie(2833.7160644531, -2355.1584472656, 26.893081665039) 
        createZombie(2825.9729003906, -2370.8776855469, 28.681663513184) 
        createZombie(2827.2592773438, -2351.7189941406, 20.205839157104) 
        createZombie(2838.8562011719, -2345.6728515625, 202058372497560) 
        createZombie(2827.9130859375, -2361.0776367188, 23.798677444458) 
        createZombie(2833.7160644531, -2355.1584472656, 23.893081665039) 
        createZombie(2825.9729003906, -2370.8776855469, 29.681663513184) 
    else 
        afterLoginNoTut(source) 
    end 
end,500,1,p) 
end 
  
function goToSafehouse(p) 
if not isElement(p) or getElementType(p) ~= "player" then return end 
if not getElementData(p,"entered") and not getAccountData(getPlayerAccount(p),"tutorial") then 
barracks = createVehicle(422,2783.9313964844,-2417.5051269531,14,0,0,90,"ESCAPE") 
setMarkerTarget(showMarker,2505.6860351563, -1684.3099365234, 13.546875) 
outputChatBox("ขึ้นรถแล้วขับหรือวิงไปตามลูกศรเพื่อไปยัง #009900Safe Zone. หรือรูปบ้านในแผนที่",p,255,255,0,true) 
homeBlip = createBlip(2495.3813476563, -1691.1353759766, 14.765625,31,2,255,0,0,255,1234,1000,p) 
setElementData(p,"entered",true) 
attachElements(showMarker,p) 
end 
end 
addEventHandler("onColShapeHit", createColRectangle(2774.9299316406, -2429.623046875,26.501953125,23.681640625), goToSafehouse) 
  
function gotToSafehouse(p) 
if not isElement(p) then return end 
if getElementType(p) ~= "player" or not getElementData(p,"entered") or getAccountData(getPlayerAccount(p),"tutorial") then return end 
triggerClientEvent(p,"missionCompleted",getRootElement()) 
outputChatBox("ภารกิจสำเสร็จ คุณได้มาถึง #009900จุดหมาย  ถ้าคุณตายครั้งต่อไปจะไปเกิดที่ Safe Zone  กด F9 เพื่อดูวิธีเล่น",p,255,255,0,true) 
outputChatBox("The vehicle will be destroyed now. Also, you will get 5 EXP for completing this mission.",p,255,255,0) 
destroyElement(showMarker) 
destroyElement(homeBlip) 
setTimer(destroyElement,5000,1,barracks) 
showMarker = nil 
homeBlip = nil 
setTimer(function() barracks = nil end,5500,1) 
local account = getPlayerAccount(p) 
setAccountData(account,"tutorial",true) 
local old = getAccountData(account,"zombies.kills") or 0 
setAccountData(account,"zombies.kills",old+5) 
triggerClientEvent(p,"expOnChange",getRootElement(),old+5,5) 
end 
addEventHandler("onColShapeHit", createColRectangle(2480.3623046875, -1689.3347167969,25.6303711,30.8875732),gotToSafehouse) 
  
--[[  
From this, its the normal spawn and onLogin event  over this thats the tut 
And i dont know why i write notes to myself in english. 
Tehแt ez felett van a tutoriแlos cucc, ez alatt a normแlis login meg wasted utแn. 
]]-- 
  
function spawnOnDead(ammo, killer, weapon, bodypart) 
    local account = getPlayerAccount(source) 
    local x,y,z = getElementPosition(source) 
    if z < 1 then fadeCamera(source,false,1,0,0,20) else fadeCamera(source,false,1,150,0,0) end 
    destroyElement(showMarker) 
  setTimer(setPedSkin ,2500,1,source, 66 , true)  
    setTimer(giveWeapon,2500,1,source,22,50,true) 
  
    if killer and getElementType(killer) == "player" then  
    end 
    fadeCamera(source,true,2) 
  
    setTimer(spawnPlayer,1500,1,source,214.0243072509+math.random(-5,5),1911.436889648+math.random(-5,5),17.640625) 
  
end 
  
function afterLoginNoTut(source) 
    local outside = getElementData(source,"outside") 
    if outside == true or outside == 2 then 
        spawnPlayer(source,2301.9077148438, -1632.7995605469, 15.3) 
        if outside == 2 then 
            for i=1,10 do  
                createZombie(2299+i,-1659,155)  
            end 
        end 
    removeElementData(source,"outside") 
    else 
         
    end 
    setCameraTarget(source) 
    fadeCamera(source,true,2) 
end 
  
  
addEventHandler("onPlayerLogin", getRootElement(), function() afterLogin(source) end) 
addEventHandler("onPlayerWasted", getRootElement(), spawnOnDead) 
  

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