xbenny2506x Posted August 30, 2009 Share Posted August 30, 2009 Hi! I have a respawn after death script and wanted add a text so that the player see after the death how long is the respawn time. But i get a error if (zufalldeath == 1) then local x = -2225.376953125 local y = 2333.6584472656 local z = 7.546875 setTimer ( spawnPlayer, 10000, 1, source, x, y, z) setTimer(setPlayerSkin, 10000, 1, source, zufallskin) if ( spawntext ) then destroyElement ( spawntext ) end local spawntext = guiCreateLabel(0.20,0.03,0.94,0.2,"Respawn in 10 Seconds",true,wnd) guiSetFont ( dummyGUIElement, "sa-header" ) setTimer ( destroyElement, 10000, 1, spawntext, source ) end addEventHandler("onPlayerWasted", getRootElement(), deathHandler) ERROR: ...r/mods/deathmatch/resourcecache/maps/playerdeath.lua:12: attempt to call global 'guiCreateLabel' (a nil value) Can someone help me? THX Link to comment
norby89 Posted August 30, 2009 Share Posted August 30, 2009 You should pay attention to functions, some are server-only others client-only. You will have to move the text stuff clientside and call it with triggerClientEvent when you spawn him. Check wiki for more info about how custom events work (addEvent). Link to comment
xbenny2506x Posted August 31, 2009 Author Share Posted August 31, 2009 nice big thx now work my script with triggerClientEvent and small other things (wiki search: addEvent) Link to comment
xbenny2506x Posted September 1, 2009 Author Share Posted September 1, 2009 I have now a other problem. When the player die all people see the text "Respawn in 10 Seconds" Here is my script: server: function deathHandler( playerSource ) local zufalldeath = math.random(1, 4) local zufallskin = math.random(7, 288) triggerClientEvent ( "onGreeting", getRootElement()) if (zufalldeath == 1) then local x = -2225.376953125 local y = 2333.6584472656 local z = 7.546875 setTimer ( spawnPlayer, 10000, 1, source, x, y, z) setTimer(setElementModel, 10000, 1, source, zufallskin) setTimer(giveWeapon, 10000, 1, source, 33, 50 ) setTimer(giveWeapon, 10000, 1, source, 31, 50 ) setTimer(giveWeapon, 10000, 1, source, 10 ) end .... end addEventHandler("onPlayerWasted", getRootElement(), deathHandler) client: function specialEventHandler ( spawntext ) if ( spawntext ) then destroyElement ( spawntext ) end local spawntext = guiCreateLabel(0.35,0.40,0.94,0.2,"Respawn in 10 Seconds",true) guiSetFont ( spawntext, "sa-header" ) guiLabelSetColor ( spawntext, 255, 234, 0 ) setTimer ( destroyElement, 10000, 1, spawntext, source ) end addEvent( "onGreeting", true ) addEventHandler( "onGreeting", getRootElement(), specialEventHandler ) I hope someone can say me how i can make it that only the player where die see the respawn text!? THX Link to comment
50p Posted September 1, 2009 Share Posted September 1, 2009 We can't see any "Respawn in 10 Seconds" text in your code, so we can't tell you what is wrong but I can tell you how to outputChatBox message that is visible only to 1 player. https://wiki.multitheftauto.com/index.ph ... putChatBox You need to use the "visibleTo" parameter. Use player element to display message to that player. Link to comment
subenji99 Posted September 1, 2009 Share Posted September 1, 2009 While 50p has their eyes examined, local spawntext = guiCreateLabel(0.35,0.40,0.94,0.2,"Respawn in 10 Seconds",true) I'll point out your mistake, and it's an easy one You can trigger client events to only trigger on specific clients - which is what you want in this case. In your Server file you have: function deathHandler( playerSource ) local zufalldeath = math.random(1, 4) local zufallskin = math.random(7, 288) triggerClientEvent ( "onGreeting", getRootElement()) ... and you can modify that triggerClientEvent call to only trigger for the one player you want - in your case, "playerSource". here's the triggerClientEvent syntax so you can see what we're dealing with: bool triggerClientEvent ( [element triggerFor=getRootElement()], string name, element theElement, [arguments...] ) https://wiki.multitheftauto.com/index.ph ... lientEvent so you modify your triggerClientEvent to: triggerClientEvent ( playerSource,"onGreeting", getRootElement()) --who to trigger for, what event to trigger, who triggered it Link to comment
50p Posted September 1, 2009 Share Posted September 1, 2009 When I read this topic it was 6:00am and I was asleep but whatever, I can see it easily Why don't you simply use client-side event onClientPlayerWasted or onClientPedWasted? Make sure the dead person is you (getLocalPlayer()). 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