thegost Posted May 9, 2016 Share Posted May 9, 2016 Hello people , In my Spawn Menu I add respawn System, But not work if you die you watch the Spawn Menu And I put to watch in first menu with 2 option option 1 spawn screen and option 2 respawn in hospital but this menu not work I cant see. And in debugscript 3 not have erros I dont understane... can help me? Client: --My Add function showSpawnScreen() if not spawnWindow then drawSpawnScreen() end setElementInterior(localPlayer,0) setElementDimension(localPlayer,0) setSpawnCamera() setTimer(function () fadeCamera(true) guiSetVisible(spawnWindow,true) guiSetVisible(infoMemo,true) guiSetVisible(locationGridList,false) guiGridListSetSelectedItem(classGridList,-1,0) showCursor(true) end,2000,1) end ------ function deathMode() if deathscreen then deathscreen = guiCreateWindow(0.3,0.8,0.4,0.2,SPAWN SCRREN",true) guiWindowSetSizable(deathscreen,false) death_hospital = guiCreateButton(0.0332,0.5463,0.4688,0.3659,"Hospital (1000$) \n You'll keep your weapons",true,deathscreen) death_spawn = guiCreateButton(0.5156,0.5463,0.4531,0.3659,"SPAWNSCREEN",true,deathscreen) deathbar = guiCreateProgressBar(0.0391,0.2732,0.9121,0.1902,true,deathscreen) deathlabel = guiCreateLabel(0.1094,0.1415,0.7754,0.1073,"... WAITING FOR REANIMATION ...",true,deathscreen) guiLabelSetVerticalAlign(deathlabel,"center") guiLabelSetHorizontalAlign(deathlabel,"center",false) addEventHandler("onClientGUIClick",death_hospital,spawnAtHospital) addEventHandler("onClientGUIClick",death_spawn,normalSpawnWindow) end guiProgressBarSetProgress(deathbar,100) guiSetVisible(deathscreen, true) showCursor(true) fadeCamera(true) deathTimer = setTimer(countUntilDeath, 1000, 1, 50) end addEvent("spawnhotpital.showDeathScreen",true) addEventHandler("spawnhotpital.showDeathScreen",localPlayer,deathMode) function countUntilDeath(time) if getElementData(getLocalPlayer(),"reanimation") then reanimatePlayer() setElementData(getLocalPlayer(),"reanimationtime",false) deathTimer = nil else if time > 0 then time = time -1 guiProgressBarSetProgress(deathbar,time * 2) deathTimer = setTimer(countUntilDeath, 1000, 1, time) else setElementData(getLocalPlayer(),"reanimationtime",false) deathTimer = nil normalSpawnWindow() end end end function normalSpawnWindow() if deathTimer then killTimer(deathTimer) deathTimer = nil end guiSetVisible(deathscreen, false) setElementData(getLocalPlayer(), "class", "N/A") showSpawnScreen() tempweapons = {} end function spawnAtHospital() if source == death_hospital then if ((getTeamName(getPlayerTeam(getLocalPlayer())) == "Criminals")or(getTeamName(getPlayerTeam(getLocalPlayer())) == "RvB Blue")) then triggerEvent("newMessage",root,nil,getLocalPlayer(),"*HELP* You can't use hospital while using RvB teams","call",255, 100, 50) return end if getPlayerMoney(getLocalPlayer()) >= 1000 then if deathTimer then killTimer(deathTimer) deathTimer = nil end guiSetVisible(deathscreen, false) showCursor(false) triggerServerEvent("SPAWNATHOSIPTAL", getLocalPlayer(), tempweapons) tempweapons = {} exports.RPGcommands:takeMoney(getLocalPlayer(),1000) else outputChatBox("You need 1000$ to spawn at a Hospital", 255, 100, 0) end end end function reanimatePlayer() local Dim = getElementDimension(getLocalPlayer()) local Int = getElementInterior(getLocalPlayer()) if deathTimer then killTimer(deathTimer) deathTimer = nil end guiSetVisible(deathscreen, false) showCursor(false) triggerServerEvent("REANIMATEPLAYER", getLocalPlayer(), tempweapons, Dim, Int) tempweapons = {} end function weaponsAfterDeath() if source == getLocalPlayer() then tempweapons = {} local weaponSlots = {0,1,2,3,4,5,6,7,8,9,10,11,12} for i, slot in ipairs(weaponSlots) do local ammo = getPedTotalAmmo ( getLocalPlayer(), slot ) if ( getPedWeapon ( getLocalPlayer(), slot ) ~= 0 ) then local weapon = getPedWeapon ( getLocalPlayer(), slot ) local ammo = getPedTotalAmmo ( getLocalPlayer(), slot ) table.insert(tempweapons, {weapon, ammo}) end end end end addEventHandler("onClientPlayerWasted", getRootElement(), weaponsAfterDeath) function waterCheck() if isElementInWater(localPlayer) then local px,py,pz = getElementPosition(localPlayer) local wx,wy,wz = getWaterLevel(x,y,z) setElementPostion(localPlayer,px,py,wz+3) end end addEventHandler("onClientPlayerSpawn",root,waterCheck) Server: function onPlayerWastedHandler(ammo,attacker,weapon,bodypart,stealth) if getElementData(source,"id") then fadeCamera(source,false) triggerClientEvent(source,"spawnhotpital.showDeathScreen",source) setElementData(source,"reanimation",false) setElementData(source,"reanimationtime",true) end local blips = getAttachedElements(source) if blips then for k,v in ipairs(blips) do if isElement(v) and getElementType(v) == "blip" then destroyElement(v) end end end end addEventHandler("onPlayerWasted",root,onPlayerWastedHandler) --- Hospital = { -- {x,y,z,rot} {2033,-1404,17.3,180}, {1173,-1323.6,15.4,270}, {-2656,636,14.5,180}, {-1514.6,2521.8,55.9,0}, {-320,1055,19.8,0}, {1607.4,1817.4,10.9,0}, {-2200.7,-2312.4,30.7,0} } function findNearestHospital(player) distanceToHospital = 9999999999 local wastedX, wastedY, wastedZ = getElementPosition(player) for k, v in ipairs(Hospital) do local loopX,loopY,loopZ,loopRot = v[1],v[2],v[3],v[4] newDistance = getDistanceBetweenPoints3D(wastedX,wastedY,wastedZ,loopX,loopY,loopZ) if newDistance < distanceToHospital then distanceToHospital = newDistance hospitalX = loopX hospitalY = loopY hospitalZ = loopZ hospitalRot = loopRot end end return hospitalX, hospitalY, hospitalZ, hospitalRot end function spawnPlayerAtHospital(savedWeapons) local skin = getPedSkin(source) local team = getPlayerTeam(source) local r, g, b = getPlayerNametagColor(source) local posX,posY,posZ,posRot = findNearestHospital(source) createBlipAttachedTo(source, 0, 2, r, g, b, 255, 0, 400) setPlayerNametagColor(source, r, g, b) spawnPlayer (source, posX, posY, posZ, posRot, skin, 0, 0, team) for i, t in ipairs(savedWeapons) do giveWeapon(source, t[1], t[2]) end fadeCamera(source,true) setCameraTarget(source,source) end addEvent("SPAWNATHOSIPTAL",true) addEventHandler("SPAWNATHOSIPTAL",root,spawnPlayerAtHospital) function reanimatePlayer(savedWeapons, dimP, intP) setElementData(source, "reanimation", false) setElementData(source, "time", false) local skin = getPedSkin(source) local team = getPlayerTeam(source) local r, g, b = getPlayerNametagColor(source) local posX, posY, posZ = getElementPosition(source) createBlipAttachedTo(source, 0, 2, r, g, b, 255, 0, 400) setPlayerNametagColor(source, r, g, b) spawnPlayer (source, posX, posY, posZ, 0, skin, 0, 0, team) setElementInterior(source, intP) setElementDimension(source, dimP) setElementHealth(source, 30) for i, t in ipairs(savedWeapons) do giveWeapon(source, t[1], t[2]) end fadeCamera(source,true) setCameraTarget(source,source) end addEvent("REANIMATEPLAYER",true) addEventHandler("REANIMATEPLAYER",root,reanimatePlayer) function resetCache(source,cmd,id) if not exports.SANGacl:isPlayerInGroup(source,"Admin") or not id then return end if spawnCache[id] then spawnCache[id] = nil exports.RPGcommands:sendMessage("*INFO* Cache deleted.",0,255,0,source) else exports.RPGcommands:sendMessage("*INFO* Cache does not exist.",255,0,0,source) end end addCommandHandler("resetcache",resetCache) function getID(source,cmd,account) if not exports.SANGacl:isPlayerInGroup(source,"Admin") or not account then return end local query = executeSQLQuery("SELECT id FROM user_data WHERE username = '"..account.."' LIMIT 1") if query and query[1] then exports.RPGcommands:sendMessage("*INFO* The ID for the account \'"..account.."\' is "..tostring(query[1].id)..".",0,255,0,source) else exports.RPGcommands:sendMessage("*INFO* Unable to find account.",0,255,0,source) end end addCommandHandler("getid",getID) Link to comment
Walid Posted May 9, 2016 Share Posted May 9, 2016 use /debugscript 3 and Try this function showSpawnScreen() if not spawnWindow then drawSpawnScreen() end setElementInterior(localPlayer,0) setElementDimension(localPlayer,0) setSpawnCamera() setTimer(function () fadeCamera(true) guiSetVisible(spawnWindow,true) guiSetVisible(infoMemo,true) guiSetVisible(locationGridList,false) guiGridListSetSelectedItem(classGridList,-1,0) showCursor(true) end,2000,1) end function deathMode() if deathscreen then deathscreen = guiCreateWindow(0.3,0.8,0.4,0.2,"SPAWN SCRREN",true) guiWindowSetSizable(deathscreen,false) death_hospital = guiCreateButton(0.0332,0.5463,0.4688,0.3659,"Hospital (1000$) \n You'll keep your weapons",true,deathscreen) death_spawn = guiCreateButton(0.5156,0.5463,0.4531,0.3659,"SPAWNSCREEN",true,deathscreen) deathbar = guiCreateProgressBar(0.0391,0.2732,0.9121,0.1902,true,deathscreen) deathlabel = guiCreateLabel(0.1094,0.1415,0.7754,0.1073,"... WAITING FOR REANIMATION ...",true,deathscreen) guiLabelSetVerticalAlign(deathlabel,"center") guiLabelSetHorizontalAlign(deathlabel,"center",false) addEventHandler("onClientGUIClick",death_hospital,spawnAtHospital) addEventHandler("onClientGUIClick",death_spawn,normalSpawnWindow) end guiProgressBarSetProgress(deathbar,100) guiSetVisible(deathscreen, true) showCursor(true) fadeCamera(true) deathTimer = setTimer(countUntilDeath, 1000, 1, 50) end addEvent("spawnhotpital.showDeathScreen",true) addEventHandler("spawnhotpital.showDeathScreen",localPlayer,deathMode) function countUntilDeath(time) if getElementData(getLocalPlayer(),"reanimation") then reanimatePlayer() setElementData(getLocalPlayer(),"reanimationtime",false) deathTimer = nil else if time > 0 then time = time -1 guiProgressBarSetProgress(deathbar,time * 2) deathTimer = setTimer(countUntilDeath, 1000, 1, time) else setElementData(getLocalPlayer(),"reanimationtime",false) deathTimer = nil normalSpawnWindow() end end end function normalSpawnWindow() if deathTimer then killTimer(deathTimer) deathTimer = nil end guiSetVisible(deathscreen, false) setElementData(getLocalPlayer(), "class", "N/A") showSpawnScreen() tempweapons = {} end function spawnAtHospital() if source == death_hospital then if ((getTeamName(getPlayerTeam(getLocalPlayer())) == "Criminals")or(getTeamName(getPlayerTeam(getLocalPlayer())) == "RvB Blue")) then triggerEvent("newMessage",root,nil,getLocalPlayer(),"*HELP* You can't use hospital while using RvB teams","call",255, 100, 50) return end if getPlayerMoney(getLocalPlayer()) >= 1000 then if deathTimer then killTimer(deathTimer) deathTimer = nil end guiSetVisible(deathscreen, false) showCursor(false) triggerServerEvent("SPAWNATHOSIPTAL", getLocalPlayer(), tempweapons) tempweapons = {} exports.RPGcommands:takeMoney(getLocalPlayer(),1000) else outputChatBox("You need 1000$ to spawn at a Hospital", 255, 100, 0) end end end function reanimatePlayer() local Dim = getElementDimension(getLocalPlayer()) local Int = getElementInterior(getLocalPlayer()) if deathTimer then killTimer(deathTimer) deathTimer = nil end guiSetVisible(deathscreen, false) showCursor(false) triggerServerEvent("REANIMATEPLAYER", getLocalPlayer(), tempweapons, Dim, Int) tempweapons = {} end function weaponsAfterDeath() if source == getLocalPlayer() then tempweapons = {} local weaponSlots = {0,1,2,3,4,5,6,7,8,9,10,11,12} for i, slot in ipairs(weaponSlots) do local ammo = getPedTotalAmmo ( getLocalPlayer(), slot ) if ( getPedWeapon ( getLocalPlayer(), slot ) ~= 0 ) then local weapon = getPedWeapon ( getLocalPlayer(), slot ) local ammo = getPedTotalAmmo ( getLocalPlayer(), slot ) table.insert(tempweapons, {weapon, ammo}) end end end end addEventHandler("onClientPlayerWasted", getRootElement(), weaponsAfterDeath) function waterCheck() if isElementInWater(localPlayer) then local px,py,pz = getElementPosition(localPlayer) local wx,wy,wz = getWaterLevel(x,y,z) setElementPostion(localPlayer,px,py,wz+3) end end addEventHandler("onClientPlayerSpawn",root,waterCheck) Link to comment
thegost Posted May 9, 2016 Author Share Posted May 9, 2016 Not Have erros... You need All script? the Spawn? Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now