Guys i dont Understand The Older Spawn Selection i readed All The lua andi dont Understand It 100% Guys Plz
This is The File Name : s_main.lua
g_root = getRootElement( );
classGroups = { };
addEvent( "spawn_clientRequestSpawn", true );
addEventHandler( "spawn_clientRequestSpawn", g_root,
function( categoryIndex, classIndex, skinIndex, password )
if skinIndex then
local class = classGroups[ categoryIndex ].classes[ classIndex ];
if class.password then
if not password or password == "soap" then
triggerClientEvent( client, "spawn_requestPassword", root, class.name );
return;
elseif password ~= class.password then
outputChatBox( "The password you typed in is incorrect! Try again or cancel to choose different class.", client, 200, 50, 50 );
triggerClientEvent( client, "spawn_requestPassword", root, class.name );
return;
end
end
local skin = class.skinMngr.skins[ skinIndex ];
local spawn = true;
local spawned;
--[[if not classGroups[ cetegoryIndex ].owner then -- if there is NO owner of the clan/gang spawn player
spawn = true;
else -- if there IS owner of the clan/gang then check if he's member of the clan/gang
end]]
if spawn then
if not class.team then
class.team = createTeam( class.name, class.color.red, class.color.green, class.color.blue );
end
local plrTeam = getPlayerTeam( client );
if ( ( plrTeam ) and ( plrTeam ~= class.team ) and ( countPlayersInTeam( plrTeam ) == 1 ) ) then
destroyElement( plrTeam );
end
spawned = spawnPlayer(
client,
skin.spawnLoc.x,
skin.spawnLoc.y,
skin.spawnLoc.z,
skin.spawnLoc.rot,
skin.modelId,
0, 0,
class.team
);
end
if spawned then
setElementData( client, "team", class.name )
setElementData( client, "skin", skin.name )
fadeCamera( client, true );
setCameraTarget( client, client );
setTimer( setCameraTarget, 200, 1, client, client );
triggerClientEvent( client, "spawn_SpawnedSuccessfully", client );
--setPlayerMoney( client, 500 );
for _, weapon in ipairs( class.weaponMngr.weapons ) do
giveWeapon( client, weapon.id, weapon.ammo, false );
end
createBlipAttachedTo( client, 0, 2, class.color.red, class.color.green, class.color.blue )
else
triggerClientEvent( client, "spawn_FailedToSpawn", client );
if countPlayersInTeam( class.team ) == 0 then
destroyElement( class.team );
class.team = nil;
end
end
end
end
);
addEvent( "spawn_receivePassword", true );
addEventHandler( "spawn_receivePassword", g_root,
function( )
end
);
addEventHandler( "onPlayerSpawn", g_root,
function ( )
end
);
addEventHandler( "onPlayerWasted", g_root,
function( )
fadeCamera( source, false, 4 );
setTimer( requestMenu, 5000, 1, source );
deleteAllPlayerBlips( source )
end
);
function requestMenu( player )
callClientFunc( player, "showSpawnMenu", true, true );
callClientFunc( player, "classSelected" );
end
addCommandHandler( "kill",
function( plr )
killPed( plr );
end
)
function preloadClassesInfo( )
local groups = getElementsByType( "category" );
for _, group in ipairs( groups ) do
table.insert( classGroups, Group:New( group ) );
end
end
addEventHandler( "onResourceStart", getResourceRootElement(), preloadClassesInfo )
function deleteAllPlayerBlips(player)
local elements = getAttachedElements(player)
if (elements) then
for i, element in ipairs(elements) do
if (getElementType(element) == "blip") then
destroyElement(element)
end
end
end
print( "number of players in team: " .. tostring( countPlayersInTeam( getPlayerTeam( player ) ) ) );
end
addEventHandler( "onPlayerQuit", g_root, function() deleteAllPlayerBlips(source) end );
------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------
function callClientFunc( player, funcName, ... )
if #{ ... } ~= 0 then
triggerClientEvent( player, "_clientCallFunction", root, funcName, ... )
else
triggerClientEvent( player, "_clientCallFunction", root, funcName )
end
end
addEvent( "_serverCallFunction", true )
addEventHandler( "_serverCallFunction", root,
function( funcName, ... )
_G[ funcName ](...)
end
)
thi is file name!: s_spawnclasses.lua
Group = { };
Group.__index = { };[*]
function Group: New( groupElement )
local group = {
name = "",
classes = { },
};
if getElementType( groupElement ) == "category" then
setmetatable( group, self );
self.__index = self;
group.name = getElementData( groupElement, "id" );
local children = getElementChildren( groupElement );
for _, child in ipairs( children ) do
table.insert( group.classes, Class:New( child ) );
end
return group;
end
return false;
end
--[[================================================================================]]--
--[[================================================================================]]--
Class = { };
Class.__index = Class;
function Class: New( classElement )
local class = {
name = "",
info = "",
color = { red = 255, green = 255, blue = 255 },
skinMngr = SkinManager:New( ),
weaponMngr = WeaponManager:New( ),
cameraMngr = CameraManager:New( ),
}
if getElementType( classElement ) == "class" then
setmetatable( class, self );
self.__index = self;
class.weaponMngr.__index = class.weaponMngr;
class.name = getElementData( classElement, "name" );
local classData = getElementChildren( classElement );
for _, data in ipairs( classData ) do
if getElementType( data ) == "info" then
class.info = getElementData( data, "text" );
elseif getElementType( data ) == "color" then
class.color.red = tonumber( 0 and getElementData( data, "red" ) or 255 );
class.color.green = tonumber( 0 and getElementData( data, "green" ) or 255 );
class.color.blue = tonumber( 0 and getElementData( data, "blue" ) or 255 );
elseif getElementType( data ) == "skin" then
class.skinMngr:AddSkin( data );
elseif getElementType( data ) == "weapon" then
class.weaponMngr:AddWeapon( data );
elseif getElementType( data ) == "camera" then
local camChildren = getElementChildren( data );
for _, camInfo in ipairs( camChildren ) do
if getElementType( camInfo ) == "position" then
class.cameraMngr:Position( camInfo );
elseif getElementType( camInfo ) == "lookAt" then
class.cameraMngr:LookAt( camInfo );
end
end
end
end
return class;
end
return false;
end
--[[================================================================================]]--
--[[================================================================================]]--
CameraManager = { };
CameraManager.__index = CameraManager;
function CameraManager: New( )
local cameramngr = {
pos = { },
lookAt = { },
};
setmetatable( cameramngr, self );
self.__index = self;
return cameramngr;
end
function CameraManager: Position( cameraPosElement )
if cameraPosElement then
self.pos.x = tonumber( getElementData( cameraPosElement, "x" ) );
self.pos.y = tonumber( getElementData( cameraPosElement, "y" ) );
self.pos.z = tonumber( getElementData( cameraPosElement, "z" ) );
else
return self.pos.x, self.pos.y, self.pos.z;
end
end
function CameraManager: LookAt( cameraLookAtElement )
if cameraLookAtElement then
self.lookAt.x = tonumber( getElementData( cameraLookAtElement, "x" ) );
self.lookAt.y = tonumber( getElementData( cameraLookAtElement, "y" ) );
self.lookAt.z = tonumber( getElementData( cameraLookAtElement, "z" ) );
else
return self.lookAt.x, self.lookAt.y, self.lookAt.z;
end
end
--[[================================================================================]]--
--[[================================================================================]]--
Skin = { };
Skin.__index = Skin;
function Skin: New( skinElement )
local skin = {
name = "",
modelId = 0,
weaponMngr = WeaponManager:New( ),
spawnLoc = { x, y, z },
}
if getElementType( skinElement ) == "skin" then
setmetatable( skin, self );
self.__index = self;
--setmetatable( skin.weaponMngr, WeaponManager );
skin.weaponMngr.__index = skin.weaponMngr;
skin.name = getElementData( skinElement, "name" );
skin.modelId = getElementData( skinElement, "id" );
local children = getElementChildren( skinElement );
for _, child in ipairs( children ) do
if getElementType( child ) == "spawnpoint" then
skin.spawnLoc.x = tonumber( getElementData( child, "x" ) );
skin.spawnLoc.y = tonumber( getElementData( child, "y" ) );
skin.spawnLoc.z = tonumber( getElementData( child, "z" ) );
skin.spawnLoc.rot = tonumber( getElementData( child, "rot" ) );
elseif getElementType( child ) == "weapon" then
skin.weaponMngr:AddWeapon( child );
end
end
return skin;
end
return false;
end
function Skin: GetSpawnPosition( )
return self.spawnLoc.x, self.spawnLoc.y, self.spawnLoc.z;
end
--[[================================================================================]]--
--[[================================================================================]]--
SkinManager = { };
SkinManager.__index = SkinManager;
function SkinManager: New( )
local skinmngr = {
skins = { },
};
setmetatable( skinmngr, self );
self.__index = self;
return skinmngr;
end
function SkinManager: AddSkin( skinElement )
table.insert( self.skins, Skin:New( skinElement ) );
end
function SkinManager: GetSkins( )
return self.skins;
end
--[[================================================================================]]--
--[[================================================================================]]--
Weapon = { };
Weapon.__index = Weapon;
function Weapon: New( weaponElement )
local weapon = {
id = 0,
ammo = 0,
};
if getElementType( weaponElement ) == "weapon" then
setmetatable( weapon, self );
self.__index = self;
weapon.id = tonumber( getElementData( weaponElement, "id" ) );
weapon.ammo = tonumber( getElementData( weaponElement, "ammo" ) );
return weapon;
end
return false;
end
--[[================================================================================]]--
--[[================================================================================]]--
WeaponManager = { };
WeaponManager.__index = WeaponManager;
function WeaponManager: New( )
local weaponmngr = {
weapons = { },
};
setmetatable( weaponmngr, self );
self.__index = self;
return weaponmngr;
end
function WeaponManager: AddWeapon( weaponElement )
table.insert( self.weapons, Weapon:New( weaponElement ) );
end
function WeaponManager: GetWeapons( )
local weapons = { };
for i, weapon in ipairs( self.weapons ) do
weapons[ i ] = { };
weapons[ i ].id = weapon.id;
weapons[ i ].ammo = weapon.ammo;
end
return weapons;
end
function WeaponManager: WeaponCount( )
return #self.weapons;
end
fILE NAME: c_main.lua
g_Me = getLocalPlayer( ); g_root = getRootElement( ); g_ResRoot = getResourceRootElement( ); screenSize = { guiGetScreenSize( ) }; --local stripHeight = .15 * (screenSize[ 2 ]*2); letterBox = { stripHeight = screenSize[ 2 ] * .15, stripAlpha = .93, -- 0-1 animLength = 01, -- seconds animStartTick = 0, animFinishTick = 0, keepAnimating = true, flyIn = function ( ) letterBox.animStartTick = 0; addEventHandler( "onClientRender", g_root, animateLetterBox_flyIn ); setTempPedRotating( true ); end, flyOut = function ( ) letterBox.animStartTick = 0; setTempPedRotating( false ); removeEventHandler( "onClientRender", g_root, animateLetterBox_flyIn ) addEventHandler( "onClientRender", g_root, animateLetterBox_flyOut ); end, } local pedRot = 0; allHUDElements = { "ammo", "area_name", "armour", "breath", "clock", "health", "money", "radar", "vehicle_name", "weapon", } iconWidths = { [0] = 21, [1] = 15, [2] = 97, [3] = 55, [4] = 83, [5] = 72, [6] = 55, [7] = 138, [8] = 104, [9] = 59, [10] =40 , [11] =31 , [12] =41 , [14] =10 , [15] =71 , [16] =13 , [17] =10 , [18] =4 , [19] =17, [22] =35 , [23] =50 , [24] =37 , [25] =75 , [26] =67 , [27] =66 , [28] =17 , [29] =35 , [30] =70 , [31] =71 , [32] =22 , [33] =75 , [34] =86 , [35] =74 , [36] =75 , [37] =19 , [38] =54 , [39] =8, [42] = 14, } icons = { [0] = ":killmessages/icons/fist.png", [1] = ":killmessages/icons/brassknuckle.png", [2] = ":killmessages/icons/golfclub.png", [3] = ":killmessages/icons/nitestick.png", [4] = ":killmessages/icons/knifecur.png", [5] = ":killmessages/icons/bat.png", [6] = ":killmessages/icons/shovel.png", [7] = ":killmessages/icons/poolcue.png", [8] = ":killmessages/icons/katana.png", [9] = ":killmessages/icons/chnsaw.png", [10] = ":killmessages/icons/gun_dildo1.png", [11] = ":killmessages/icons/gun_dildo2.png", [12] = ":killmessages/icons/gun_vibe1.png", [14] = ":killmessages/icons/flowera.png", [15] = ":killmessages/icons/gun_cane.png", [16] = ":killmessages/icons/grenade.png", [17] = ":killmessages/icons/teargas.png", [18] = ":killmessages/icons/molotov.png", [19] = ":killmessages/icons/explosion.png", [22] = ":killmessages/icons/colt45.png", [23] = ":killmessages/icons/Silenced.png", [24] = ":killmessages/icons/desert_eagle.png", [25] = ":killmessages/icons/chromegun.png", [26] = ":killmessages/icons/sawnoff.png", [27] = ":killmessages/icons/shotgspa.png", [28] = ":killmessages/icons/micro_uzi.png", [29] = ":killmessages/icons/mp5lng.png", [30] = ":killmessages/icons/ak47.png", [31] = ":killmessages/icons/m4.png", [32] = ":killmessages/icons/tec9.png", [33] = ":killmessages/icons/cuntgun.png", [34] = ":killmessages/icons/sniper.png", [35] = ":killmessages/icons/rocketla.png", [36] = ":killmessages/icons/heatseek.png", [37] = ":killmessages/icons/flame.png", [38] = ":killmessages/icons/minigun.png", [39] = ":killmessages/icons/satchel.png", [42] = ":killmessages/icons/fireextinguisher.png", }; classGroups = { }; classesInfo = { }; classesWeapons = { }; classesSkins = { }; addEventHandler( "onClientResourceStart", getResourceRootElement(), function ( ) fadeCamera( true ); setTimer( setCameraMatrix, 50, 1, 1967.71, 1342.9, 26.63, 2034.47, 1343.02, 20.01 ); --letterBox.flyIn( ); preloadClassesInfo( ); createClassSelectionWnd( ); createGroupSelectionWnd( ); createClassDescriptionWnd( ); createClassWeaponWnd( ); createPasswordWnd( ); --setTimer( createTempPed, 100, 1 ); showCursor( true ); showSpawnMenu( false, true ); --showHUDComponents( allHUDElements ); end ); function createTempPed( model ) -- 7474 - object id -- 8661 local x, y, z = getWorldFromScreenPosition( screenSize[ 1 ] - gridList:Size(false) / 2 - 70, ( screenSize[ 2 ]/2) --[[/ 1.6 ) * .8]], 10 ); local cX, cY, cZ = getCameraMatrix( ); x, y, z = getWorldFromScreenPosition( screenSize[ 1 ] - gridList:Size(false) / 2 - 70, ( screenSize[ 2 ]/2 )--[[ / 1.6 ) * .8]], 10 ) g_ground = createObject( 7474, x, y, z - 1.02, 0, 0, 90 ); tempPed = createPed( 0 and model or 0, x, y, z ); setPedRotation( tempPed, pedRot ); setElementFrozen( tempPed, true ); setPedAnimation( tempPed, "dancing", "dnce_m_b", -1, true, true, false ) --setPedAnimation( tempPed, "cop_ambient", "Coplook_nod", -1, true, true, false ) --setPedRotation( tempPed, 90 ); setElementAlpha( g_ground, 0 ); setTempPedRotating( true ); end function destroyTempPed( ) if tempPed then destroyElement( g_ground ); destroyElement( tempPed ); g_ground = nil; tempPed = nil; end end function setTempPedRotating( rotate ) if ( ( rotate ) and ( not pedRotating ) ) then addEventHandler( "onClientRender", g_root, rotatePed ); pedRotating = true; elseif ( not rotate ) then removeEventHandler( "onClientRender", g_root, rotatePed ); pedRotating = nil; end end function rotatePed( ) if tempPed then pedRot = pedRot + 1; setPedRotation( tempPed, pedRot ); end end function preloadClassesInfo( ) local groups = getElementsByType( "category" ); for _, group in ipairs( groups ) do table.insert( classGroups, Group:New( group ) ); end end function preloadClassesInfo( ) local groups = getElementsByType( "Town" ); for _, group in ipairs( category ) do table.insert( classGroups, Group:New( group ) ); end end function hideHUDComponents( components ) for i, comp in pairs( components ) do showPlayerHudComponent( comp, false ); end --showChat( false ); end function showHUDComponents( components ) for i, comp in pairs( components ) do showPlayerHudComponent( comp, true ); end --showChat( true ); end --addEventHandler( "onClientRender", getRootElement(), function animateLetterBox_flyIn ( ) if letterBox.animStartTick == 0 then letterBox.animStartTick = getTickCount(); letterBox.animFinishTick = letterBox.animStartTick + letterBox.animLength * 1000; letterBox.keepAnimating = true; end local stripH; local currentStripHeight = letterBox.stripHeight; if letterBox.keepAnimating then local currentTick = getTickCount();