Jump to content

Me Explican esto?


AlvareZ_

Recommended Posts

Me Podrian explicar un poco mas detallado el setAccountData y getAccountData, lo que quiero es que al loggear le salga algo y la segunda vez No me explican un poco mas detallado esto: Gracias de ante mano

function onPlayerQuit ( ) 
      -- when a player leaves, store his current money amount in his account data 
      local playeraccount = getPlayerAccount ( source ) 
      if ( playeraccount ) and not isGuestAccount ( playeraccount ) then -- if the player is logged in 
            local playermoney = getPlayerMoney ( source ) -- get the player money 
            setAccountData ( playeraccount, "piraterpg.money", playermoney ) -- save it in his account 
      end 
end 
  
function onPlayerLogin (_, playeraccount ) 
      -- when a player logins, retrieve his money amount from his account data and set it 
      if ( playeraccount ) then 
            local playermoney = getAccountData ( playeraccount, "piraterpg.money" ) 
            -- make sure there was actually a value saved under this key (check if playermoney is not false). 
            -- this will for example not be the case when a player plays the gametype for the first time 
            if ( playermoney ) then 
                  setPlayerMoney ( source, playermoney ) 
            end 
      end 
end 
  
addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) 
addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin) 

Link to comment

setAccountData y getAccountData es parecido al setElementData y getElementData. Solo que setAccountData guarda datos, lo que vos quieras, en la cuenta del player y getAccountData es para obtenerlas. Si tu quieres mostrarle algo cuando se registre, puedes hacer esto: Que verifique si tiene un dato especefico, si no lo tiene le mostras lo que queres. Asi mira:

function onPlayerNuevoQuit() 
local playeraccount = getPlayerAccount(source)--Obtener cuenta del player 
if ( playeraccount ) and not isGuestAccount ( playeraccount ) then 
if (not getAccountData(playeraccount, "nuevo")) then -- Si no obtiene el dato... 
setAccountData(playeraccount, "nuevo", "viejo") -- Darle el dato diciendo que este player ya es viejo asi no le aparece la bienvenida 
end 
end 
end 
addEventHandler("onPlayerQuit", getRootElement(), onPlayerNuevoQuit) 
  
function onPlayerRegister(_, playeraccount) 
if (not getAccountData(playeraccount, "nuevo")) then--Si no tiene el dato... 
outputChatBox("Bienvenido a nuestro server 24/7 de MTA:SA", source, 0, 255, 0, false)--mostrarle en el chat lo que esta entre "" 
end 
end 
addEventHandler("onPlayerLogin", getRootElement(), onPlayerRegister) 
  

No se si me explique bien.

Link to comment

Eso seria en clinent-side no ? intento crearlo con unas set camera entonces seria :

function onPlayerNuevoQuit() 
local playeraccount = getPlayerAccount(source) 
if ( playeraccount ) and not isGuestAccount ( playeraccount ) then 
if (not getAccountData(playeraccount, "nuevo")) then  
setAccountData(playeraccount, "nuevo", "viejo") 
end 
end 
end 
addEventHandler("onPlayerQuit", getRootElement(), onPlayerNuevoQuit) 
  
function onPlayerRegister(_, playeraccount) 
if (not getAccountData(playeraccount, "nuevo")) then 
    setCameraMatrix(2350.2368164063, 69.811370849609, 26.484375, 2340.9641113281, 12.886473655701, 26.3359375) 
    setTimer(setCameraMatrix, 8000, 1, 2272.8959960938, -32.551116943359, 26.339841842651, 2315.6574707031, -28.518367767334, 26.3359375) 
end 
end 
addEventHandler("onPlayerLogin", getRootElement(), onPlayerRegister) 

Gracias por ayudarme

Link to comment
Eso seria en clinent-side no ? intento crearlo con unas set camera entonces seria :
function onPlayerNuevoQuit() 
local playeraccount = getPlayerAccount(source) 
if ( playeraccount ) and not isGuestAccount ( playeraccount ) then 
if (not getAccountData(playeraccount, "nuevo")) then  
setAccountData(playeraccount, "nuevo", "viejo") 
end 
end 
end 
addEventHandler("onPlayerQuit", getRootElement(), onPlayerNuevoQuit) 
  
function onPlayerRegister(_, playeraccount) 
if (not getAccountData(playeraccount, "nuevo")) then 
    setCameraMatrix(2350.2368164063, 69.811370849609, 26.484375, 2340.9641113281, 12.886473655701, 26.3359375) 
    setTimer(setCameraMatrix, 8000, 1, 2272.8959960938, -32.551116943359, 26.339841842651, 2315.6574707031, -28.518367767334, 26.3359375) 
end 
end 
addEventHandler("onPlayerLogin", getRootElement(), onPlayerRegister) 

Gracias por ayudarme

Si quieres hacerlo Client, cambia los Eventos que tienes.

Link to comment

Solo me faltaba un source, ahora intento agregarle esto: pero no me da :S

function onPlayerNuevoQuit() 
local playeraccount = getPlayerAccount(source) 
if ( playeraccount ) and not isGuestAccount ( playeraccount ) then 
if (not getAccountData(playeraccount, "nuevo")) then 
spawnPlayer (source, 2312.84375, -1.3126500844955, 26.7421875, 0, math.random (280,288), 0, 0, spawnTeam) 
outputChatBox("Bienvenido de Vuelta"..getPlayerName.."Diviertete!", source, 255, 0, 0, 255) 
setAccountData(playeraccount, "nuevo", "viejo") 
end 
end 
end 
addEventHandler("onPlayerQuit", getRootElement(), onPlayerNuevoQuit) 

