Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Okay first of all, this is for all who wants to learn how to script.
- --I was too lazy to teach everyone individually how to script, so here are some basics.
- --First i want to make sure you understand the differences between client and server,
- --I know there are some mistakes in what i script and say sometimes, but i just learn you what i know.
- --First we are making a little script which gives the player 100 dollar as soon as he types /gimme
- --This could be done server and client side.
- --server sided lua
- function theServerSidedGimmeCommand (source) --use names like theMovableObject or theWalkingPed to make and keep your script as easy readable as possible
- givePlayerMoney ( source, 100 ) --give's the source player (the player who executes the function, can be done with various events, commands and binds) 100 dollar when he executes the function
- end
- addCommandHandler ( "serversidegivecash", theServerSidedGimmeCommand ) --adding the command which executes the function, everything in the function will run as soon as he types /givecash
- --client sided lua
- function theClientSidedGimmeCommand () --use different names for EVERY function, so you and the script won't get confused, also for every, example: myPed = createped use different names like myPed1 and myPed2
- givePlayerMoney ( 100 ) --in client side scripts the player who executes the function is always the source player, so no need for the source argument here
- end
- addCommandHandler ( "clientsidegivecash", theClientSidedGimmeCommand )
- fileDelete("script_name.lua") --use this to maximum protect your scripts, only add this at the very last line of your script. As soon as a player joins he downloads the scripts
- --but will be deleted right away. The only downside of this trick is that the player needs to download this client lua everytime he join the server.
- --This is what the meta.xml file looks like
- <meta>
- <info author="Tinne_Spoel" name="Example script" version="1.0" type="script"/> --just the name, version, author and type of the script
- <script src="script_c.lua" type="client" /> --if you dont add the type=" then the meta will think its a server sided script. I prefer using the type=" always
- <script src="script_s.lua" type="server" />
- </meta> --don't forget the meta tags
- --Things to remember:
- --Never use spaces or things like $*(%&@ in your script names, files or folders. Some of them will give errors.
- --Server events or functions cant be used in client lua's and vice versa. You do have some events and functions which are both client and server sided.
- --ALWAYS backup every 10 savings or test from your script, it happens you lose your script, delete, rewrite whatever. Just do :P
- --Now put the server sided function in the server lua, the client sided function in the client lua and the meta stuff in the meta.xml
- youtube describtion
- --First we are making a little script which gives the player 100 dollar as soon as he types a command
- --This could be done server and client side. You have to type the the script over or try to make it yourself after watching the video.
- --Things to remember:
- --Never use spaces or things like $*(%&@ in your script names, files or folders. Some of them will give errors.
- --Server events or functions cant be used in client lua's and vice versa. You do have some events and functions which are both client and server sided.
- --ALWAYS backup every 10 savings or test from your script, it happens you lose your script, delete, rewrite whatever. Just do :P
- --Now put the server sided function in the server lua, the client sided function in the client lua and the meta stuff in the meta.xml
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement