Jump to content

Some questions for a LUA newbie :D


CTCCoco

Recommended Posts

1. Its possible do a house / bussiness system with XML fuctions?

2. Why if I use xmlCreateFile ( ":RLC/houses, "HouseSystem" ) or xmlCreateFile ( "houses, "HouseSystem" ) don't create anything :S?

3. Why If I change some Data manually like the Player Level to 4 or something and when the player connect to the server change it to 0 automatic?

4. Why this makeadmin command doesn't works? ( You put the things /haceradmin (name of the player) (level of admin) and says: "you must put /haceradmin blabla all the time :S ) Code:

function ComandoPagar(thePlayer, theCommand, theTarget, amount)
         if theTarget then local giveTo = getPlayerFromName(theTarget) end
         if amount then amount = tonumber(amount) end
         if giveTo and amount then
           amount = math.floor(amount)
           if giveTo == thePlayer then outputChatBox("Error: No puedes darte dinero a tí mismo.", thePlayer)
           elseif amount < 1 then outputChatBox("Error: No puedes enviar nada...", thePlayer)
           elseif getPlayerMoney(thePlayer) < amount then outputChatBox("Error: No tienes $" .. amount, thePlayer)
           else
             setAccountData(getPlayerAccount(giveTo), "RLC.NivelAdmin", amount)
             outputChatBox(getPlayerName(thePlayer) .. " te ha dado nivel" .. amount" de admin", giveTo)
             outputChatBox("Has dado " .. amount .. " de nivel de admin a " .. theTarget, thePlayer)
           end
         else
           outputChatBox("Escribe /" .. theCommand .. " <nombre> <nivel de admin>", thePlayer)
         end 
       end
       addCommandHandler("haceradmin", ComandoPagar)

Thanks for all people. Please help me I need learn :DD

Link to comment

1. Yes. When you're making your own home system then you can use anything you like.

2. Both of your xmlCreateFile samples are invalid. If you had used MTA:SE you wouldn't get that error because you would know what's wrong with this code immediately. I won't say what's wrong because you want to learn, so check your code. Or download MTA:SE and open your resource with it, then open the file in which this code is and you'll find out what's wrong.

3. When you change accounts.xml manually, server doesn't know about it and uses the values which were loaded before editing it. If you want to change values of attributes then you have to use setAccountData instead.

4. giveTo will always be nil at if giveTo and amount then line since you declare it as local inside an if statement which is different block (learn more about it here). So, it will always go to else which is that message you get.

Link to comment
1. Yes. When you're making your own home system then you can use anything you like.

2. Both of your xmlCreateFile samples are invalid. If you had used MTA:SE you wouldn't get that error because you would know what's wrong with this code immediately. I won't say what's wrong because you want to learn, so check your code. Or download MTA:SE and open your resource with it, then open the file in which this code is and you'll find out what's wrong.

3. When you change accounts.xml manually, server doesn't know about it and uses the values which were loaded before editing it. If you want to change values of attributes then you have to use setAccountData instead.

4. giveTo will always be nil at if giveTo and amount then line since you declare it as local inside an if statement which is different block (learn more about it here). So, it will always go to else which is that message you get.

I don't know why but I can't save a file with MTA:SE. I think is bugged on my computer for something strange.

Thanks for all you are the best xD. I will write if I have more problems.

Link to comment

I have been trying to find a way to fix this problem with files not being saved but I can't do much without having access to Vista nor 7. I'm guessing you're not using XP because to my knowledge, nobody who is running XP has this problem.

Link to comment
1. Yes. When you're making your own home system then you can use anything you like.

2. Both of your xmlCreateFile samples are invalid. If you had used MTA:SE you wouldn't get that error because you would know what's wrong with this code immediately. I won't say what's wrong because you want to learn, so check your code. Or download MTA:SE and open your resource with it, then open the file in which this code is and you'll find out what's wrong.

This isn't the error. Is a stupid error that I do in the post but it doesn't work with the ". Please help me.

4. giveTo will always be nil at if giveTo and amount then line since you declare it as local inside an if statement which is different block (learn more about it here). So, it will always go to else which is that message you get.

I don't get the message now. I don't get anything :S no message and nothing :S only if you don't put the name of the level of admin get a error but if you put all correct you don't get anything :S [ PROBLEM SOLVED]

Please help and thanks .

Link to comment
I have been trying to find a way to fix this problem with files not being saved but I can't do much without having access to Vista nor 7. I'm guessing you're not using XP because to my knowledge, nobody who is running XP has this problem.

Erhm... I use XP :S

Post your problem in MTA:SE topic and continue the discussion there.

2. Post more code here or debug it yourself. Probably it's not the function's fault but your script's.

Link to comment

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...