Jump to content

problema con el DX Spawn Menu


iFoReX

Recommended Posts

porque me aparece la pantalla en negra D: ?

client

local classes = { 
    [1]={name="Asian Gangster", location="San Fierro", skin=123, r=255, g=255, b=0, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false}, 
    [2]={name="Gangster", location="Los Santos", skin=115, r=200, g=0, b=0, camx=2090.4487, camy=-1806.4600, camz=13.5469, x=2098.1418, y=-1806.5272, z=13.5542, rotz=91, locked=false}, 
    [3]={name="Gangster", location="Las Venturas", skin=115, r=200, g=0, b=0, camx=2504.7014, camy=1272.5519, camz=10.8125, x=2513.3313, y=1272.1747, z=10.8125, rotz=91, locked=false}, 
    [4]={name="Gangster", location="San Fierro", skin=115, r=200, g=0, b=0, camx=-2650.6509, camy=1351.9685, camz=7.1874, x=-2654.8606, y=1356.3500, z=7.1082, rotz=211, locked=false}, 
    [5]={name="Citizen", location="Los Santos", skin=0, r=255, g=200, b=0, camx=2080.0674, camy=-1768.3506, camz=13.5525, x=2074.3320, y=-1768.9489, z=13.5545, rotz=264, locked=false}, 
    [6]={name="Citizen", location="Las Venturas", skin=0, r=255, g=200, b=0, camx=1549.4467, camy=2672.7546, camz=10.8203, x=1549.5360, y=2666.0066, z=10.8274, rotz=360, locked=false}, 
    [7]={name="Citizen", location="San Fierro", skin=0, r=255, g=200, b=0, camx=-2631.7356, camy=922.4197, camz=71.9426, x=-2636.7900, y=932.1591, z=71.8688, rotz=210, locked=false}, 
    [8]={name="Staff", location="Las Venturas", skin=217, r=255, g=255, b=0, camx=2477.5403, camy=2773.1514, camz=10.7346, x=2492.9961, y=2773.0344, z=10.8063, rotz=89, locked=true, team="Staff"} 
} 
  
local weapons = { 
    ["Asian Gangster"]={5, 24, 26, 28, 30}, 
    ["Gangster"]={5, 24, 26, 28, 30}, 
    ["Citizen"]={7, 22, 32, 30, 18}, 
    ["Staff"]={24, 31, 34, 35, 16} 
} 
  
local curr = 1 
  
addEvent("client:showSpawnMenu", true) 
  
addEventHandler("onClientResourceStart",resourceRoot, 
function() 
addEventHandler("client:showSpawnMenu", root,spawn) 
end 
) 
  
function spawn(class) 
    addEventHandler("onClientRender", root, drawSpawnInfo) 
    bindKey("arrow_l", "down", switchPrevious) 
    bindKey("arrow_r", "down", switchNext) 
    bindKey("space", "down", switchSpawn) 
    bindKey("enter", "down", spawn) 
    updateClassPos(curr) 
end 
  
function switchSpawn() 
end 
  
function switchNext(_, state) 
    if state == "down" then 
        curr = curr + 1 
        if curr > #classes then curr = 1 end 
        outputChatBox(classes[curr].name) 
        updateClassPos(curr) 
    end 
end 
  
function switchPrevious(_, state) 
    if state == "down" then 
        curr = curr - 1 
        if curr < 1 then curr = #classes end 
        outputChatBox(classes[curr].name) 
        updateClassPos(curr) 
    end 
end 
    
function spawn() 
    if classes[curr].locked then 
        if isPlayerInTeam(localPlayer, classes[curr].team) then 
            normalSpawn() 
            else 
            outputChatBox("Only members of '"..classes[curr].team.."' are allowed to use this spawn!", 255, 0, 0) 
        end 
        else 
        normalSpawn() 
    end 
end 
  
