Jump to content

Couple of questions about a GUI spawn script


oversteerer

Recommended Posts

Hi, I am not a scripter but my friend made a GUI spawn selection script for our server and there are a couple of issues we cannot figure out. Im hoping you folk can point us in the right direction :)

1. There is a bug when someone attempts to join a VIP clan who is not logged in or not in that group.. Everyone in the server has the spawn window pop up on their screen forcing them to respawn (we do not have a close window button yet).

2. We want to set a short delay after a player dies before the spawn window appears. Currently the spawn window pops up instantly upon death, we would like 5 seconds before the player can respawn to reflect upon their death, vent rage etc

Ive never posted up code on the forum so hopefully I do it right with the part with the bug. I dont want to post the whole script as I didnt write it and i read a lot about people stealing scripts :(

This is from the end of the client.lua (where the VIP clans are: Development Manager and Monster Clan), i can post up other bits if required, just ask.

Thanks in advance for any suggestions.

addEventHandler("onClientGUIClick", leone, joinLeone, false) 
  
function joinForelli() 
    triggerServerEvent("setTeamForelli", localPlayer) 
    guiSetVisible(spawnew, false) 
    showCursor(false) 
end 
addEventHandler("onClientGUIClick", forelli, joinForelli, false) 
  
----------------Developer Manager Clan------------------- 
  
addEvent("onTeamTrueDm", true) 
addEventHandler("onTeamTrueDm", getRootElement(), spawn) 
function joinDm() 
    triggerServerEvent("setTeamDm", localPlayer) 
    guiSetVisible(spawnew, false) 
    showCursor(false) 
end 
addEventHandler("onClientGUIClick", dm, joinDm, false) 
function flupp (thePlayer) 
    guiSetVisible(spawnew,true) 
    showCursor(true) 
end 
addEvent("onTeamDm", true) 
addEventHandler("onTeamDm", getRootElement(), flupp) 
  
------------Monster Clan--------------- 
  
addEvent("onTeamTrueMonster", true) 
addEventHandler("onTeamTrueMonster", getRootElement(), spawn) 
function joinMonster() 
    triggerServerEvent("setTeamMonster", localPlayer) 
    guiSetVisible(spawnew, false) 
    showCursor(false) 
end 
addEventHandler("onClientGUIClick", monster, joinMonster, false) 
function flupp () 
    guiSetVisible(spawnew,true) 
    showCursor(true) 
end 
addEvent("onTeamMonster", true) 
addEventHandler("onTeamMonster", getRootElement(), flupp) 
  
  
    if not guiGetVisible(spawnew) then 
    guiSetVisible(spawnew, true) else 
    showCursor(true) 
end 
end 
addEventHandler("onClientResourceStart",resourceRoot,spawn) 
addEventHandler("onClientPlayerJoin",getLocalPlayer(),spawn) 
addEventHandler("onClientPlayerWasted",getLocalPlayer(),spawn) 

Link to comment

Hi manve1, here is the end part of the the server spawn.lua. This includes the part with the VIP clans, only if the player cannot join do the other players see the spawn window.

function joinForelli() 
    setPlayerTeam(source,teamForelli) 
    spawnPlayer ( source, -2211.9836425781, 1056.4545898438, 80.0078125, 180.99975585938 ) 
    setElementModel(source,100) 
    setElementHealth(source,100) 
    giveWeapon( source, 23, 99 ) 
    giveWeapon( source, 31, 333 ) 
    setCameraTarget(source,player) 
end 
addEvent("setTeamForelli", true) 
addEventHandler("setTeamForelli",getRootElement(),joinForelli) 
  
---------------------Developer Manager Clan---------------------- 
  
function joinDm() 
    if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("DM")) then 
    setPlayerTeam(source,teamDm)  
    spawnPlayer ( source, -2530.6340332031, -13.738405227661, 16.421875, 87.817443847656 ) 
    setElementModel(source,153) 
    setElementHealth(source,100) 
    setPedArmor ( source, 100 ) 
    setPlayerMoney ( source, 24500 ) 
    giveWeapon( source, 24, 99 ) 
    giveWeapon( source, 27, 99 ) 
    giveWeapon( source, 32, 333 ) 
    giveWeapon( source, 31, 333 ) 
    giveWeapon( source, 34, 99 ) 
    setCameraTarget(source,player) 
else 
    outputChatBox ( "You are not part of this group!", source, 255,0,0 ) 
    triggerClientEvent("onTeamDm", getRootElement(),source)  
end 
end 
addEvent("setTeamDm", true) 
addEventHandler("setTeamDm",getRootElement(),joinDm) 
  
------------------Monster Clan--------------------- 
  
function joinMonster() 
    if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("ME")) then 
    setPlayerTeam(source,teamMonster)  
    spawnPlayer ( source, -1984.7640380859, 648.16845703125, 46.568286895752, 267.86129760742 ) 
    setElementModel(source,123) 
    setElementHealth(source,100) 
    giveWeapon( source, 24, 99 ) 
    giveWeapon( source, 27, 99 ) 
    giveWeapon( source, 31, 333 ) 
    setCameraTarget(source,player) 
else 
    outputChatBox ( "You are not part of this group!", source, 255,0,0 ) 
    triggerClientEvent("onTeamMonster", getRootElement(),source)  
end 
end 
addEvent("setTeamMonster", true) 
addEventHandler("setTeamMonster",getRootElement(),joinMonster) 

The createteamfunction is at the beginning of the server spawn.lua :

function createTeamsOnStart () 
etc... 
etc... 
teamForelli = createTeam ( "Forelli", 126, 107, 78 ) 
teamDm = createTeam ( "DM", 185, 0, 0 ) 
teamMonster = createTeam ( "M.E", 0, 157, 0 ) 
end 
addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), createTeamsOnStart ) 

I have included the team forelli which is a normal gang spawn, no log in required, no problem with that, not bugged.

I hope this helps, thanks for your reply

Link to comment

Solidsnake you are THE MAN!!!! That fixed the bug perfectly. Many thanks to you :D

We are still unsure where we should place the setTimer. Even after reading the wiki page. We have a slow motion animation and a 'wasted' message that runs when the player is killed so we want those visible, not blocked out by an instant spawn window.

I think it goes in the client.lua after the spawn window function? Sounds correct?

Link to comment

Replace this

addEventHandler("onClientResourceStart",resourceRoot,spawn) 
addEventHandler("onClientPlayerJoin",getLocalPlayer(),spawn) 
addEventHandler("onClientPlayerWasted",getLocalPlayer(),spawn) 

Into this

addEventHandler("onClientResourceStart",resourceRoot,function() setTimer(spawn, 5000, 1) end) 
addEventHandler("onClientPlayerJoin",getLocalPlayer(),function() setTimer(spawn, 5000, 1) end) 
addEventHandler("onClientPlayerWasted",getLocalPlayer(),function() setTimer(spawn, 5000, 1) end) 

Link to comment
addEventHandler("onClientPlayerJoin",getLocalPlayer(),function() setTimer(spawn, 5000, 1) end) 

That part is useless, since "onClientPlayerJoin" is triggered for remote players only, not the person who joined, and "onClientResourceStart" is already doing what this event would do.

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