Jump to content

Spawnwindow and some spawnpoints.


Nec

Recommended Posts

any here, can help me with this.

i am trying to make that but i dont know LUA.

and is not easy.

Thanks.

50p know what i talked.

i dont know where's the problem CHECK

--Spawn UI v2

--Written by: Me

--I hope this fucking works

--Create the spawnWindow selection (Our only fucking window)

spawnWindow = guiCreateWindow(0.7, 0.7, 0.3, 0.3, "Spawn Selection", true)

spawnList = guiCreateGridList(0.05, 0.1, 0.5, 0.85, true, spawnWindow)

spawnButton = guiCreateButton(0.7, 0.85, 0.2, 0.25, "Spawn", true,

spawnWindow)

spawnLabel = guiCreateLabel(0.6, 0.15, 0.15, 0.12, "Skin", true, spawnWindow)

spawnSkin = guiCreateStaticImage(0.7, 0.25, 0.2, 0.5214, "images/box.png",

true, spawnWindow)

spawnInfoWindow = guiCreateWindow(0.7, 0.55, 0.3, 0.15, "Class Information", true)

spawnInfoLabel = guiCreateLabel(0.05, 0.25, 0.95, 0.75, "Class Information", true, spawnInfoWindow)

--Create column (and throw the fucker away, afterwards)

guiGridListAddColumn(spawnList, "Class", 0.9)

--Store previously selected information (to prevent repetitition)

selected = {

teamIndex = 0,

classIndex = 0

}

--Me cheating and knowing what a location looks like

default = {

camPos = {

x = 1967.71,

y = 1342.9,

z = 26.63

},

camTarget = {

x = 2034.47,

y = 1343.02,

z = 23.01

}

}

--The class

class = {}

--Make the UI visible when it needs to be

function f_onResourceStart()

f_setSpawnWindowVisible(true)

f_getClasses()

f_initGUI()

f_setCameraAtLocation(default)

f_fadeCameraIn(1.0)

guiLabelSetHorizontalAlign(spawnInfoLabel, "left", true)

end

addEventHandler("onClientResourceStart",

getResourceRootElement(getThisResource()), f_onResourceStart)

function f_onClientPlayerWasted(killer, weapon, bodypart)

if (source == getLocalPlayer()) then

f_initSpawnOnDeath()

end

end

addEventHandler("onClientPlayerWasted", getRootElement(),

f_onClientPlayerWasted)

--Make the UI visible when it doesn't need to be

function f_onResourceStop()

f_setSpawnWindowVisible(false)

guiSetVisible(spawnInfoWindow, false)

f_fadeCameraIn(0)

end

addEventHandler("onClientResourceStop",

getResourceRootElement(getThisResource()), f_onResourceStop)

function f_initSpawnOnDeath()

setTimer(f_fadeCameraOut, 3000, 1, 1.0)

setTimer(f_setSpawnWindowVisible, 4000, 1, true)

setTimer(f_setCamreaOnClick, 4000, 1)

setTimer(f_fadeCameraIn, 4000, 1, 1.0)

end

--Populate the UI depending on what happens

function f_getClasses()

triggerServerEvent("s_getClasses", getLocalPlayer())

end

addEvent("c_setClasses", true)

function f_setClasses(teams, classes)

for i, team in ipairs(teams) do

local header = guiGridListAddRow(spawnList)

guiGridListSetItemText(spawnList, header, 1, team, true,

false)

for j, class in pairs(classes) do

local row = guiGridListAddRow(spawnList)

guiGridListSetItemText(spawnList, row, 1, class, false,

false)

guiGridListSetItemData(spawnList, row, 1, tostring(i) .. " "

.. tostring(j))

end

end

addEventHandler("onClientGUIClick", spawnList, f_getClassData)

end

addEventHandler("c_setClasses", getRootElement(), f_setClasses)

function f_getClassData()

if (source == spawnList) then

triggerServerEvent("s_getClassData", getLocalPlayer(),

f_getSelectedTeamIndex(), f_getSelectedClassIndex())

end

end

addEvent("c_setClassData", true)

function f_setClassData(s_class)

class = s_class

f_setCameraOnClick()

f_setSkinImage(f_getSelectedSkin())

guiSetVisible(spawnInfoWindow, true)

guiSetText(spawnInfoLabel, s_class.info)

end

addEventHandler("c_setClassData", getRootElement(), f_setClassData)

--Spawn Player

function f_spawnPlayer(button)

if (f_getSelectedTeamIndex()) and (f_getSelectedClassIndex()) and

(button == "left") and (source == spawnButton) then

triggerServerEvent("s_spawnPlayer", getLocalPlayer(),

f_getSelectedTeamIndex(), f_getSelectedClassIndex(),

f_getSelectedSkinIndex(), f_getSelectedLocationIndex(),

f_getSelectedSpawnIndex())

f_setSpawnWindowVisible(false)

guiSetVisible(spawnInfoWindow, false)

end

end

--Utility Functions

function f_setCameraOnClick(element)

f_setCameraAtLocation(f_getSelectedLocation())

end

function f_setCameraAtLocation(location)

--Fade camera out

f_fadeCameraOut(0)

guiSetVisible(spawnButton, false)

--Wait for screen to be faded before setting position

setTimer ( setCameraMatrix, 50, 1, location.camPos.x, location.camPos.y, location.camPos.z, location.camTarget.x, location.camTarget.y, location.camTarget.z )

--Fade camera back in

setTimer(guiSetVisible, 500, 1, spawnButton, true)

setTimer(f_fadeCameraIn, 500, 1)

end

function f_setSkinImage(skin)

guiStaticImageLoadImage(spawnSkin, "images/skins/" .. tostring(skin.id) ..

".png")

end

function f_fadeCameraOut(time)

setTimer(fadeCamera, 100, 1, false, time)

end

function f_fadeCameraIn(time)

setTimer(fadeCamera, 100, 1, true, time)

end

function f_initGUI()

--Disable sorting

guiGridListSetSortingEnabled(spawnList, false)

--Spawn button click

addEventHandler("onClientGUIClick", spawnButton, f_spawnPlayer)

end

function f_setSpawnWindowVisible(visible)

guiSetVisible(spawnWindow, visible)

showCursor(visible)

if (visible) then

guiBringToFront(spawnWindow)

end

if not visible then

setCameraTarget ( getLocalPlayer ( ) )

end

end

--Index Functions

function f_getSelectedTeamIndex()

local n = guiGridListGetItemData(spawnList,

guiGridListGetSelectedItem(spawnList), 1)

return tonumber(gettok(n, 1, string.byte(' ')))

end

function f_getSelectedClassIndex()

local n = guiGridListGetItemData(spawnList,

guiGridListGetSelectedItem(spawnList), 1)

return tonumber(gettok(n, 2, string.byte(' ')))

end

function f_getSelectedSkinIndex()

return 1

end

function f_getSelectedLocationIndex()

return 1

end

function f_getSelectedSpawnIndex()

return 1

end

--Table Functions

function f_getSelectedLocation()

return class.locations[1]

end

function f_getSelectedSkin()

return class.skins[1]

end

Link to comment
dude this is FREESTATEPROJET SPAWNGUI why u steal from it u need server side if im right

This was FreeStateProject's "Spawn UI" (it's very old).. I made completely new one which source code is not fully available.. and yes, you need server-side script for this too.

Nec, you will not get code from us... We help here (correct your code, point you to different directions, etc.), not do things for you. Once you come up with some code we can help but don't expect people making scripts for free here, unless you find someone who wants to make it for you.

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