Jump to content

Help


Batista

Recommended Posts

Posted

Hello all,

I want to do a script that save the team when I quit, and when I login again I return to the same team.

Please help me with it.

Thank you.

Posted (edited)

I won't give you the script himself, but the functions/events you can use.

Functions:

getPlayerTeam -- To get the player team. 
getTeamName -- To get the player team name. 
getPlayerAccount -- To get the player account. 
setAccountData -- To save the team name in his account. 
getAccountData -- To get the saved team name in his account. 
getTeamFromName -- To get a team by it's name. 
setPlayerTeam -- To set the player team. 

Events:

[url=https://wiki.multitheftauto.com/wiki/OnPlayerQuit]https://wiki.multitheftauto.com/wiki/OnPlayerQuit[/url] 
[url=https://wiki.multitheftauto.com/wiki/OnPlayerLogin]https://wiki.multitheftauto.com/wiki/OnPlayerLogin[/url] 

Click on the links and start learning.

Edited by Guest

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
  
addEventHandler("onPlayerQuit",root,function() -- adding on player quit event  
    hisAcc = getPlayerAccount(source) -- get the player account  
    if hisAcc and not isGuestAccount(hisAcc) then -- if he is logged in 
        hisTeam = getPlayerTeam(source) -- get his team 
            if hisTeam then -- if got the team  
                hisTeamName = getTeamName(hisTeam) -- get the team name 
                    setAccountData(hisAcc,"team",hisTeamName) -- save the team in value "team" at his account 
            end 
    end 
end ) 
  
addEventHandler("onPlayerLogin",root,function(_,theCurrentAccount) -- adding on player login event 
    hisAcc = theCurrentAccount  
    hisTeamName = getAccountData(hisAcc,"team") -- get the saved value [ team name ] 
        if hisTeamName then -- if got the value 
            hisTeam = getTeamFromName(hisTeamName) -- get the team from the name saved 
                if hisTeam then -- if got the team 
                    setPlayerTeam(source,hisTeam) -- set his team to the saved team 
                end 
        end 
end ) 
  

ING : [xXx]~Al3grab

Posted

@Al3grab: Are you f**** stu***?? I wanted him to make it, not to get the complete script, now he'll just copy and paste it on a Lua file and say "thanks".

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
@Al3grab: Are you f**** stu***?? I wanted him to make it, not to get the complete script, now he'll just copy and paste it on a Lua file and say "thanks".

i'm bored xD

ING : [xXx]~Al3grab

Posted

well, as long as there are still people around there who will give out full working scripts.. Actually, another way of learning is to get a complete script and trying to understand how everything fits together; and it's rather effective than attempting to create a script from scratch as a newbie

Posted

Thank you Al3agrab.

@SolidSnake, the person know from his mistakes and from othres help. I try to do one with the functions that you give it to me and I didn't, it's hard for a new scripter as me, with Al3agrab help I know more about that.

Posted

Oh c'mon, you didn't even try to make it, you just copied it like I said.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

No, at the first I try to make one, but I find it hardly. When I have a look at this topic, I found that Al3agrab post it, so I start readingit to know how he do it.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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