Lergen

Members
  • Content Count

    24
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Lergen

  • Rank
    Civilian

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. That did the trick. Thank you guys!
  2. 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))
  3. 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))
  4. Ahhh, that's unfortunate then. I appreciate the heads-up though, thanks!
  5. 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.
  6. 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.
  7. 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.
  8. 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?
  9. 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)
  10. 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.
  11. 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.
  12. 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?
  13. 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.
  14. 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?
  15. 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?