Akam Posted June 4, 2013 Share Posted June 4, 2013 (edited) Hi! i need help with a hospital problem, when i spawn at the hospital it only saves my team obviously because i dont have added any other script, but i want it to save my stats,wanted level and skin id on wasted. i can't script so i can't add it, i got the hospital script from here: https://forum.multitheftauto.com/viewtop ... 9&p=566127 please help Thanks for taking your time to read Edited June 4, 2013 by Guest Link to comment
فاّرس Posted June 4, 2013 Share Posted June 4, 2013 Sorry i am not understand you ! what " hospital " ? and post your code and tell me what's the problem. Link to comment
Akam Posted June 4, 2013 Author Share Posted June 4, 2013 Sorry i am not understand you !what " hospital " ? and post your code and tell me what's the problem. i can't explain better the topic says all i want that when i die and respawn at the hospital that my wanted level and my stats don't disappear. hospitalsTable = { { 1177.7994384766, -1323.0667724609, 14.088536262512 }, { -2656.2421875, 635.99420166016, 14.453125 }, { 1607.1225585938, 1817.8732910156, 10.8203125 }, } function findNearestHostpital(thePlayer) local nearest = nil local min = 999999 for key,val in pairs(hospitalsTable) do local xx,yy,zz=getElementPosition(thePlayer) local x1=val[1] local y1=val[2] local z1=val[3] local dist = getDistanceBetweenPoints2D(xx,yy,x1,y1) if dist<min then nearest = val min = dist end end return nearest[1],nearest[2],nearest[3] end function spawn(player) local xx,yy,zz = findNearestHostpital(player) spawnPlayer( player, xx,yy,zz) fadeCamera(player,true,3.0) end addEventHandler("onPlayerWasted", root, function() fadeCamera(source,false,6.0,0,0,0) setTimer(spawn, 8000, 1, source) end ) addEventHandler ( "onPlayerWasted", root, function ( ) local account = getPlayerAccount ( source ) if ( account and not isGuestAccount ( account ) ) then for slot = 1, 12 do setAccountData ( account, "save-wep".. slot, getPedWeapon ( source, slot ) ) setAccountData ( account, "save-ammo".. slot, getPedTotalAmmo ( source, slot ) ) end local team = getPlayerTeam ( source ) if ( team ) then setAccountData ( account, "save-level", getWantedLevel ( team ) ) end end end ) addEventHandler ( "onPlayerSpawn", root, function ( ) local account = getPlayerAccount ( source ) if ( account and not isGuestAccount ( account ) ) then local team = getTeamFromName ( getAccountData ( account, "save-team" ) ) if ( team ) then setPlayerTeam ( source, team ) else outputChatBox ( "Get a Job NOOB", source ) end for slot = 1, 12 do local wep = getAccountData ( account, "save-wep".. slot ) local ammo = getAccountData ( account, "save-ammo".. slot ) giveWeapon ( source, wep, ammo ) end end end ) Link to comment
Akam Posted June 4, 2013 Author Share Posted June 4, 2013 Someone? please help guys need this done quick Link to comment
K4stic Posted June 5, 2013 Share Posted June 5, 2013 Download from Community one save system Link to comment
Akam Posted June 5, 2013 Author Share Posted June 5, 2013 Download from Community one save system Nobody understands me i talk about when i DIE! and after i die i respawn at the hospital but when i respawn at the hospital i lose all my stats and i lose my wanted level i dont want to lose my wanted level or stats when i spawn Link to comment
Moderators IIYAMA Posted June 5, 2013 Moderators Share Posted June 5, 2013 (edited) Because you don't load all the account data? setPlayerWantedLevel ( source, getAccountData ( account, "save-level" ) or 0 ) What stats???? nobody has written anything in the script about stats. Edited June 5, 2013 by Guest Link to comment
Akam Posted June 5, 2013 Author Share Posted June 5, 2013 Because you don't load all the account data? setAccountData ( account, "save-level",getAccountData ( account, "save-level" ) ) setAccountData ( account, "save-level",getAccountData ( account, "save-level" ) ) What stats???? nobody has written anything in the script about stats. what? is that code? lol i know that this script dosent got wanted level or stats but i want to add and i cant script so please help i can basic tho Link to comment
Moderators IIYAMA Posted June 5, 2013 Moderators Share Posted June 5, 2013 addEventHandler ( "onPlayerSpawn", root, function ( ) local account = getPlayerAccount ( source ) if ( account and not isGuestAccount ( account ) ) then setPlayerWantedLevel ( source, getAccountData ( account, "save-level" ) or 0 ) local team = getTeamFromName ( getAccountData ( account, "save-team" ) ) if ( team ) then setPlayerTeam ( source, team ) else outputChatBox ( "Get a Job NOOB", source ) end for slot = 1, 12 do local wep = getAccountData ( account, "save-wep".. slot ) local ammo = getAccountData ( account, "save-ammo".. slot ) giveWeapon ( source, wep, ammo ) end end end ) setPlayerWantedLevel ( source, getAccountData ( account, "save-level" ) or 0 )* Link to comment
Akam Posted June 6, 2013 Author Share Posted June 6, 2013 addEventHandler ( "onPlayerSpawn", root, function ( ) local account = getPlayerAccount ( source ) if ( account and not isGuestAccount ( account ) ) then setPlayerWantedLevel ( source, getAccountData ( account, "save-level" ) or 0 ) local team = getTeamFromName ( getAccountData ( account, "save-team" ) ) if ( team ) then setPlayerTeam ( source, team ) else outputChatBox ( "Get a Job NOOB", source ) end for slot = 1, 12 do local wep = getAccountData ( account, "save-wep".. slot ) local ammo = getAccountData ( account, "save-ammo".. slot ) giveWeapon ( source, wep, ammo ) end end end ) setPlayerWantedLevel ( source, getAccountData ( account, "save-level" ) or 0 )* i appreciate your help but that dosent work ._. Link to comment
Akam Posted June 7, 2013 Author Share Posted June 7, 2013 (edited) Post the whole script. Yes finally the master is here here is the whole script hospitalsTable = { { 1177.7994384766, -1323.0667724609, 14.088536262512 }, { -2656.2421875, 635.99420166016, 14.453125 }, { 1607.1225585938, 1817.8732910156, 10.8203125 }, } function findNearestHostpital(thePlayer) local nearest = nil local min = 999999 for key,val in pairs(hospitalsTable) do local xx,yy,zz=getElementPosition(thePlayer) local x1=val[1] local y1=val[2] local z1=val[3] local dist = getDistanceBetweenPoints2D(xx,yy,x1,y1) if dist<min then nearest = val min = dist end end return nearest[1],nearest[2],nearest[3] end function spawn(player) local xx,yy,zz = findNearestHostpital(player) spawnPlayer( player, xx,yy,zz) fadeCamera(player,true,3.0) end addEventHandler("onPlayerWasted", root, function() fadeCamera(source,false,6.0,0,0,0) setTimer(spawn, 8000, 1, source) end ) addEventHandler ( "onPlayerWasted", root, function ( ) local account = getPlayerAccount ( source ) if ( account and not isGuestAccount ( account ) ) then for slot = 1, 12 do setAccountData ( account, "save-wep".. slot, getPedWeapon ( source, slot ) ) setAccountData ( account, "save-ammo".. slot, getPedTotalAmmo ( source, slot ) ) end local team = getPlayerTeam ( source ) if ( team ) then setAccountData ( account, "save-team", getTeamName ( team ) ) end end end ) addEventHandler ( "onPlayerSpawn", root, function ( ) local account = getPlayerAccount ( source ) if ( account and not isGuestAccount ( account ) ) then local team = getTeamFromName ( getAccountData ( account, "save-team" ) ) if ( team ) then setPlayerTeam ( source, team ) else outputChatBox ( "Get a Job NOOB", source ) end for slot = 1, 12 do local wep = getAccountData ( account, "save-wep".. slot ) local ammo = getAccountData ( account, "save-ammo".. slot ) giveWeapon ( source, wep, ammo ) end end end ) edit: sorry wrong script but i changed it to the real script Edited June 7, 2013 by Guest Link to comment
iPrestege Posted June 7, 2013 Share Posted June 7, 2013 You didn't save the wanted level any where . Link to comment
Akam Posted June 7, 2013 Author Share Posted June 7, 2013 You didn't save the wanted level any where . sorry did post wrong script now you can see that i have no save wanted level or save stats Link to comment
iPrestege Posted June 7, 2013 Share Posted June 7, 2013 You forgot much thing try this on wasted and on spawn replace your with this : addEventHandler ( "onPlayerWasted", root, function ( ) local account = getPlayerAccount ( source ) if ( account and not isGuestAccount ( account ) ) then for slot = 1, 12 do setAccountData ( account, "save-wep".. slot, getPedWeapon ( source, slot ) ) setAccountData ( account, "save-ammo".. slot, getPedTotalAmmo ( source, slot ) ) end local team = getPlayerTeam ( source ) if ( team ) then setAccountData ( account, "save-team", getTeamName ( team ) ) local wanted = getPlayerWantedLevel ( source ) if wanted then setAccountData ( account,"save-wanted",wanted ) end end end end ) addEventHandler ( "onPlayerSpawn", root, function ( ) local account = getPlayerAccount ( source ) if ( account and not isGuestAccount ( account ) ) then local team = getTeamFromName ( getAccountData ( account, "save-team" ) ) if ( team ) then setPlayerTeam ( source, team ) else outputChatBox ( "Get a Job NOOB", source ) end for slot = 1, 12 do local wep = getAccountData ( account, "save-wep".. slot ) local ammo = getAccountData ( account, "save-ammo".. slot ) giveWeapon ( source, wep, ammo ) if (accountData) then local playerWanted = getAccountData (account, "save-wanted") setPlayerWantedLevel ( source,playerWanted or 0 ) end end end ) Link to comment
Akam Posted June 7, 2013 Author Share Posted June 7, 2013 You forgot much thing try this on wasted and on spawn replace your with this : addEventHandler ( "onPlayerWasted", root, function ( ) local account = getPlayerAccount ( source ) if ( account and not isGuestAccount ( account ) ) then for slot = 1, 12 do setAccountData ( account, "save-wep".. slot, getPedWeapon ( source, slot ) ) setAccountData ( account, "save-ammo".. slot, getPedTotalAmmo ( source, slot ) ) end local team = getPlayerTeam ( source ) if ( team ) then setAccountData ( account, "save-team", getTeamName ( team ) ) local wanted = getPlayerWantedLevel ( source ) if wanted then setAccountData ( account,"save-wanted",wanted ) end end end end ) addEventHandler ( "onPlayerSpawn", root, function ( ) local account = getPlayerAccount ( source ) if ( account and not isGuestAccount ( account ) ) then local team = getTeamFromName ( getAccountData ( account, "save-team" ) ) if ( team ) then setPlayerTeam ( source, team ) else outputChatBox ( "Get a Job NOOB", source ) end for slot = 1, 12 do local wep = getAccountData ( account, "save-wep".. slot ) local ammo = getAccountData ( account, "save-ammo".. slot ) giveWeapon ( source, wep, ammo ) if (accountData) then local playerWanted = getAccountData (account, "save-wanted") setPlayerWantedLevel ( source,playerWanted or 0 ) end end end ) i am getting an error when i am trying to start the script error: [2013-06-07 15:45:20] SCRIPT ERROR: [Addons]\hospital\wasted.lua:77: unexpected symbol near ')' [2013-06-07 15:45:20] WARNING: Loading script failed: [Addons]\hospital\wasted.lua:77: unexpected symbol near ')' Link to comment
iPrestege Posted June 7, 2013 Share Posted June 7, 2013 addEventHandler ( "onPlayerWasted", root, function ( ) local account = getPlayerAccount ( source ) if ( account and not isGuestAccount ( account ) ) then for slot = 1, 12 do setAccountData ( account, "save-wep".. slot, getPedWeapon ( source, slot ) ) setAccountData ( account, "save-ammo".. slot, getPedTotalAmmo ( source, slot ) ) end local team = getPlayerTeam ( source ) if ( team ) then setAccountData ( account, "save-team", getTeamName ( team ) ) setAccountData ( account,"save-wanted",getPlayerWantedLevel ( source ) ) end end end ) addEventHandler ( "onPlayerSpawn", root, function ( ) local account = getPlayerAccount ( source ) if ( account and not isGuestAccount ( account ) ) then local team = getTeamFromName ( getAccountData ( account, "save-team" ) ) if not ( team ) then outputChatBox ( "Get a Job NOOB", source ) return end setPlayerTeam ( source, team ) for slot = 1, 12 do local wep = getAccountData ( account, "save-wep".. slot ) local ammo = getAccountData ( account, "save-ammo".. slot ) giveWeapon ( source, wep, ammo ) local playerWanted = getAccountData (account, "save-wanted") setPlayerWantedLevel ( source,playerWanted or 0 ) end end end ) Link to comment
Akam Posted June 7, 2013 Author Share Posted June 7, 2013 addEventHandler ( "onPlayerWasted", root, function ( ) local account = getPlayerAccount ( source ) if ( account and not isGuestAccount ( account ) ) then for slot = 1, 12 do setAccountData ( account, "save-wep".. slot, getPedWeapon ( source, slot ) ) setAccountData ( account, "save-ammo".. slot, getPedTotalAmmo ( source, slot ) ) end local team = getPlayerTeam ( source ) if ( team ) then setAccountData ( account, "save-team", getTeamName ( team ) ) setAccountData ( account,"save-wanted",getPlayerWantedLevel ( source ) ) end end end ) addEventHandler ( "onPlayerSpawn", root, function ( ) local account = getPlayerAccount ( source ) if ( account and not isGuestAccount ( account ) ) then local team = getTeamFromName ( getAccountData ( account, "save-team" ) ) if not ( team ) then outputChatBox ( "Get a Job NOOB", source ) return end setPlayerTeam ( source, team ) for slot = 1, 12 do local wep = getAccountData ( account, "save-wep".. slot ) local ammo = getAccountData ( account, "save-ammo".. slot ) giveWeapon ( source, wep, ammo ) local playerWanted = getAccountData (account, "save-wanted") setPlayerWantedLevel ( source,playerWanted or 0 ) end end end ) nice you fixed the error but it wont save my wanted level when i die Link to comment
iPrestege Posted June 7, 2013 Share Posted June 7, 2013 Are you sure you have a wanted level ? And please see what the debug say . Link to comment
Akam Posted June 7, 2013 Author Share Posted June 7, 2013 Are you sure you have a wanted level ? And please see what the debug say . oh shit man sorry ._. i turned of every resource except the needed ones and the hospital script it works! you are the best but i need to add a script that when i die it saves my weapon stats can you help me? edit: sorry wrong spelling ._. Link to comment
iPrestege Posted June 7, 2013 Share Posted June 7, 2013 addEventHandler ( "onPlayerWasted", root, function ( ) local account = getPlayerAccount ( source ) if ( account and not isGuestAccount ( account ) ) then for stats = 69,81 do setAccountData ( account,"save-stats".. stats,getPedStat ( source,stats ) ) end for slot = 1, 12 do setAccountData ( account, "save-wep".. slot, getPedWeapon ( source, slot ) ) setAccountData ( account, "save-ammo".. slot, getPedTotalAmmo ( source, slot ) ) end local team = getPlayerTeam ( source ) if ( team ) then setAccountData ( account, "save-team", getTeamName ( team ) ) setAccountData ( account,"save-wanted",getPlayerWantedLevel ( source ) ) end end end ) addEventHandler ( "onPlayerSpawn", root, function ( ) local account = getPlayerAccount ( source ) if ( account and not isGuestAccount ( account ) ) then local team = getTeamFromName ( getAccountData ( account, "save-team" ) ) if not ( team ) then outputChatBox ( "Get a Job NOOB", source ) return end setPlayerTeam ( source, team ) for slot = 1, 12 do local wep = getAccountData ( account, "save-wep".. slot ) local ammo = getAccountData ( account, "save-ammo".. slot ) giveWeapon ( source, wep, ammo ) local playerWanted = getAccountData (account, "save-wanted") setPlayerWantedLevel ( source,playerWanted or 0 ) for stats = 69,81 do local stats = getAccountData (account,"save-stats".. stats) setPedStat ( source,stats ) end end end end ) Link to comment
Akam Posted June 7, 2013 Author Share Posted June 7, 2013 addEventHandler ( "onPlayerWasted", root, function ( ) local account = getPlayerAccount ( source ) if ( account and not isGuestAccount ( account ) ) then for stats = 69,81 do setAccountData ( account,"save-stats".. stats,getPedStat ( source,stats ) ) end for slot = 1, 12 do setAccountData ( account, "save-wep".. slot, getPedWeapon ( source, slot ) ) setAccountData ( account, "save-ammo".. slot, getPedTotalAmmo ( source, slot ) ) end local team = getPlayerTeam ( source ) if ( team ) then setAccountData ( account, "save-team", getTeamName ( team ) ) setAccountData ( account,"save-wanted",getPlayerWantedLevel ( source ) ) end end end ) addEventHandler ( "onPlayerSpawn", root, function ( ) local account = getPlayerAccount ( source ) if ( account and not isGuestAccount ( account ) ) then local team = getTeamFromName ( getAccountData ( account, "save-team" ) ) if not ( team ) then outputChatBox ( "Get a Job NOOB", source ) return end setPlayerTeam ( source, team ) for slot = 1, 12 do local wep = getAccountData ( account, "save-wep".. slot ) local ammo = getAccountData ( account, "save-ammo".. slot ) giveWeapon ( source, wep, ammo ) local playerWanted = getAccountData (account, "save-wanted") setPlayerWantedLevel ( source,playerWanted or 0 ) for stats = 69,81 do local stats = getAccountData (account,"save-stats".. stats) setPedStat ( source,stats ) end end end end ) i am getting an error [2013-06-07 17:03:43] WARNING: [Addons]\hospital\wasted.lua:72: Bad argument @ 'setPedStat' Link to comment
iPrestege Posted June 7, 2013 Share Posted June 7, 2013 addEventHandler ( "onPlayerWasted", root, function ( ) local account = getPlayerAccount ( source ) if ( account and not isGuestAccount ( account ) ) then for stats = 69,81 do setAccountData ( account,"save-stats".. stats,getPedStat ( source,stats ) ) end for slot = 1, 12 do setAccountData ( account, "save-wep".. slot, getPedWeapon ( source, slot ) ) setAccountData ( account, "save-ammo".. slot, getPedTotalAmmo ( source, slot ) ) end local team = getPlayerTeam ( source ) if ( team ) then setAccountData ( account, "save-team", getTeamName ( team ) ) setAccountData ( account,"save-wanted",getPlayerWantedLevel ( source ) ) end end end ) addEventHandler ( "onPlayerSpawn", root, function ( ) local account = getPlayerAccount ( source ) if ( account and not isGuestAccount ( account ) ) then local team = getTeamFromName ( getAccountData ( account, "save-team" ) ) if not ( team ) then outputChatBox ( "Get a Job NOOB", source ) return end setPlayerTeam ( source, team ) for slot = 1, 12 do local wep = getAccountData ( account, "save-wep".. slot ) local ammo = getAccountData ( account, "save-ammo".. slot ) giveWeapon ( source, wep, ammo ) local playerWanted = getAccountData (account, "save-wanted") setPlayerWantedLevel ( source,playerWanted or 0 ) for stats = 69,81 do setPedStat ( source,getAccountData (account,"save-stats".. stats) ) end end end end ) Link to comment
Akam Posted June 7, 2013 Author Share Posted June 7, 2013 addEventHandler ( "onPlayerWasted", root, function ( ) local account = getPlayerAccount ( source ) if ( account and not isGuestAccount ( account ) ) then for stats = 69,81 do setAccountData ( account,"save-stats".. stats,getPedStat ( source,stats ) ) end for slot = 1, 12 do setAccountData ( account, "save-wep".. slot, getPedWeapon ( source, slot ) ) setAccountData ( account, "save-ammo".. slot, getPedTotalAmmo ( source, slot ) ) end local team = getPlayerTeam ( source ) if ( team ) then setAccountData ( account, "save-team", getTeamName ( team ) ) setAccountData ( account,"save-wanted",getPlayerWantedLevel ( source ) ) end end end ) addEventHandler ( "onPlayerSpawn", root, function ( ) local account = getPlayerAccount ( source ) if ( account and not isGuestAccount ( account ) ) then local team = getTeamFromName ( getAccountData ( account, "save-team" ) ) if not ( team ) then outputChatBox ( "Get a Job NOOB", source ) return end setPlayerTeam ( source, team ) for slot = 1, 12 do local wep = getAccountData ( account, "save-wep".. slot ) local ammo = getAccountData ( account, "save-ammo".. slot ) giveWeapon ( source, wep, ammo ) local playerWanted = getAccountData (account, "save-wanted") setPlayerWantedLevel ( source,playerWanted or 0 ) for stats = 69,81 do setPedStat ( source,getAccountData (account,"save-stats".. stats) ) end end end end ) another error [2013-06-07 17:08:42] WARNING: [Addons]\hospital\wasted.lua:71: Bad argument @ 'setPedStat' Link to comment
iPrestege Posted June 7, 2013 Share Posted June 7, 2013 addEventHandler ( "onPlayerWasted", root, function ( ) local account = getPlayerAccount ( source ) if ( account and not isGuestAccount ( account ) ) then for stats = 69,81 do setAccountData ( account,"save-stats".. stats,getPedStat ( source,stats ) ) end for slot = 1, 12 do setAccountData ( account, "save-wep".. slot, getPedWeapon ( source, slot ) ) setAccountData ( account, "save-ammo".. slot, getPedTotalAmmo ( source, slot ) ) end local team = getPlayerTeam ( source ) if ( team ) then setAccountData ( account, "save-team", getTeamName ( team ) ) setAccountData ( account,"save-wanted",getPlayerWantedLevel ( source ) ) end end end ) addEventHandler ( "onPlayerSpawn", root, function ( ) local account = getPlayerAccount ( source ) if ( account and not isGuestAccount ( account ) ) then local team = getTeamFromName ( getAccountData ( account, "save-team" ) ) if not ( team ) then outputChatBox ( "Get a Job NOOB", source ) return end setPlayerTeam ( source, team ) for slot = 1, 12 do local wep = getAccountData ( account, "save-wep".. slot ) local ammo = getAccountData ( account, "save-ammo".. slot ) giveWeapon ( source, wep, ammo ) local playerWanted = getAccountData (account, "save-wanted") setPlayerWantedLevel ( source,playerWanted or 0 ) for stats = 69,81 do setPedStat ( source,getAccountData (account,"save-stats".. stats) or nil ) outputChatBox('SET PED STAT DONE',source) end end end end ) See if it output the chat box or no . 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