function normalSpawn() 
    removeEventHandler("onClientRender", root, drawSpawnInfo) 
    unbindKey("arrow_l", "down", switchPrevious) 
    unbindKey("arrow_r", "down", switchNext) 
    unbindKey("enter", "down", spawn) 
    outputChatBox("Spawned") 
    if isElement(actor) then destroyElement(actor) end 
    triggerServerEvent("server:spawnOptions", localPlayer, classes[curr].skin, weapons[classes[curr].name][1], weapons[classes[curr].name][2], weapons[classes[curr].name][3], weapons[classes[curr].name][4], weapons[classes[curr].name][5], classes[curr].x, classes[curr].y, classes[curr].z, classes[curr].rotz) 
end 
  
function updateClassPos(num) 
    if not isElement(actor) then actor = createPed(classes[num].skin, classes[num].x, classes[num].y, classes[num].z) end 
    local cx, cy, cz = classes[num].camx, classes[num].camy, classes[num].camz 
    setPedRotation(actor, classes[num].rotz) 
    setElementPosition(actor, classes[num].x, classes[num].y, classes[num].z) 
    setElementModel(actor, classes[num].skin) 
    setCameraMatrix(cx, cy, cz, classes[num].x, classes[num].y, classes[num].z) 
end 
  
function isPlayerInTeam(src, TeamName) 
    if src and isElement ( src ) and getElementType ( src ) == "player" then 
           local team = getPlayerTeam(src) 
        if team then 
            if getTeamName(team) == TeamName then 
                return true 
                else 
                return false 
            end 
        end 
    end 
end 
  
function drawSpawnInfo() 
    local x, y, z = classes[curr].x, classes[curr].y, classes[curr].z 
    local sx, sy = getScreenFromWorldPosition(x, y, z) 
    if sx then 
        dxDrawFramedText(classes[curr].name, sx+65, sy-50, 10, 10, tocolor(classes[curr].r, classes[curr].g, classes[curr].b, 255), tocolor(0, 0, 0, 255), 2, "default-bold") 
        dxDrawFramedText(getZoneName(x, y, z, true).." (SPACE to change)", sx+65, sy, 10, 10, tocolor(255, 255, 255, 255), tocolor(0, 0, 0, 255), 1.5, "default-bold") 
        dxDrawFramedText("Weapons:", sx+65, sy+25, 10, 10, tocolor(255, 255, 255, 255), tocolor(0, 0, 0, 255), 1.5, "default-bold") 
        dxDrawFramedText("- "..getWeaponNameFromID(weapons[classes[curr].name][1]), sx+65, sy+50, 10, 10, tocolor(255, 255, 255, 255), tocolor(0, 0, 0, 255), 1.5, "default-bold") 
        dxDrawFramedText("- "..getWeaponNameFromID(weapons[classes[curr].name][2]), sx+65, sy+75, 10, 10, tocolor(255, 255, 255, 255), tocolor(0, 0, 0, 255), 1.5, "default-bold") 
        dxDrawFramedText("- "..getWeaponNameFromID(weapons[classes[curr].name][3]), sx+65, sy+100, 10, 10, tocolor(255, 255, 255, 255), tocolor(0, 0, 0, 255), 1.5, "default-bold") 
        dxDrawFramedText("- "..getWeaponNameFromID(weapons[classes[curr].name][4]), sx+65, sy+125, 10, 10, tocolor(255, 255, 255, 255), tocolor(0, 0, 0, 255), 1.5, "default-bold") 
        dxDrawFramedText("- "..getWeaponNameFromID(weapons[classes[curr].name][5]), sx+65, sy+150, 10, 10, tocolor(255, 255, 255, 255), tocolor(0, 0, 0, 255), 1.5, "default-bold") 
    end 
end 
  
