-
Posts
1,058 -
Joined
-
Last visited
-
Days Won
1
Everything posted by Saml1er
-
Since the button gets created when you trigger panel évent, thats why onClientGUIClick couldn't get the gui élément ( button ). So WhoamI added a check if ( source == buttons[1] and guiGetVisible (buttons[1]) ) then and used table so source is always defined. This is what he fixed.
-
The wiki tutorial wasn't good enough ?! https://wiki.multitheftauto.com/wiki/Sc ... ing_script Do you really think everyone finds this easy? I posted a tut so people can easily understand how to make a Resource. Can't help people who don't even put an effort to create a Resource. Nevermind. You beat me.
-
I once made a script which gets the Name of the Player died and renders it for 5 sec. server side addEventHandler("onPlayerWasted", getRootElement(), -- This is an Event "onPlayerWasted" function ( ) -- We don't need to name the function because we're inlcuding it in the event ( brackets " ) ") local NubName = getPlayerName (source) -- get the player name who died. local Name2 = "Test" triggerClientEvent ( source, "NameOfnabDied", source, NubName, Name2 ) -- we attach it to source ( the player who died and transfer the data now ( player name ) end ) -- close the bracket here In this script text is visible for the Player who died only. client side HisName = "" -- make a variable and define as empty HisName2 = "" -- another one addEvent ("NameOfnabDied", true ) -- add a new event. addEventHandler("NameOfnabDied", getRootElement(), -- Add the new event handler function ( NubName, Name2) -- add the context so you can receive the data. -- since we want to make it visible on the screen we'll use dxDrawText for this purpose. HisName = NubName.." has died." -- We are doing this because we want the Player Name to exist global Name2 = HisName2.." has died." addEventHandler("onClientRender", root, visibletext ) -- make the text visible with this setTimer ( -- We'll use a timer to stop rendering the text function ( ) removeEventHandler("onClientRender", root, visibletext ) -- make the text invisible by removing the event handler end ,5000, 1 -- This will remove the text after 5 seconds ) -- close the bracket for setTimer end ) -- close the bracket for the event handler local w, h = guiGetScreenSize ( ) -- get the screen size local dx1 = false function visibletext ( ) dxDrawText (HisName , w * 0.375, h * 0.25, w * 0, h * 0, tocolor ( 255, 255, 255, 195 ), 1.0, "bankgothic", "left", "top", false, false, false, true ) dxDrawText (HisName2 , w * 0.375, h * 0.25, w * 0, h * 0, tocolor ( 255, 255, 255, 195 ), 1.0, "bankgothic", "left", "top", false, false, false, true ) -- arrange height and width, right now HisName2 variable Is empty so it will display nothing until You trigger the event then this will render the text. You must arrange dxdraw sizes as many times You want to render the text and add différent évents so you don't define the first variable again and again. end I'm on from mob so can't help you right now. P.S if You want the text visible for everyone then replace source with root in triggerClientEvent.
-
When you go to">Folder and search options>view> scroll down> Now take a screen with snipping tool and post it here also right click on script.lua and click properties and take a screen shot with snipping tool and post it here as well. I got the problem thats why I'm saying this. Anyways also right click on script.lua and rename it script.lua > Now right click on méta.xml and rename it meta.xml
-
Just add this line: triggerClientEvent (player, "EventName",player ) or if you want to pass arguements triggerClientEvent (player, "EventName",player, ADMIN_GROUP, name, tostring ( count ) ) Client side function greetingHandler ( ADMIN_GROUP, name, count ) -- do your stuff end addEvent( "EventName", true ) addEventHandler( "EventName", getRootElement(), greetingHandler )
-
Open your méta.xml and paste This: <meta> <info author="Author" version="1.0" name="Script01" type="script"/> <script src="script.lua" type="server"></script> </meta> This will fix it and if still no Luck then I'll help you in teamviewer.
-
setClipboard is client side function.
-
Allow me to educate you. "Resource not found" has nothing to do with script.lua. "Resource not found" means the Resource Is not loaded or it does not exist. If script.lua was missing then it would have output error in debug something like "script.lua file missing". Common sensé.
-
If you want to get numbers from édit box then use: drugss = tonumber ( guiGetText(editbox) ) This will convert "" into number for example, "10" into 10
-
Type refresh or go to your server and type "/refresh". This will load the resource(You must have admin rights). Also At the top there's an option "Organize">Folder and search options>view> scroll down> and untick "hide extensions for known file types. Then rename the script and meta text documents (change the suffixes to .xml and .lua) There should come up and label, you should click yes and the file type is now changed to .xml and .lua. Its important to do this because this will make it lua file from .txt.
-
How to make a ped action(clientside) visible to everyone?
Saml1er replied to HeavyMetal's topic in Scripting
How do you trigger event from server side? If you want to trigger it for everyone then triggerClientEvent ( root, "eventName", root, arguements ) if you're not triggering from server side then use addEventHandler ("onClientResourceStart", root, functionName) This will make it visible for everyone. If you still can't do it then please share your code here or if its really important to you then send it to me in pm so I can tell you what you're doing wrong. -
I used capitalized letters to get more attention like I got yours.
-
You can create a Col shape with radar if needed for a specific area and that area should be the bank and when a player hits that colshape then use setElementData ( hitElement, "PlayerinBank", true ) and then use another event oncolshapeleave ( or what ever it is ) and set the his element data to false and when you want to give money then get all players by for i,v in pairs (getElementsByType("player") ) do if getElementData ( v, "PlayerinBank" ) == true then -- give him money
-
By leaving the server, it forces him to logout ... Ohh and I thought People stay logged in forever when after they once logged in Lmao.
-
function doTask(thePlayer, taskId, playername, due) if ( hasObjectPermissionTo ( thePlayer, "function.banPlayer" ) ) then if taskId then local due = tonumber ( due ) local player = getPlayerFromName(playername or "") if player then if taskId == 1 and due then due = due * 1000 -- converting duration into seconds setPlayerMuted(player, true) setTimer ( setPlayerMuted, due, 1, player, false ) -- unmuting him after the time is over outputChatBox("You have been muted for "..due.." seconds",player) elseif taskId == 2 then kickPlayer ( player, thePlayer, "You are kicked because of cheating." ) elseif taskId == 3 then banPlayer ( player, thePlayer, serial, "You are banned because of hacking/abusing.", 3600 ) else outputChatBox("Wrong Task id.",thePlayer) end else outputChatBox("Could not find the player.",thePlayer) end else outputChatBox("SYNTAX: /task [id] [victim] ",thePlayer) end else outputChatBox ( "TaskID: You don't have enough permissions", thePlayer ) end
-
He just removed local because when you add local then the variable will exist inside that function only, you cannot use it outside the function nor in any other function so he removed it and now it exists outside the function as well, that's why you're able to destroy it.
-
Hello, so since we learned how to create a resource and thanks to our friend firas for explaining us what is function and how it works. I've decided to continue lua lessons so today I'll teach you guys that what is " outputChatBox " and how it works. But first it's important to know that there are 2 types of script which are " Client side and server side " There's a rule in lua that you can't have client side function in server side and server side function in client side. But still there's a way to make it working we'll learn that in coming lessons right now we'll learn about " outputChatBox " Task: So here's a simple task when we start the script it should say "Welcome to DDC Scripting" in yellow color (rgb = 255 , 255 , 255, 0, ) Solution: outputChatBox ( " Welcome to DDC Scripting ", getRootElement(), 255, 255, 0, true ) so you see you made a simple script. Let's say welcome to scripting lvl 1, you learned how to make a simple script for outputChatBox. You can also have this in red color just change the rgb code ( here's a link for rgb codes ) red color outputChatBox ( " Welcome to DDC Scripting ", getRootElement(), 255, 0, 0, true ) So now I'll explain how this works so when you add your text between " " you add the text and when you add getRootElement(), then you make the text visible for everyone and when you add 255,255,255 this is for the color and we are adding true ( if it is false then you can't add hex code like # FFFF00 between " " for example " #FFFF00Welcome #0000FFto #FFFF00DDC ". so now I want to make a little change in here I want to output some text in chatbox when a player join the server so for that purpose you'll see the code a little different but don't get confused you can read firas topic here for more details. function welcomeMessage ( ) -- welcomeMessage you can modify it with any name you want outputChatBox ("Welcome to DDC server!", source, 255, 255, 0, true) -- you can modify the text between " " also the rgb code end -- the function ends here addEventHandler("onPlayerJoin", getRootElement(), welcomeMessage) -- adding an eventhandler so we can tell the script when to work So was that hard ? let's make something even good. function welcomeMessage () -- welcomeMessage you can modify it with any name you want local Dreddy = "good guy" local Sam = " bad guy" outputChatBox (Dreddy.." Welcome to DDC server! "..Sam, 255, 255, 0, true) end So this is how your meta.xml should look like <meta> <info author="Author" version="1.0" name="Script01" type="script"/> <script src="script.lua" type="server"></script> </meta> So now I have a task for all of you reading this. Make a script saying " You all suck " in red color ( 255, 0, 0 ) onplayerjoin also if you add something like I did for example local Sam = "bad guy" then you might get some points ;D NOTE: All these scripts are in server side, I'll add client side later. Client side. function welcomeMessage () -- welcomeMessage you can modify it with any name you want local Dreddy = "good guy" local Sam = " bad guy" outputChatBox (Dreddy.." Welcome to DDC server! "..Sam, 255, 255, 0, true) end addEventHandler("onClientPlayerJoin", getRootElement(), welcomeMessage) -- so you see, we changed here "onPlayerJoin" to "onClientPlayerJoin" because it's client side. Now you must change this line in your meta.xml for client side. <script src="script.lua" type="server"></script> to Some info by Karevan from DDC: Why are we using type"client" for this script? It's because it's client side and you must tell meta.xml that the script is in client side or the script won't work so better change it. The local "keyword" can be used or not, that is correct. But it's not meant to be used whenever you want to not "get confused". It has its uses. When you use local before the name of a variable, you are making that variable exist only WHITHIN that block of code and its childs, but not parents. So for example: if you have a local variable inside a function, that variable will not exist outside that function. But, if you declare a variable WITHOUT using local, that variable will then exist outside the function, and you will be able to use it on any other functions. local is used in a few more ways, but that's all you need to know for now. Now you know that a variable is a keyword which stores a value virtually, you need to know that such value can either be a number, a string (text), or more complex things like tables or objects/elements. In the example, the values are strings. When you want to represent a string, you always have to use quotes around it. It can be either ' or ", but both need to be the same. The actual difference between client and server, explained basically: The scripts you run on the server, run on a machine which is common for all players, that machine synchronizes all players and shares their information. Server scripts run just once and on one machine.[/li] The scripts you run on a client run on the PC of each player. The client "talks" with the server to know about the other players, where they are, what they do, etc... Client scripts run once on every player. This means you can have the same script running in different ways on different machines, with different players. But having the same code.[/li] So, while things that happen in server happen at the same time for all connected clients (or players), things that happen on client happen in a different time for each client (or player). Updated 21.02.2014
-
Its an Event ( race event ). You can also change the 'LoadingMap' with following states and the 2 parameters. Parameters string newState, string oldState newState: the new state oldState: the old state Possible states: undefined NoMap LoadingMap PreGridCountdown GridCountdown Running MidMapVote SomeoneWon TimesUp EveryoneFinished PostFinish NextMapSelect NextMapVote ResourceStopping More info can be found here: https://wiki.multitheftauto.com/wiki/Resource:Race
-
function triplo() removeEventHandler ( "onClientPlayerWasted", getLocalPlayer(), triplo ) setTimer ( function () triggerServerEvent, "ClientHaveLevels", getLocalPlayer() ) addEventHandler ( "onClientPlayerWasted", getLocalPlayer(), triplo ) end, 15000,1, true ) end addCommandHandler ("triplo", triplo) addEventHandler ( "onClientPlayerWasted", getLocalPlayer(), triplo )
-
Yeah, its a typo. YOU WIN *sarcasm*
-
I removed brackets because I don't like to use unnecessary crap in script. Brackets is not a requirement in such cases. Brackets are compulsory for tables, event handlers, command handlers and functions and when calling them. Test this script, you'll see it works.
-
Got the problem getTeamName addCommandHandler( "infernus", function () if getTeamName(getPlayerTeam(LocalPlayer)) == "New World Order") then txd = engineLoadTXD ( "infernus.txd" ) engineImportTXD ( txd, 411 ) dff = engineLoadDFF ( "infernus.dff", 411 ) engineReplaceModel ( dff, 411 ) end end )
-
Your script should work fine. Post your meta.xml code here.
-
What for? setAccountData is server side function. Well you want a single GUI to work for everyone?
-
You can use elseif statement instead of adding different functions.