Link to comment
Solo me faltaba un source, ahora intento agregarle esto: pero no me da :S
function onPlayerNuevoQuit() 
local playeraccount = getPlayerAccount(source) 
if ( playeraccount ) and not isGuestAccount ( playeraccount ) then 
if (not getAccountData(playeraccount, "nuevo")) then 
spawnPlayer (source, 2312.84375, -1.3126500844955, 26.7421875, 0, math.random (280,288), 0, 0, spawnTeam) 
outputChatBox("Bienvenido de Vuelta"..getPlayerName.."Diviertete!", source, 255, 0, 0, 255) 
setAccountData(playeraccount, "nuevo", "viejo") 
end 
end 
end 
addEventHandler("onPlayerQuit", getRootElement(), onPlayerNuevoQuit) 

getPlayerName, no está definido de quien es el nombre. Ademas , no creaste el Team ( spawnTeam ).

Edited by Guest
Link to comment

No me anda nada, Mira registre una nueva cuenta que no es admin ni nada y Sale cada ves que loggeo, y con la mia que tiene Admin no me sale que sera?

function onPlayerNuevoQuit() 
local playeraccount = getPlayerAccount(source) 
if ( playeraccount ) and not isGuestAccount ( playeraccount ) then 
local localPlayerName = getPlayerName(getLocalPlayer()) 
spawnPlayer (source, 2312.84375, -1.3126500844955, 26.7421875, 0, math.random (280,288), 0, 0, spawnTeam) 
outputChatBox("Bienvenido de Vuelta"..getPlayerName(playerSource)"Diviertete!", source, 255, 0, 0, 255) 
if (not getAccountData(playeraccount, "nuevo")) then 
setAccountData(playeraccount, "nuevo", "viejo") 
end 
end 
end 
addEventHandler("onPlayerQuit", getRootElement(), onPlayerNuevoQuit) 
  
function onPlayerRegister(_, playeraccount) 
if (not getAccountData(playeraccount, "nuevo")) then 
    setCameraMatrix(source, 2350.2368164063, 69.811370849609, 26.484375, 2340.9641113281, 12.886473655701, 26.3359375) 
    setTimer(setCameraMatrix, 8000, 1, source, 2272.8959960938, -32.551116943359, 26.339841842651, 2315.6574707031, -28.518367767334, 26.3359375) 
end 
end 
addEventHandler("onPlayerLogin", getRootElement(), onPlayerRegister) 

Link to comment

Para Mi es este el problema.

outputChatBox("Bienvenido de Vuelta"..getPlayerName(playerSource)"Diviertete!", source, 255, 0, 0, 255) 

Cambialo por este

outputChatBox("Bienvenido de Vuelta "..getPlayerName(source).. "Diviertete!", source, 255, 0, 0, 255) 
Edited by Guest
Link to comment

Si pongo todo asi deberia andar, no ?

function onPlayerNuevoQuit() 
local playeraccount = getPlayerAccount(source) 
if ( playeraccount ) and not isGuestAccount ( playeraccount ) then 
spawnPlayer (source, 2312.84375, -1.3126500844955, 26.7421875, 0, math.random (280,288), 0, 0, spawnTeam) 
outputChatBox("Bienvenido de Vuelta "..getPlayerName(source).. "Diviertete!", source, 255, 0, 0, 255) 
if (not getAccountData(playeraccount, "nuevo")) then 
setAccountData(playeraccount, "nuevo", "viejo") 
end 
end 
end 
addEventHandler("onPlayerQuit", getRootElement(), onPlayerNuevoQuit) 
  
function onPlayerRegister(_, playeraccount) 
if (not getAccountData(playeraccount, "nuevo")) then 
    setCameraMatrix(source, 2350.2368164063, 69.811370849609, 26.484375, 2340.9641113281, 12.886473655701, 26.3359375) 
    setTimer(setCameraMatrix, 8000, 1, source, 2272.8959960938, -32.551116943359, 26.339841842651, 2315.6574707031, -28.518367767334, 26.3359375) 
end 
end 
addEventHandler("onPlayerLogin", getRootElement(), onPlayerRegister) 

Link to comment
function onPlayerNuevoQuit() 
local playeraccount = getPlayerAccount(source) 
if ( playeraccount ) and not isGuestAccount ( playeraccount ) then 
if (not getAccountData(playeraccount, "nuevo")) then 
setAccountData(playeraccount, "nuevo", "viejo") 
end 
end 
end 
addEventHandler("onPlayerQuit", getRootElement(), onPlayerNuevoQuit) 
  
function playerViejo() 
local account = getPlayerAccount(source) 
if (getAccountData(account, "nuevo") == "viejo") then 
 spawnPlayer (source, 2312.84375, -1.3126500844955, 26.7421875, 0, math.random (280,288), 0, 0) 
outputChatBox("Bienvenido de Vuelta "..getPlayerName(source).. "Diviertete!", source, 255, 0, 0, 255)  
end 
end 
addEventHandler("onPlayerLogin", getRootElement(), playerViejo) 
  
function onPlayerRegister(_, playeraccount) 
if (not getAccountData(playeraccount, "nuevo")) then 
    setCameraMatrix(source, 2350.2368164063, 69.811370849609, 26.484375, 2340.9641113281, 12.886473655701, 26.3359375) 
    setTimer(setCameraMatrix, 8000, 1, source, 2272.8959960938, -32.551116943359, 26.339841842651, 2315.6574707031, -28.518367767334, 26.3359375) 
end 
end 
addEventHandler("onPlayerLogin", getRootElement(), onPlayerRegister)  

Link to comment
Sigue sin andar :/, No hay error debug, Con mi cuenta admin no me muestra las setCameraMatrix y con la cuenta que me registre si me las muestra, y tambien si ya esta registrada me loggeo con la mia y no me spawnea y no me dice nada en el chat

Te falta

if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "admin" ) ) then 

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...