function dxDrawFramedText ( message , left , top , width , height , color , frameColor , scale , font , alignX , alignY , clip , wordBreak , postGUI ) 
    color = color or tocolor ( 255 , 255 , 255 , 255 ) 
    frameColor = frameColor or tocolor ( 0 , 0 , 0 , 255 ) 
    scale = scale or 1 
    font = font or "default" 
    alignX = alignX or "left" 
    alignY = alignY or "top" 
    clip = clip or false 
    wordBreak = wordBreak or false 
    postGUI = postGUI or false 
    local sMessage = message : gsub ( "#%x%x%x%x%x%x" , "" ) 
    dxDrawText ( sMessage , left + 1 , top + 1 , width + 1 , height + 1 , frameColor , scale , font , alignX , alignY , clip , wordBreak , false ) 
    dxDrawText ( sMessage , left + 1 , top - 1 , width + 1 , height - 1 , frameColor , scale , font , alignX , alignY , clip , wordBreak , false ) 
    dxDrawText ( sMessage , left - 1 , top + 1 , width - 1 , height + 1 , frameColor , scale , font , alignX , alignY , clip , wordBreak , false ) 
    dxDrawText ( sMessage , left - 1 , top - 1 , width - 1 , height - 1 , frameColor , scale , font , alignX , alignY , clip , wordBreak , false ) 
    dxDrawText ( message , left , top , width , height , color , scale , font , alignX , alignY , clip , wordBreak , false ) 
end 

server

local ammo = { 
    [9]={1}, 
    [22]={170}, 
    [25]={35}, 
    [31]={300}, 
    [39]={20}, 
    [1]={1}, 
    [5]={1}, 
    [24]={77}, 
    [26]={40}, 
    [28]={200}, 
    [30]={300}, 
    [41]={1500}, 
    [8]={1}, 
    [23]={170}, 
    [29]={240}, 
    [34]={350}, 
    [45]={1}, 
    [2]={1}, 
    [32]={350}, 
    [37]={550}, 
    [18]={15}, 
    [3]={1}, 
    [17]={15}, 
    [42]={1500}, 
    [16]={30}, 
    [7]={1}, 
    [35]={2} 
} 
  
addEvent("server:spawnOptions", true) 
addEventHandler("server:spawnOptions", root, 
function(skin, w1, w2, w3, w4, w5, x, y, z, rotz) 
    spawnPlayer(source, x, y, z, rotz, skin) 
    setElementInterior(source, 0) 
    setElementDimension(source, 0) 
    setCameraTarget(source, source) 
    giveWeapon(source, w1, ammo[w1][1]) 
    giveWeapon(source, w2, ammo[w2][1]) 
    giveWeapon(source, w3, ammo[w3][1], true) 
    giveWeapon(source, w4, ammo[w4][1]) 
    giveWeapon(source, w5, ammo[w5][1]) 
end) 

Link to comment
local classes = { 
    [1]={name="Asian Gangster", location="San Fierro", skin=123, r=255, g=255, b=0, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false}, 
    [2]={name="Gangster", location="Los Santos", skin=115, r=200, g=0, b=0, camx=2090.4487, camy=-1806.4600, camz=13.5469, x=2098.1418, y=-1806.5272, z=13.5542, rotz=91, locked=false}, 
    [3]={name="Gangster", location="Las Venturas", skin=115, r=200, g=0, b=0, camx=2504.7014, camy=1272.5519, camz=10.8125, x=2513.3313, y=1272.1747, z=10.8125, rotz=91, locked=false}, 
    [4]={name="Gangster", location="San Fierro", skin=115, r=200, g=0, b=0, camx=-2650.6509, camy=1351.9685, camz=7.1874, x=-2654.8606, y=1356.3500, z=7.1082, rotz=211, locked=false}, 
    [5]={name="Citizen", location="Los Santos", skin=0, r=255, g=200, b=0, camx=2080.0674, camy=-1768.3506, camz=13.5525, x=2074.3320, y=-1768.9489, z=13.5545, rotz=264, locked=false}, 
    [6]={name="Citizen", location="Las Venturas", skin=0, r=255, g=200, b=0, camx=1549.4467, camy=2672.7546, camz=10.8203, x=1549.5360, y=2666.0066, z=10.8274, rotz=360, locked=false}, 
    [7]={name="Citizen", location="San Fierro", skin=0, r=255, g=200, b=0, camx=-2631.7356, camy=922.4197, camz=71.9426, x=-2636.7900, y=932.1591, z=71.8688, rotz=210, locked=false}, 
    [8]={name="Staff", location="Las Venturas", skin=217, r=255, g=255, b=0, camx=2477.5403, camy=2773.1514, camz=10.7346, x=2492.9961, y=2773.0344, z=10.8063, rotz=89, locked=true, team="Staff"} 
} 
  
