Jump to content

Script help


jkub

Recommended Posts

I got the bank script from the resources page and I want to make it to where you can login to your own player account on my server and you can keep track of your bank account. like you can save your money to your account and when you come back the next day youl still be able to have the money you had the day b4... sort of like an rpg>> how would i do that?

Edited by Guest
Link to comment
  • Replies 109
  • Created
  • Last Reply

Top Posters In This Topic

I got the bank script from the resources page and I want to make it to where you can login to your own player account on my server and you can keep track of your bank account. like you can save your money to your account and when you come back the next day youl still be able to have the money you had the day b4... sort of like an rpg>> how would i do that?

Ehm... Do you know anything about XML, tables or in combination? XML is really good for saving things, but slow. Tables store things, but only for one session.

This means: Make a few GUI's, store their deposited and withdrawn money in tables and write it in at the last moment. Just an example.

But IF you need to learn new things anyway, I would (*ahem*, the rest of the forum members would) recommend you to save it in SQL. Or MySQL. But I'm not an expert on (My)SQL, so don't ask me about that... :S

I don't know if you know how any of those things work? If not, do you know how it works to save all the data temporarily? Be sure you know how to do that, since you'll need to know that to be able to make it work dang fast. ;)

(combination of my method and (My)SQL FTW! xD)

Link to comment

Im sorry i didnt do this earlier, i dont wanna post multiple topics for single questions but can you also help me step by step on how to output a chat message alerting everyone when a player has pulled out a disallowed wepon such as a minigun?

i would use both events and functions right

and which function or event would I use to monitor players weapons

and I know already that putting the outputchatbox command right after the getweaponline will not work because they have to be linked somehow.

Link to comment

How you alert of a minigun? Fairly simple, only finding out is a bit harder:

function weaponSwitchDisableMinigun ( previousWeaponID, currentWeaponID ) --when a player switches his weapon 
  
if currentWeaponID == 38 then --if the weapon ID is minigun 
     toggleControl ( source, "fire", false ) --disable the fire button 
else --otherwise 
     toggleControl ( source, "fire", true )  --enable it 
end 
--add an event handler for onPlayerWeaponSwitch 
addEventHandler ( "onPlayerWeaponSwitch", getRootElement(), weaponSwitchDisableMinigun ) 

This is an example from the wiki, from the page onPlayerWeaponSwitch

Let's modify it for your use shall we?

function weaponSwitchDisableMinigun ( previousWeaponID, currentWeaponID ) 
     if currentWeaponID == 38 then 
          outputChatBox ( "Warning! You now have an illegal weapon in your hands! Shoot and you'll be banned!", source, 255, 0, 0 ) 
     end 
end 
addEventHandler ( "onPlayerWeaponSwitch", getRootElement(), weaponSwitchDisableMinigun ) 

That should work. ;)

Link to comment
thanks man that worked like a charm! :D

If you don't mind, I would recommend you to look around the forums for all kinds of commands and examples, and expanding your knowledge, and then making a start. So you can prove you can script. If we just give you the piece of script, you won't learn from it. ;)

Link to comment
actually man this may sound ironic but i have actually been looking around. Ive looked at alot of things on the wiki lol.

Yes, looking and remembering are simple. But, did you actually understand them? That's the major factor! :D

Anyway, I'll put on a little example script soon. It'll be extremely simple, so you might want to look at it and make your own, with mine as an example. (or someone else must post something in the meantime... =/)

But I'm going to play Red Alert 3 Beta first! ^^

Link to comment

what if i wanted to functions on the minigun pull out like have the warning message and a loss of health for the culprit, how would the 2 functions work in unison?

wat command or function would join both functions together would it be and or also?

Link to comment

at first i got a mini myself to test it with others in the server and they said they didnt see the message.

but later ithink i ended up fixed it. I took an outputchatbox function with a getelementroot thingy. the one b4 didnt have it. I dont know why that would make it server side but i tested the changed script and this time they said they did see it. so i guess it worked

Link to comment

:)

Its because of the source used in outputChatBox function. It makes it only visible to the player who switched their weapon.

Like this: outputChatBox ( string text, [ element visibleTo=getRootElement(), int r=255, int g=255, int b=255, bool colorCoded=false ] )

visibleTo: This specifies who the chat is visible to. Any players in this element will see the chat message. See visibility.

http://development.mtasa.com/index.php? ... putChatBox

Link to comment
ohh so thats why. thanks :D

im gonna study this :~ more and try to make more since of it>>>

The small details count. ;)

I have made a small start, but had to leave the house for quite some time unexpected... So the start is... Creating a file... And... Eh...

Naming the file... xD

Link to comment
ill do some more studying on this soon as i get home lol

I used to do everything on notepad anyway, even switching to an actual lua editor helped a bit lol. how ironic

You didn't use a good editor? Lol that'd explain things... xD

Anyway, I think that if you learn everything step-by-step from the tutorials, (WITH the editor xD) then you'll be able to answer your first question yourself. ;)

Link to comment

if you have $500 and you use givePlayerMoney, it will plus it on so say you do givePlayerMoney $250 it will be $500 + $250 = $750. Same but opposite for takePlayerMoney.

setPlayerMoney doesn't and it will set the money as whatever you say so if you do $5000 and have on you $750 it will put it at $5000. If it was givePlayerMoney it would be $5750.

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