-.Paradox.- Posted June 9, 2013 Posted June 9, 2013 Hello, I'm new here and my name is Steven, i need a resource can save player skin and stats when he die or login. Thanks, Bye.
iPrestege Posted June 9, 2013 Posted June 9, 2013 Wrong section search here : https://community.multitheftauto.com/.
Jaysds1 Posted June 9, 2013 Posted June 9, 2013 You could learn lua, as I don't know any resources on the community site with those features.
Alan.Alexander Posted June 10, 2013 Posted June 10, 2013 function saveData(p) if not source and p then source = p; end local a = getPlayerAccount(source); if a then if not isGuestAccount(a) then setAccountData(a, "user.money", getPlayerMoney(source)); setAccountData(a, "user.skin", getPedSkin(source)); setAccountData(a, "user.health", getElementHealth(source)); setAccountData(a, "user.armor", getPedArmor(source)); local x,y,z = getElementPosition(source); setAccountData(a, "user.pos", toJSON({x,y,z,getElementInterior(source),getElementDimension(source)})); local rx, ry, rz = getElementRotation(source); setAccountData(a, "user.rot", toJSON({rx,ry,rz})); local stats = {}; for i=69,79 do stats[i] = getPedStat(source,i); end setAccountData(a, 'user.stats', toJSON(stats)); end end end addEventHandler("onPlayerQuit",getRootElement(),saveData) addEventHandler("onPlayerLogout",getRootElement(),saveData) addEventHandler("onPlayerWasted",getRootElement(),saveData) function playerLogin (thePreviousAccount, theCurrentAccount, autoLogin) local a = getPlayerAccount(source); if not isGuestAccount(a) then local pos = fromJSON(getAccountData(theCurrentAccount,"user.pos")) or {}; if pos[1] and pos[2] and pos[3] then local money = getAccountData(theCurrentAccount,"user.money"); local health = getAccountData(theCurrentAccount,"user.health"); local armor = getAccountData(theCurrentAccount,"user.armor"); local skin = getAccountData(theCurrentAccount,"user.skin"); local rx,ry,rz = fromJSON(getAccountData(theCurrentAccount,"user.rot")); if not rx then rx = 0; end; if not ry then ry = 0; end; if not rz then rz = 0; end; local stats = fromJSON(getAccountData(theCurrentAccount,"user.stats")); spawnPlayer(source,pos[1],pos[2],pos[3],0,skin,pos[4],pos[5]); --setElementRotation(source,tonumber(rx),tonumber(ry),tonumber(rz)); setElementRotation(source,0,0,0); setElementHealth(source,health); setPedArmor(source,armor); setPlayerMoney(source,money); setElementFrozen(source,false); setElementAlpha(source,255) for i=69,79 do setPedStat(source,i,tonumber(stats[tostring(i)])); end else FirstTimePlaying(); end setCameraTarget(source,source); fadeCamera(source,true,2); end end addEventHandler ("onPlayerLogin", getRootElement(), playerLogin) function FirstTimePlaying() local PedSkins = {26,29,27,33,34,32,45,46,61,59,60,68,73,78,79,93,100,105,106,107,101,102,103,104,108,109,110,114,115,116,117,118,120,121,122,127,133,152,157,154,161,163,165,170,176,177,179,181,191,192,204,206,217,227,246,247,248,250,254,264}; spawnPlayer(source, 1608, 1830, 10.8, 0, math.random(1,#PedSkins), 0, 0); setPlayerMoney(source,2500); giveWeapon(source,math.random(22,23),250); giveWeapon(source,25,25); end function saveWeaponData(p) if not source and p then source = p; end local a = getPlayerAccount(source); if not isGuestAccount(a) then for i=0,11 do setAccountData(a, "weapon."..i,toJSON({getPedWeapon(source,i),getPedTotalAmmo(source,i)})); end end end addEventHandler("onPlayerQuit",getRootElement(),saveWeaponData) addEventHandler("onPlayerWasted",getRootElement(),saveWeaponData) addEventHandler("onPlayerLogout",getRootElement(),saveWeaponData) function loadWeaponData(p) if not source and p then source = p; end local a = getPlayerAccount(source); if not isGuestAccount(a) then for i=0,11 do local w = fromJSON(getAccountData(a, "weapon."..i, getPedWeapon(source,i))); giveWeapon(source,w[1],w[2]); end end end addEventHandler("onPlayerSpawn",getRootElement(),loadWeaponData) function onPickupHit(p) local t = getPickupType(source); if t ~= 0 then return; end if getElementHealth(p) > 99 then cancelEvent() end end addEventHandler("onPickupHit",getRootElement(),onPickupHit); hospitalSpawnPoints = {} --hospitalSpawnPoints[0] = {x,y,z,r,name,city,lx,ly,lz} hospitalSpawnPoints[1] = {1177,-1322,14.5,270,"All Saints General Hospital","LS",1215,-1320,30,1175,-1340,13}; createPickup(1178,-1317,14,0,20,15000); hospitalSpawnPoints[2] = {1245,331,20,340,"Crippen Memorial Hospital","LS",1240,360,35,1245,331,18}; createPickup(1252,329,20,0,20,15000); hospitalSpawnPoints[3] = {-315,1055,20,0,"Fort Carson Medical Center","LV",-300,1085,40,-315,1055,18}; createPickup(-312,1052,20.5,0,20,15000); hospitalSpawnPoints[4] = {1610,1825,11,0,"Las Venturas Hospital","LV",1632,1855,25,1610,1825,10}; createPickup(1600,1820,11,0,20,15000); hospitalSpawnPoints[5] = {-2660,635,15,180,"San Fierro Medical Center","SF",-2631,585,30,-2660,635,14}; createPickup(-2667,636,14.5,0,20,15000); hospitalSpawnPoints[6] = {2033,-1415,17.5,120,"County General Hospital","LS",2007,-1450,35,2033,-1415,16}; createPickup(2030,-1405,17.5,0,20,15000); hospitalSpawnPoints[7] = {-1515,2530,56,0,"El Quebrados Medical Center","LV",-1535,2560,70,-1515,2530,55}; createPickup(-1520,2520,56,0,20,15000); hospitalSpawnPoints[8] = {-2195,-2305,31,325,"Angel Pine Medical Center","SF",-2190,-2280,46,-2195,-2305,30}; createPickup(-2190,-2300,30.5,0,20,15000); for key, val in pairs (hospitalSpawnPoints) do createBlip (val[1], val[2], val[3], 22, 2, 255, 0, 0, 255, 0, 200) end function onWasted() if not isGuestAccount(getPlayerAccount(source)) then local xx, yy, zz = getElementPosition(source); local zone = getElementZoneName(source,true); local r = math.random(1,100); local hos = {}; if r > 0 and r < 751 then local min_distance = 99999999; for key, val in pairs (hospitalSpawnPoints) do local dist = getDistanceBetweenPoints3D(val[1], val[2], val[3],xx,yy,zz); if (dist) then min_distance = dist; hos = val; end end elseif r >750 and r < 951 then local z = 'LS'; if zone == "San Fierro" then z = 'SF' elseif zone == 'Las Venturas' then z = 'LV'; end local hoss = {}; for key, val in pairs (hospitalSpawnPoints) do if val[6] == z then hoss[(#hoss + 1)] = val; end end hos = hoss[math.random(1,#hoss)]; else hos = hospitalSpawnPoints[math.random(1,#hospitalSpawnPoints)]; end rand1 = (math.random(0,300)-150)/100; rand2 = (math.random(0,300)-150)/100; outputChatBox("You have died!!",source,255,64,0); outputChatBox("You will respawn at "..hos[5]..".",source,64,255,0); setTimer(spawnPlayer, 15000, 1, source, hos[1]+rand1, hos[2]+rand2, hos[3], hos[4], getPedSkin (source), 0, 0 ); setTimer(setCameraTarget, 15000, 1, source, source); setTimer(fadeCamera, 2000, 1, source, false,2); setTimer(setCameraMatrix,4000,1,source,hos[7],hos[8],hos[9],hos[10],hos[11],hos[12]); setTimer(fadeCamera, 4000, 1, source, true); end end addEventHandler ("onPlayerWasted", getRootElement(), onWasted) First script is a player save script, second is a respawn, enjoy.
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