local weapons = { 
    ["Asian Gangster"]={5, 24, 26, 28, 30}, 
    ["Gangster"]={5, 24, 26, 28, 30}, 
    ["Citizen"]={7, 22, 32, 30, 18}, 
    ["Staff"]={24, 31, 34, 35, 16} 
} 
  
local curr = 1 
  
addEventHandler ( "onClientResourceStart", resourceRoot, 
    function ( ) 
        triggerEvent ( "client:showSpawnMenu", localPlayer ) 
    end 
) 
  
addEvent("client:showSpawnMenu", true) 
addEventHandler("client:showSpawnMenu", root, 
function(class) 
    addEventHandler("onClientRender", root, drawSpawnInfo) 
    bindKey("arrow_l", "down", switchPrevious) 
    bindKey("arrow_r", "down", switchNext) 
    bindKey("space", "down", switchSpawn) 
    bindKey("enter", "down", spawn) 
    updateClassPos(curr) 
end) 
  
function switchSpawn() 
end 
  
function switchNext(_, state) 
    if state == "down" then 
        curr = curr + 1 
        if curr > #classes then curr = 1 end 
        outputChatBox(classes[curr].name) 
        updateClassPos(curr) 
    end 
end 
  
function switchPrevious(_, state) 
    if state == "down" then 
        curr = curr - 1 
        if curr < 1 then curr = #classes end 
        outputChatBox(classes[curr].name) 
        updateClassPos(curr) 
    end 
end 
    
function spawn() 
    if classes[curr].locked then 
        if isPlayerInTeam(localPlayer, classes[curr].team) then 
            normalSpawn() 
            else 
            outputChatBox("Only members of '"..classes[curr].team.."' are allowed to use this spawn!", 255, 0, 0) 
        end 
        else 
        normalSpawn() 
    end 
end 
  
function normalSpawn() 
    removeEventHandler("onClientRender", root, drawSpawnInfo) 
    unbindKey("arrow_l", "down", switchPrevious) 
    unbindKey("arrow_r", "down", switchNext) 
    unbindKey("enter", "down", spawn) 
    outputChatBox("Spawned") 
    if isElement(actor) then destroyElement(actor) end 
    triggerServerEvent("server:spawnOptions", localPlayer, classes[curr].skin, weapons[classes[curr].name][1], weapons[classes[curr].name][2], weapons[classes[curr].name][3], weapons[classes[curr].name][4], weapons[classes[curr].name][5], classes[curr].x, classes[curr].y, classes[curr].z, classes[curr].rotz) 
end 
  
function updateClassPos(num) 
    if not isElement(actor) then actor = createPed(classes[num].skin, classes[num].x, classes[num].y, classes[num].z) end 
    local cx, cy, cz = classes[num].camx, classes[num].camy, classes[num].camz 
    setPedRotation(actor, classes[num].rotz) 
    setElementPosition(actor, classes[num].x, classes[num].y, classes[num].z) 
    setElementModel(actor, classes[num].skin) 
    setCameraMatrix(cx, cy, cz, classes[num].x, classes[num].y, classes[num].z) 
end 
  
