papam77 Posted July 2, 2013 Share Posted July 2, 2013 Hello, i never made with the xml, but i need know how to make savePlayerMoney onPlayerDisconnect. And load from the xml onPlayerLogin How can do it? Link to comment
Castillo Posted July 2, 2013 Share Posted July 2, 2013 Using XML wouldn't be efficient, I would recommend to use account data instead, a lot easier too. Link to comment
papam77 Posted July 2, 2013 Author Share Posted July 2, 2013 Ah Work it, thank you function onPlayerQuit ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then local playermoney = getPlayerMoney ( source ) setAccountData ( playeraccount, "Penize", playermoney ) end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) function onPlayerLogin (_, playeraccount ) if ( playeraccount ) then local playermoney = getAccountData ( playeraccount, "Penize" ) if ( playermoney ) then setPlayerMoney ( source, playermoney ) end end end addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin) And why doesn't work it for the skin? function onPlayerQuit ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then local playermoney = getPlayerMoney ( source ) local skin = getPlayerSkin ( source ) setAccountData ( playeraccount, "acc", playermoney ) setAccountData ( playeraccount, "skin", skin ) end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) function onPlayerLogin (_, playeraccount ) if ( playeraccount ) then local playermoney = getAccountData ( playeraccount, "acc" ) local skin = getAccountData ( playeraccount, "skin" ) if ( playermoney ) then setPlayerMoney ( source, playermoney ) setPlayerSkin ( source, skin ) end end end addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin) Link to comment
Castillo Posted July 2, 2013 Share Posted July 2, 2013 function onPlayerQuit ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then local playermoney = getPlayerMoney ( source ) local skin = getElementModel ( source ) setAccountData ( playeraccount, "acc", playermoney ) setAccountData ( playeraccount, "skin", skin ) end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) function onPlayerLogin ( _, playeraccount ) if ( playeraccount ) then local playermoney = getAccountData ( playeraccount, "acc" ) local skin = getAccountData ( playeraccount, "skin" ) if ( playermoney ) then setPlayerMoney ( source, playermoney ) end if ( skin ) then setElementModel ( source, skin ) end end end addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin ) Link to comment
papam77 Posted July 2, 2013 Author Share Posted July 2, 2013 It doesn't load my skin. Link to comment
Castillo Posted July 2, 2013 Share Posted July 2, 2013 function onPlayerQuit ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then local playermoney = getPlayerMoney ( source ) local skin = getElementModel ( source ) setAccountData ( playeraccount, "acc", playermoney ) setAccountData ( playeraccount, "skin", skin ) end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) function onPlayerLogin ( _, playeraccount ) if ( playeraccount ) then local playermoney = getAccountData ( playeraccount, "acc" ) local skin = getAccountData ( playeraccount, "skin" ) if ( playermoney ) then setPlayerMoney ( source, playermoney ) end if ( skin ) then setElementModel ( source, skin ) else outputChatBox ( "NO SKIN SAVED!", source ) end end end addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin ) Try that and see what it outputs when you login. Link to comment
Castillo Posted July 2, 2013 Share Posted July 2, 2013 You're logging out or quitting the server? Link to comment
papam77 Posted July 2, 2013 Author Share Posted July 2, 2013 Ah now works, my bad. And if i have this: -------------------------- -- Welcome To Los Santos -------------------------- addEventHandler ( "onPlayerLogin", root, function ( ) local player = getRootElement() fadeCamera ( source, true, 1.0, 255, 0, 0 ) setPlayerSkin ( player, 29 ) outputChatBox ("#FE02F7Vítej na serveru #ffffff"..getPlayerName( source ).."#FE02F7.",getRootElement(), 255, 255, 255, true ) outputChatBox ("#FE02F7Získáváš #2CFE02500XP #FE02F7jako bonus za přihlášení.",getRootElement(), 255, 255, 255, true ) setElementRotation ( player, 0, 0, 180) setCameraTarget ( source ) spawnPlayer ( source, 1642.5999755859, -2241.1999511719, 13.10000038147 ) end ) function onPlayerQuit ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then local playermoney = getPlayerMoney ( source ) local skin = getElementModel ( source ) local pos = getElementPosition ( source ) setAccountData ( playeraccount, "acc", playermoney ) setAccountData ( playeraccount, "skin", skin ) setAccountData ( playeraccount, "pos", pos ) end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) function onPlayerLogin ( _, playeraccount ) if ( playeraccount ) then local playermoney = getAccountData ( playeraccount, "acc" ) local skin = getAccountData ( playeraccount, "skin" ) local pos = getAccountData ( playeraccount, "pos" ) -- Money if ( playermoney ) then setPlayerMoney ( source, playermoney ) end -- Skin if ( skin ) then setElementModel ( source, skin ) else outputChatBox ( "NO SKIN SAVED!", source ) end -- Positions if ( pos ) then setElementPosition ( source, posX, posY, posZ ) else outputChatBox ( "NO POSITION SAVED!", source ) end end end addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin ) How can do this spawnPlayer ( source, 1642.5999755859, -2241.1999511719, 13.10000038147 ) Only if is player new on the server. First standing. Link to comment
Castillo Posted July 2, 2013 Share Posted July 2, 2013 You can use account data to check if is his/her first login. Link to comment
papam77 Posted July 2, 2013 Author Share Posted July 2, 2013 Ty. And if player isn't logged freeze him/her? How? Link to comment
papam77 Posted July 2, 2013 Author Share Posted July 2, 2013 addEventHandler ( "onPlayerJoin", root, function ( ) setCameraTarget ( source ) fadeCamera ( source, true, 1.0, 255, 0 ,0 ) setElementFrozen ( source, true ) spawnPlayer ( source, 1642.5999755859, -2241.1999511719, 13.10000038147 ) end ) And i'm not frozen. Link to comment
iPrestege Posted July 2, 2013 Share Posted July 2, 2013 addEventHandler ( "onPlayerJoin", root, function ( ) setCameraTarget ( source ) fadeCamera ( source, true, 1.0, 255, 0 ,0 ) spawnPlayer ( source, 1642.5999755859, -2241.1999511719, 13.10000038147 ) setElementFrozen ( source, true ) end ) Link to comment
papam77 Posted July 2, 2013 Author Share Posted July 2, 2013 And this addEventHandler( "onPlayerWasted", getRootElement( ), function ( source ) setTimer ( spawnPlayer, 3000, 1, source, 2034, -1414, 16 ) end ) It doesn't spawn me to the place selected by me Link to comment
#Al-Ha[J]aRii Posted July 2, 2013 Share Posted July 2, 2013 And this addEventHandler( "onPlayerWasted", getRootElement( ), function ( source ) setTimer ( spawnPlayer, 3000, 1, source, 2034, -1414, 16 ) end ) addEventHandler( "onPlayerWasted", getRootElement( ), function ( player ) setTimer ( spawnPlayer, 3000, 1, player, 2034, -1414, 16 ) end ) Link to comment
#Al-Ha[J]aRii Posted July 2, 2013 Share Posted July 2, 2013 Doesn't work. any debugscript 3 ? Link to comment
papam77 Posted July 2, 2013 Author Share Posted July 2, 2013 Full code: server_side: -------------------------- -- Welcome To Los Santos -------------------------- addEventHandler ( "onPlayerJoin", root, function ( ) setCameraTarget ( source ) fadeCamera ( source, true, 1.0, 255, 0 ,0 ) spawnPlayer ( source, 1642.5999755859, -2241.1999511719, 13.10000038147 ) setElementFrozen ( source, true ) end ) addEventHandler ( "onPlayerLogout", root, function ( ) local player = getRootElement() setElementFrozen ( source, true ) end) function onPlayerQuit ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then local playermoney = getPlayerMoney ( source ) local skin = getElementModel ( source ) local pos = getElementPosition ( source ) setAccountData ( playeraccount, "acc", playermoney ) setAccountData ( playeraccount, "skin", skin ) setAccountData ( playeraccount, "pos", pos ) end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) addEventHandler ( "onPlayerLogout", getRootElement ( ), onPlayerQuit ) function onPlayerLogin ( _, playeraccount ) local player = getRootElement() setFPSLimit ( 100 ) fadeCamera ( source, true, 1.0, 255, 0, 0 ) setElementFrozen ( source, false ) setPlayerSkin ( player, 29 ) outputChatBox ("#FE02F7Získáváš #2CFE02500XP #FE02F7jako bonus za přihlášení.",getRootElement(), 255, 255, 255, true ) setElementRotation ( player, 0, 0, 180) if ( playeraccount ) then local playermoney = getAccountData ( playeraccount, "acc" ) local skin = getAccountData ( playeraccount, "skin" ) local pos = getAccountData ( playeraccount, "pos" ) -- Money if ( playermoney ) then setPlayerMoney ( source, playermoney ) end -- Skin if ( skin ) then setElementModel ( source, skin ) else outputChatBox ( "NO SKIN SAVED!", source ) end -- Positions if ( pos ) then setElementPosition ( source ) else outputChatBox ( "NO POSITION SAVED!", source ) end end end addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin ) addEventHandler ( "onPlayerVehicleEnter", root, function ( vehicle ) local vehicle = getVehicleName ( vehicle ) outputChatBox ("#FE02F7Pro nastartování vozidla #ffffff" .. vehicle .. "#FE02F7 stiskni #ffffffK#FE02F7.",getRootElement(), 255, 255, 255, true ) end ) addEventHandler( "onPlayerWasted", getRootElement( ), function ( player ) setTimer ( spawnPlayer, 3000, 1, player, 2034, -1414, 16 ) end ) Link to comment
iPrestege Posted July 2, 2013 Share Posted July 2, 2013 addEventHandler( "onPlayerWasted", getRootElement( ), function ( ) setTimer ( spawnPlayer, 3000, 1, source, 2034, -1414, 16 ) end ) Try it. Link to comment
#Al-Ha[J]aRii Posted July 2, 2013 Share Posted July 2, 2013 addEventHandler( "onPlayerWasted", getRootElement( ), function ( ) setTimer ( spawnPlayer, 3000, 1, source, 2034, -1414, 16 ) end ) Try it. I think he wil need : setCameraTarget Link to comment
papam77 Posted July 2, 2013 Author Share Posted July 2, 2013 No no, not needed Work it, ty Link to comment
papam77 Posted July 2, 2013 Author Share Posted July 2, 2013 addEventHandler( "onPlayerWasted", getRootElement( ), function ( ) -- Place for spawn setTimer ( spawnPlayer, 3000, 1, source, 2034, -1414, 16.3 ) -- Saving Part local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then local playermoney = getPlayerMoney ( source ) local skin = getElementModel ( source ) local pos = getElementPosition ( source ) setAccountData ( playeraccount, "acc", playermoney ) setAccountData ( playeraccount, "skin", skin ) end -- Loading part local player = getRootElement() if ( playeraccount ) then local playermoney = getAccountData ( playeraccount, "acc" ) local skin = getAccountData ( playeraccount, "skin" ) -- Money if ( playermoney ) then setPlayerMoney ( source, playermoney ) end -- Skin if ( skin ) then setElementModel ( source, skin ) else outputChatBox ( "NO SKIN SAVED!", source ) end end end ) I edited something, but it doesn't load my skin. 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