Lergen Posted August 5, 2019 Share Posted August 5, 2019 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)) Link to comment
Scripting Moderators ds1-e Posted August 5, 2019 Scripting Moderators Share Posted August 5, 2019 1 hour ago, Lergen said: 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)) Condition which check if attacker is not equal to victim? if attacker ~= source then -- end Link to comment
Lergen Posted August 5, 2019 Author Share Posted August 5, 2019 19 hours ago, majqq said: Condition which check if attacker is not equal to victim? if attacker ~= source then -- end 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)) Link to comment
DNL291 Posted August 5, 2019 Share Posted August 5, 2019 Just add this to line 3: if attacker == source then return end 1 Link to comment
Scripting Moderators ds1-e Posted August 6, 2019 Scripting Moderators Share Posted August 6, 2019 (edited) 5 hours ago, Lergen said: 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)) What did you wrong is that i left comment to complete your code in it. But it would be easier for you using what @DNL291 suggested. Edited August 6, 2019 by majqq 1 Link to comment
Lergen Posted August 9, 2019 Author Share Posted August 9, 2019 That did the trick. Thank you guys! Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now