function isPlayerInTeam(src, TeamName) 
    if src and isElement ( src ) and getElementType ( src ) == "player" then 
           local team = getPlayerTeam(src) 
        if team then 
            if getTeamName(team) == TeamName then 
                return true 
                else 
                return false 
            end 
        end 
    end 
end 
  
function drawSpawnInfo() 
    local x, y, z = classes[curr].x, classes[curr].y, classes[curr].z 
    local sx, sy = getScreenFromWorldPosition(x, y, z) 
    if sx then 
        dxDrawFramedText(classes[curr].name, sx+65, sy-50, 10, 10, tocolor(classes[curr].r, classes[curr].g, classes[curr].b, 255), tocolor(0, 0, 0, 255), 2, "default-bold") 
        dxDrawFramedText(getZoneName(x, y, z, true).." (SPACE to change)", sx+65, sy, 10, 10, tocolor(255, 255, 255, 255), tocolor(0, 0, 0, 255), 1.5, "default-bold") 
        dxDrawFramedText("Weapons:", sx+65, sy+25, 10, 10, tocolor(255, 255, 255, 255), tocolor(0, 0, 0, 255), 1.5, "default-bold") 
        dxDrawFramedText("- "..getWeaponNameFromID(weapons[classes[curr].name][1]), sx+65, sy+50, 10, 10, tocolor(255, 255, 255, 255), tocolor(0, 0, 0, 255), 1.5, "default-bold") 
        dxDrawFramedText("- "..getWeaponNameFromID(weapons[classes[curr].name][2]), sx+65, sy+75, 10, 10, tocolor(255, 255, 255, 255), tocolor(0, 0, 0, 255), 1.5, "default-bold") 
        dxDrawFramedText("- "..getWeaponNameFromID(weapons[classes[curr].name][3]), sx+65, sy+100, 10, 10, tocolor(255, 255, 255, 255), tocolor(0, 0, 0, 255), 1.5, "default-bold") 
        dxDrawFramedText("- "..getWeaponNameFromID(weapons[classes[curr].name][4]), sx+65, sy+125, 10, 10, tocolor(255, 255, 255, 255), tocolor(0, 0, 0, 255), 1.5, "default-bold") 
        dxDrawFramedText("- "..getWeaponNameFromID(weapons[classes[curr].name][5]), sx+65, sy+150, 10, 10, tocolor(255, 255, 255, 255), tocolor(0, 0, 0, 255), 1.5, "default-bold") 
    end 
end 
  
function dxDrawFramedText ( message , left , top , width , height , color , frameColor , scale , font , alignX , alignY , clip , wordBreak , postGUI ) 
    color = color or tocolor ( 255 , 255 , 255 , 255 ) 
    frameColor = frameColor or tocolor ( 0 , 0 , 0 , 255 ) 
    scale = scale or 1 
    font = font or "default" 
    alignX = alignX or "left" 
    alignY = alignY or "top" 
    clip = clip or false 
    wordBreak = wordBreak or false 
    postGUI = postGUI or false 
    local sMessage = message : gsub ( "#%x%x%x%x%x%x" , "" ) 
    dxDrawText ( sMessage , left + 1 , top + 1 , width + 1 , height + 1 , frameColor , scale , font , alignX , alignY , clip , wordBreak , false ) 
    dxDrawText ( sMessage , left + 1 , top - 1 , width + 1 , height - 1 , frameColor , scale , font , alignX , alignY , clip , wordBreak , false ) 
    dxDrawText ( sMessage , left - 1 , top + 1 , width - 1 , height + 1 , frameColor , scale , font , alignX , alignY , clip , wordBreak , false ) 
    dxDrawText ( sMessage , left - 1 , top - 1 , width - 1 , height - 1 , frameColor , scale , font , alignX , alignY , clip , wordBreak , false ) 
    dxDrawText ( message , left , top , width , height , color , scale , font , alignX , alignY , clip , wordBreak , false ) 
end 

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...