-
Posts
1,058 -
Joined
-
Last visited
-
Days Won
1
Everything posted by Saml1er
-
You can use "onClientPlayerDamage" instead of using onClientRender or timers.
-
Yea, great idea! But... I can't change Alpha of object when I aiming. I'm so stupid. >< Don't punish yourself, you're just new and I like people who put their efforts in scripting. This is a client side script function targetingActivated ( target ) if target and getElementType (target) == "object" then setElementAlpha(target, 0) -- 0 will make it invisible end end addEventHandler ( "onClientPlayerTarget", getRootElement(), targetingActivated ) Can you please explain more what exactly are you trying to do?
-
Server-side: if weapon1 == "M95 BARRETT" then m95a = createObject(1900, x,y,z) attachElementToBone(m95a, source, 12, 0,0,0,0,-90,0) triggerClientEvent (source, "hiderweap", source, m95a) end Client-side: function hiderweap(ident) ?????????????? end addEvent("hiderweap", true) addEventHandler("hiderweap", getRootElement(), hiderweap) It's all I have... This does not work with all entities - vehicles, players and objects are exempt.(с) wiki Ow, why don't you create it in client side then and set its alpha to 0?
-
setElementVisibleTo
-
This is server side script and you're running it in client side? That won't work. Modify its type as server side script in your meta.xml.
-
A little piece of code from my lobby script: local EventNHandlers = { } local _functions = { } _addEventHandler = addEventHandler addEventHandler = function (eventName, attachedTo, handlerFunction) if handlerFunction then if event == "onClientPreRender" then setTimer( function() handlerFunction() end,2000,1) elseif event == "onClientRender" then setTimer( function() handlerFunction() end,2000,1) elseif event == "onClientHUDRender" then setTimer( function() handlerFunction() end,2000,1) else if _addEventHandler(eventName, attachedTo, handlerFunction) then EventNHandlers[#EventNHandlers+1] = {eventName, attachedTo, handlerFunction} end end if not _functions[handlerFunction] then _functions[handlerFunction] = true -- set it to nil when you want to remove the event handler end end end --- If you want to remove then then loop through the tables ^ for k,v in ipairs(EventNHandlers) do removeEventHandler(EventNHandlers[k][1],getRootElement(),EventNHandlers[k][3]) end for k,v in pairs(_functions) do k = nil -- set the function to nil now end Remember this will insert all event handlers in your current script (file).
-
Since I thought he didn't define coordinates and that "if not statement" for spx which wasn't set to true even after he sets the rotation and position of the element player so I thought its a mess but if the coordinates are defined globally then everything should work fine.
-
A guy who owns a whole server but can't buy scripts or script himself but instead he depends on other scripters to script for him for free? Wake up from this bad dream.
-
Spx,y,z is not defined anywhere in the script. Make sure you add this line: local spx,spy,spz = getElementPosition (localPlayer) Still this won't help, your code is a total mess. I'll help ya later but I know someone might fix your code till that time.
-
Gang is not a table, its a string. local tab = { } local gang = getAccountData(getPlayerAccount(source)),"safr.Group") -- use getElementData since getAccountData is server side function local text = guiGetText(memo) tab[gang] = tostring (text)
-
The best thing about table is that you can insert almost everything in it and there are many ways to insert, it can be column, rows etc. You always don't really need to use table.insert but instead you can do it like this as well: myTable.text2 = "And here comes the second one." -- this dot will help in inserting the text. This inserting method is equivalent to: myTable["text2"] = "And here comes the second one."
-
its the text you inserted. for example, local myT = { } a = "Hello, MTA players" b = "Welcome to lua scripting" table.insert (myT, b) table.insert (myT, a) -- loop local Cash = tonumber ( getElementData (localPlayer, "cash") ) -- you must use setElementData before this ^^ for k,v in ipairs (myT) do if v == "Hello, MTA players" and Cash > 50 then -- some code here elseif v == "Welcome to lua scripting" and Cash < 50 then -- some code here end end Well if you're doing this client side then use setElementData.
-
You need to loop through table. for k,v in ipairs (table) do if v == "Text" then print (v) end end
-
Just post a single function you are saving it. If you can't post it then only god can help you. ;D
-
The part where you are saving data.
-
Use castillo's code that exp table part. What's hard to understand in that? >.>
-
Dude, my lobby script load maps using XML functions and it doesn't lagg at all and about the gang thing, what do you use to save gang names, elementData or accountData ?
-
Then use xml, I'll post an example of xml functions within 2 hours.
-
SQL is the best but anyway I'm too lazy to write examples from my mobile So I found a script in one pf my old post: local mesg = "" addCommandHandler("say", function (thePlayer,_,msg) local time = getRealTime() local hours = time.hour local minutes = time.minute mesg = mesg.." [:"..hours..":"..minutes.."] "..getPlayerName ( thePlayer )..": "..msg end ) function LogTimer () if mesg ~= "" then File = fileOpen ("logs.txt") if File then fileWrite (File, mesg ) else fileCreate ("logs.txt") File = fileOpen ("logs.txt") fileWrite (File, mesg ) end fileClose (File) mesg = "" end end setTimer (LogTimer, 30000, 0 ) I haven't tested This but I hope this will help you.
-
Yeah, my bad. I have a question. When you define local Player as source in évent handler and when you use other functions inside it then Player élément has to defined again for other functions (like getElementHealth etc)? I'm asking this because I've never tested it in that way but I saw it on wiki several times.
-
Client side. function healPlayerOnHit_Handler (attacker, weapon, bodypart) if(getElementType(attacker) == "player") and isPlayerInTeam(attacker,"Medic") then if weapon == 41 then cancelEvent() if not targetCurrentHealth >= 100 then local targetCurrentHealth = getElementHealth ( ) local newHealth = 100 - targetCurrentHealth setElementHealth( newHealth) local randomCash = math.random ( 25, 50 ) givePlayerMoney(theAttacker,randomCash) end end end addEventHandler("onClientPlayerDamage", getLocalPlayer(), healPlayerOnHit_Handler ) Don't forget to modify your méta.xml.
-
SolidSnake just posted a check and I already know that it was just the first 5-6 lines. The script didn't work for him because he placed "end" statement at wrong place. Also there shouldn't be more than 2 ends because if there already exists and "if" statement and when you use "if not" then you don't need to add more ends.
-
Strange, the code seems fine to me. e.e addEventHandler ( "onClientMarkerHit", resourceRoot, function ( hitElement ) if hitElement == localPlayer and getElementType (source) == "marker" then outputChatBox ("Well it works ^^", getRootElement()) if ( not getElementData ( source, "isSWATMarker" ) ) then return end end -- < -- < -- remove this if the script doesn't work.
-
Thank you guys, it works perfectly! final result: function RaceMode.endMap() if stateAllowsPostFinish() then for i, player in ipairs(getElementsByType("player")) do fadeCamera ( root, false, 3.5, 0, 0, 0 ) -- fades out in 3.5 secs. end gotoState('PostFinish') local text = g_GameOptions.randommaps and 'Next map starts in:' or '' Countdown.create(4, RaceMode.startNextMapSelect, text, 255, 255, 255, 2, 0 ):start() triggerEvent('onPostFinish', g_Root) end end If you're using root then you don't need to loop through all players, here: function RaceMode.endMap() if stateAllowsPostFinish() then fadeCamera ( root, false, 3.5, 0, 0, 0 ) -- fades out in 3.5 secs. gotoState('PostFinish') local text = g_GameOptions.randommaps and 'Next map starts in:' or '' Countdown.create(4, RaceMode.startNextMapSelect, text, 255, 255, 255, 2, 0 ):start() triggerEvent('onPostFinish', g_Root) end end
