Lergen

Members
  • Content Count

    31
  • Joined

  • Last visited

Everything posted by Lergen

  1. Lergen

    Script error?

    Thanks for the tip. So after trying that code and starting the script, I get barraged with error messages when I start the video: "bad argument at 'dxDrawimage' [expected material at argument 5, got nil]" and "bad argument at 'loadbrowserURL' [expected browser at argument 1, got nil]" Thinking the problem was with it being that I was using a video file rather than a video URL, I tried the YouTube example on the wiki function renderBSOD() local x, y = guiGetScreenSize() playVideo (0, 0, x, y, "https://www.youtube.com/embed/rRjY8SOZ9Uo?autoplay=1&showinfo=0&rel=0&controls=0&disablekb=1", 90600, false, false) -- bs.png for win7/XP, bs2.png for Win10/modern BSOD screen. change at will end However doing it this way causes the screen to go white and crashes MTA.
  2. Lergen

    Script error?

    Hello. I made a slight modification to Dutchman's BSOD script to play a video rather than display an image, but I'm receiving an error on line 5: "attempt to call global 'playVideo' (a nil value). Can anyone offer some advice as to what's wrong here? I'd greatly appreciate it. local bsodTimer function renderBSOD() local x, y = guiGetScreenSize() playVideo (0, 0, x, y, "bs2.mp4", 90600, false, false) -- bs.png for win7/XP, bs2.png for Win10/modern BSOD screen. change at will end function performPrank(thePlayer) if (thePlayer == getLocalPlayer()) then if (isTimer(bsodTimer)) then killTimer(bsodTimer) end for i = 1, 100 do setWorldSoundEnabled(i, false) end setAmbientSoundEnabled("general", false) setAmbientSoundEnabled("gunfire", false) setInteriorSoundsEnabled(false) showChat(false) setPlayerHudComponentVisible("all", false) setSoundVolume(sound, 0.5) removeEventHandler("onClientRender", getRootElement(), renderBSOD) addEventHandler("onClientRender", getRootElement(), renderBSOD) bsodTimer = setTimer( function() removeEventHandler("onClientRender", getRootElement(), renderBSOD) showChat(true) setPlayerHudComponentVisible("all", true) setAmbientSoundEnabled("general", true) setAmbientSoundEnabled("gunfire", true) setInteriorSoundsEnabled(true) resetWorldSounds() end,420000,1) end end addEvent("showBSODToPlayer", true) addEventHandler("showBSODToPlayer", getRootElement(), performPrank)
  3. Thanks so much for your help! I hate to ask again, but I'm still a bit confused as to where to go from here, as removing those lines still seems to present another error: addEventHandler("onPlayerLogin", root, function(thePlayer, command) local account_name = getAccountName(player_account) if not isObjectInACLGroup("user."..account_name, aclGetGroup("Admin")) and isObjectInACLGroup("user."..account_name, aclGetGroup("Moderator")) then return false end local img = ":admin/client/images/flags/us.png" local country_code = "US" setElementData(thePlayer, "Country", {img, country_code}) return true end ) This now gives me an error on the 4th line: "attempt to concatenate local 'account_name' (a boolean value). Any ideas?
  4. Hello. I've been attempting to modify the scoreboard so that when a moderator/admin logs in, they're automatically assigned the region/flag of the country specified in the Lua script. addEventHandler("onPlayerLogin", root, function(thePlayer, command) local player_account = getPlayerAccount(thePlayer) if not player_account then return false end local account_name = getAccountName(player_account) if not isObjectInACLGroup("user."..account_name, aclGetGroup("Admin")) and isObjectInACLGroup("user."..account_name, aclGetGroup("Moderator")) then return false end local img = ":admin/client/images/flags/us.png" local country_code = "US" setElementData(thePlayer, "Country", {img, country_code}) return true end ) Unfortunately, I seem to be getting an error on the third line: "Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got account]. Can anyone offer any advice on what's going wrong here? Making it a command handler instead of an event handler seems to work, for some reason, but I need it to be on logon rather than through player command.
  5. Hello. I've been trying to make a script so that when a player types the command handler, it draws an image above their head for a few seconds before removing itself. Do you guys have any advice for going about this? I've tried referencing a few resources that do something similar, but still can't get it working.
  6. That was exactly what I needed. Thank you.
  7. Hello. I've had a bit of trouble trying to figure out how to do something. I'm trying to make it so when a player enters water (swimming) it drains his health until he exits it. What's the best way to go about doing this? I've looked around but haven't been able to find any reference points for this. I'd greatly appreciate any help!
  8. That did the trick. Thank you guys!
  9. Yeah, that's what I'm trying to do, make sure the attacker isn't the person who died. I tried this, but still couldn't get it working. Am I forgetting something here or doing something wrong? function player_Wasted(ammo, attacker, weapon, bodypart) if isElement(source) and isElement(attacker) and getElementType(attacker) == "player" then if attacker ~= source then end else if(getPlayerTeam(source) == getTeamFromName(team_criminals) or getPlayerTeam(source) == getTeamFromName(team_lnr)) or getPlayerTeam(source) == getTeamFromName(team_gangsters) and (getPlayerTeam(attacker) == getTeamFromName(team_criminals) or getPlayerTeam(attacker) == getTeamFromName(team_lnr)) or getPlayerTeam(attacker) == getTeamFromName(team_gangsters) and getElementData(source, "Group") ~= getElementData(attacker, "Group") and not isTimer(cooldown[attacker]) and getElementData(source,"isInTurf") then local victim_money = getPlayerMoney(source) if victim_money > money_pickpocket_max then victim_money = money_pickpocket_max elseif victim_money < money_pickpocket_min then victim_money = money_pickpocket_min end local money = math.floor(victim_money*(math.random(10,25)/25))
  10. Hello again. I've been playing around with the GTW scripts as they're open source, but I discovered a small problem. Whenever an enemy player dies inside a turf, the player who got the kill receives some money. However, a player can also kill themselves with a grenade or vehicle and still receive the money as if they had killed an enemy. Is there any way to check that the player who just died wasn't themself so they won't receive payment? function player_Wasted(ammo, attacker, weapon, bodypart) if isElement(source) and isElement(attacker) and getElementType(attacker) == "player" then if(getPlayerTeam(source) == getTeamFromName(team_criminals) or getPlayerTeam(source) == getTeamFromName(team_lnr)) or getPlayerTeam(source) == getTeamFromName(team_gangsters) and (getPlayerTeam(attacker) == getTeamFromName(team_criminals) or getPlayerTeam(attacker) == getTeamFromName(team_lnr)) or getPlayerTeam(attacker) == getTeamFromName(team_gangsters) and getElementData(source, "Group") ~= getElementData(attacker, "Group") and not isTimer(cooldown[attacker]) and getElementData(source,"isInTurf") then local victim_money = getPlayerMoney(source) if victim_money > money_pickpocket_max then victim_money = money_pickpocket_max elseif victim_money < money_pickpocket_min then victim_money = money_pickpocket_min end local money = math.floor(victim_money*(math.random(10,25)/25)) givePlayerMoney(attacker, math.floor(money))
  11. Ahhh, that's unfortunate then. I appreciate the heads-up though, thanks!
  12. Thanks! This probably sounds dumb but how would you check that a player selected an animation on the client if it's handled server-side? I'm guessing getPedAnimation would be used.
  13. I looked around a bit, but couldn't find an answer for this. When using https://wiki.multitheftauto.com/wiki/SetPedWalkingStyle is there any way to change the speed a player sprints at while using it? A sprinting ped animation is probably slower than CJ's walking speed. So in other words, when someone is using a ped walking style, is it possible to let them sprint as fast as CJ? I'd greatly appreciate any help.
  14. Lergen

    Gang color blips

    A little over a month of trying different things but I've still had no luck on this. Everything I've tried just results in the same dead-end: It won't work unless I restart the resource when a new player joins. I have no idea what's going wrong in the script.
  15. That did the trick, thanks! I tried this out, but I couldn't get it working. I'll try tinkering with it though. What's the difference between TickCount and Timers that make it more optimized?
  16. I have this script here that lets a player spawn a vehicle. I tried adding a timer to it so that there's a two minute cooldown before spawning another vehicle, it's supposed to be on a player-by-player basis but it's still global. Can someone tell me what I'm doing wrong? I'd really appreciate it. local spawnDelayTime = 120000 -- delay time in ms local spawnTimer = { } function carSpawn () if isTimer(spawnTimer[source]) then local timeleft = math.ceil( getTimerDetails(spawnTimer[source])/1000 ) -- Get seconds left from timer if timeleft then local secondString = " second" if timeleft > 1 then secondString = " seconds" end outputChatBox("You may spawn your vehicle again in "..tostring(timeleft)..secondString) return false end end if not (isGuestAccount (getPlayerAccount (source))) and not (isPedInVehicle(source)) then spawnTimer[source] = setTimer(function() spawnTimer[source] = false end,spawnDelayTime,1)
  17. Hello, I'm fairly new to this. I'm trying to learn to convert the GTWTurf system (https://github.com/404rq/GTW-RPG/tree/master/[resources]/GTWturf) to use Castillo's gang system (https://community.mtasa.com×/index.php?p=resources&amp;s=details&amp;id=1514). I think I have it working, but the turf colors won't update to use the exported gang colors. What am I doing wrong? I'm guessing the problem is in this: local playerGang = getElementData (player, "gang" ) if ( playerGang ) then local r, g, b = unpack ( getGangColor ( playerGang ) ) setRadarAreaColor(area, tonumber(r), tonumber(g), tonumber(b), 175) setRadarAreaFlashing(area, false) setElementData(theTurf, "currAttacker", nil) dbExec(db, "UPDATE turfs SET owner=?, red=?, green=?, blue=? WHERE X=? AND Y=?", gang, r, g, b, tonumber(getElementData(colCuboid,"posx")), tonumber(getElementData(colCuboid,"posy"))) end end, time_to_capture*1000, 1) end end I'm using Sasuke's turfsystem, which does use Castillo's gang system, as a reference: function ( player ) if turfElement[source] and source == turfElement[source][1] then local turf,area,id = unpack( turfElement[source] ) local playerGang = getElementData ( player, "gang" ) local turfGang = executeSQLQuery("SELECT GangOwner FROM Turf_System WHERE Turfs=?", "Turf["..tostring(id).."]" ) if ( turfGang[1].GangOwner == playerGang ) then outputChatBox( messages[2]:format( turfGang[1].GangOwner or "None" ), player, 0, 255, 0, false ) else local playerGang = getElementData ( player, "gang" ) setElementData( source, "warTurf", playerGang ) if ( isTimer ( turfTimer[source][1] ) ) then if isTimer( turfTimer[source][2] ) then killTimer( turfTimer[source][2] ) end return end if ( playerGang ) then local r, g, b = unpack ( getGangColor ( playerGang ) ) -- local r, g, b = 255, 255, 255 setRadarAreaFlashing ( area, true ) if turfGang[1].GangOwner ~= "Nadie" then outputChatBox( messages[3]:format( turfGang[1].GangOwner ), player, 0, 255, 0, false ) else outputChatBox( messages[4], player, 0, 255, 0, false ) end turfTimer[source][1] = setTimer ( function ( ) local players = getGangPlayersInTurf ( turf, playerGang ) setRadarAreaColor ( area, tonumber(r), tonumber(g), tonumber(b), 175 ) for _, player in ipairs ( players ) do outputChatBox( messages[5], player, 0, 255, 0, false ) triggerClientEvent(player, "onTakeTurf", player) givePlayerMoney ( player, 4000 ) executeSQLQuery("UPDATE Turf_System SET GangOwner=?,r=?,g=?,b=? WHERE Turfs=?", playerGang, tonumber(r), tonumber(g), tonumber(b), "Turf["..tostring(id).."]" ) -- setElementData ( turf, "getTurfGang", playerGang ) end setRadarAreaFlashing ( area, false ) end ,120000, 1) end end end end In the debug I get badargument at getelementdata [expected element at argument 1, got nil]. I'd greatly appreciate any advice.
  18. Lergen

    Gang color blips

    That's the problem, it isn't a table and I can't modify it because the code is compiled. https://community.mtasa.com/index.php?p=resources&amp;s=details&amp;id=1514 The reason I'm looking at turf system is because it's somehow still managing to call the colors despite that (when a player takes over a turf, it changes to their gang's color). That's why I'm starting to think the SQL is what's allowing that script to call the colors and why mine isn't working. I don't know what else the problem could be, but I don't know. I could be way off here.
  19. Lergen

    Gang color blips

    I'm almost positive I've figured out why it's not calling the colors. It's the SQL - I didn't add it to my script. This is what the entire Turf script looks like that I've been using for reference: addEventHandler("onResourceStart", resourceRoot, function() executeSQLQuery("CREATE TABLE IF NOT EXISTS Turf_System ( Turfs TEXT, GangOwner TEXT, r INT, g INT, b INT)") -- local check = executeSQLQuery("SELECT * FROM Turf_System" ) if #check == 0 then for i=1,#turfPos do executeSQLQuery("INSERT INTO Turf_System(Turfs,GangOwner,r,g,b) VALUES(?,?,?,?,?)", "Turf["..tostring(i).."]", "Nadie", 0, 255, 0) end elseif #check > 1 then for i = #check, #turfPos do executeSQLQuery("INSERT INTO Turf_System(Turfs,GangOwner,r,g,b) VALUES(?,?,?,?,?)", "Turf["..tostring(i).."]", "Nadie", 0, 255, 0) end end for i,v in ipairs(turfPos) do local sqlData = executeSQLQuery("SELECT * FROM Turf_System WHERE Turfs=?", "Turf["..tostring(i).."]") local turfCol = createColCuboid(unpack(v)) setElementData(turfCol, "getTurfGang", sqlData[1].GangOwner) local turfArea = createRadarArea(v[1], v[2], v[4], v[5], sqlData[1].r, sqlData[1].g, sqlData[1].b, 175) turfElement[turfCol] = {turfCol, turfArea, i} turfTimer[turfCol] = {} end outputDebugString( messages[1] ) end ) addEventHandler ('onPlayerLogin', root, function ( player ) local playerGang = getElementData ( player, "gang" ) if ( playerGang ) then local r, g, b = unpack ( getGangColor ( playerGang ) ) setPlayerNametagColor(player, tonumber(r), tonumber(g), tonumber(b)) end end ) addEventHandler ( "onColShapeHit", root, function ( player ) if turfElement[source] and source == turfElement[source][1] then local turf,area,id = unpack( turfElement[source] ) local playerGang = getElementData ( player, "gang" ) local turfGang = executeSQLQuery("SELECT GangOwner FROM Turf_System WHERE Turfs=?", "Turf["..tostring(id).."]" ) if ( turfGang[1].GangOwner == playerGang ) then outputChatBox( messages[2]:format( turfGang[1].GangOwner or "None" ), player, 0, 255, 0, false ) else local playerGang = getElementData ( player, "gang" ) setElementData( source, "warTurf", playerGang ) if ( isTimer ( turfTimer[source][1] ) ) then if isTimer( turfTimer[source][2] ) then killTimer( turfTimer[source][2] ) end return end if ( playerGang ) then local r, g, b = unpack ( getGangColor ( playerGang ) ) -- local r, g, b = 255, 255, 255 setRadarAreaFlashing ( area, true ) if turfGang[1].GangOwner ~= "Nadie" then outputChatBox( messages[3]:format( turfGang[1].GangOwner ), player, 0, 255, 0, false ) else outputChatBox( messages[4], player, 0, 255, 0, false ) end turfTimer[source][1] = setTimer ( function ( ) local players = getGangPlayersInTurf ( turf, playerGang ) setRadarAreaColor ( area, tonumber(r), tonumber(g), tonumber(b), 175 ) for _, player in ipairs ( players ) do outputChatBox( messages[5], player, 0, 255, 0, false ) triggerClientEvent(player, "onTakeTurf", player) givePlayerMoney ( player, 4000 ) executeSQLQuery("UPDATE Turf_System SET GangOwner=?,r=?,g=?,b=? WHERE Turfs=?", playerGang, tonumber(r), tonumber(g), tonumber(b), "Turf["..tostring(id).."]" ) -- setElementData ( turf, "getTurfGang", playerGang ) end setRadarAreaFlashing ( area, false ) end ,120000, 1) end end end end ) addEventHandler ( "onColShapeLeave", root, function( player ) if turfElement[source] and source == turfElement[source][1] then if isTimer( turfTimer[source][1] ) then local aGang = getElementData( source, "warTurf" ) local ps = getGangPlayersInTurf( source, aGang ) if #ps == 0 then outputChatBox( messages[6], player, 255, 0, 0 ) turfTimer[source][2] = setTimer( function(source, aGang) if isTimer(turfTimer[source][1]) then killTimer(turfTimer[source][1]) end setRadarAreaFlashing(turfElement[source][2], false) for _, v in ipairs( getElementsByType("player") ) do if getElementData(v, "gang") == aGang then outputChatBox(messages[7], v, 255, 0, 0) end end end , 20000, 1, source, aGang) end end end end ) function getGangPlayersInTurf( turf, gang ) -- element, string if turf and gang then local players = getElementsWithinColShape ( turf, "player" ) local gPla = {} for _, v in ipairs( players ) do if getElementData(v, "gang") == gang then table.insert(gPla, v) end end return gPla end end function getGangColor(gangName) return exports[ "gang_system" ]:getGangData ( gangName, "color" ) end I'm still learning, but I think what's happening is that it's getting the gang colors and turning them into the table that's needed for the unpack (hence the "bad argument #1 to 'unpack' (table expected, got boolean)) error in my own script. But I don't know where to go from here. Do I modify the SQL so that it just gets colors with none of the turf stuff or is there a simpler way of doing this?
  20. Lergen

    Gang color blips

    Still working on this, but no luck. What changes in a restart that would make it work when it wouldn't before? I'm starting to think it's the event 'onPlayerJoin' that may be messing it up somehow.
  21. Lergen

    Gang color blips

    OK. Possibly(?) some progress. local r,g,b = exports.gang_system:getGangData ( gangName, "color" ) Returns: "bad argument at 'setPlayerNametagColor' [expected number at argument 2, got nil]. using it this way, it can't get colors from the gang system. I feel like reiterating that this function joinHandler(player) if not player then player = source end local gangName = getElementData(player, "gang") local r, g, b = unpack(getGangColor(gangName)) setPlayerNametagColor(player, tonumber(r), tonumber(g), tonumber(b)) g_PlayerData[player] = { vehicles = {}, settings={} } g_PlayerData[player].blip = createBlipAttachedTo(player, 0, 2, tonumber(r), tonumber(g), tonumber(b)) addEventHandler("onFreeroamLocalSettingChange",player,onLocalSettingChange) if getOption('welcometextonstart') then outputChatBox('Welcome to Freeroam', player, 0, 255, 0) end end addEventHandler('onPlayerJoin', root, joinHandler) actually -works- it get the gang colors, and displays them like I want it to, the only thing is that freeroam needs to be restarted for it to work. It outputs only this one error when a player connects: "bad argument #1 to 'unpack' (table expected, got boolean). Could this be the problem?
  22. Lergen

    Gang color blips

    Thanks. I got "Bad argument at setPlayerNametagColor [Expected number at argument 2, got nil] I'm at a loss. Could the problem be somewhere else in the freeroam script?
  23. Lergen

    Gang color blips

    I appreciate your help. That code didn't output any errors, but it unfortunately didn't work. This is what the default freeroam script looks like: function joinHandler(player) if not player then player = source end local r, g, b = math.random(50, 255), math.random(50, 255), math.random(50, 255) setPlayerNametagColor(player, r, g, b) g_PlayerData[player] = { vehicles = {}, settings={} } g_PlayerData[player].blip = createBlipAttachedTo(player, 0, 2, r, g, b) addEventHandler("onFreeroamLocalSettingChange",player,onLocalSettingChange) if getOption('welcometextonstart') then outputChatBox('Welcome to Freeroam', player, 0, 255, 0) outputChatBox('Press F1 to show/hide controls', player, 0, 255, 0) end end addEventHandler('onPlayerJoin', root, joinHandler) And this is my modified version which should just be changing blip/nametag color: function joinHandler(player) if not player then player = source end local gangName = getElementData(player, "gang") local r, g, b = unpack(getGangColor(gangName)) setPlayerNametagColor(player, tonumber(r), tonumber(g), tonumber(b)) g_PlayerData[player] = { vehicles = {}, settings={} } g_PlayerData[player].blip = createBlipAttachedTo(player, 0, 2, tonumber(r), tonumber(g), tonumber(b)) addEventHandler("onFreeroamLocalSettingChange",player,onLocalSettingChange) if getOption('welcometextonstart') then outputChatBox('Welcome to Freeroam', player, 0, 255, 0) end end addEventHandler('onPlayerJoin', root, joinHandler) This works like it should, but freeroam needs to be restarted for each new person that joins for the blip/nametag to show up. I'm just not sure what's breaking here.
  24. Lergen

    Gang color blips

    Thanks, I messed around with it a bit and almost have it working! The nametags and blips show like they're supposed to, but only if I restart the freeroam gamemode each time a new person joins, otherwise they don't show at all. In other words, only on restarting freeroam whenever somebody joins can I get it to work. I'm not sure if it's related but I get this error in debug: "server.lua 131:bad argument #1 to 'unpack' (table expected, got boolean) Line 131 is line 6 here. function joinHandler(player) if not player then player = source end local gangName = getElementData(player, "gang") local r, g, b = unpack(getGangColor(gangName)) setPlayerNametagColor(player, tonumber(r), tonumber(g), tonumber(b)) g_PlayerData[player] = { vehicles = {}, settings={} } g_PlayerData[player].blip = createBlipAttachedTo(player, 0, 2, tonumber(r), tonumber(g), tonumber(b)) addEventHandler("onFreeroamLocalSettingChange",player,onLocalSettingChange) if getOption('welcometextonstart') then outputChatBox('Welcome to Freeroam', player, 0, 255, 0) end end addEventHandler('onPlayerJoin', root, joinHandler) function getGangColor(gangName) return exports[ "gang_system" ]:getGangData ( gangName, "color" ) end I'm just using the default freeroam server script. Was there something I forgot to add?
  25. Lergen

    Gang color blips

    Setting it as its own stand-alone script rather than trying to incorporate it into the Freeroam script, the only problem returned is the "Client (name) triggered event onServerCall, but event is not added serverside." one. I'm not sure what this means though.