Tete omar Posted April 18, 2013 Share Posted April 18, 2013 Hello, I've made a disguise code, the player'd be undisguised when some event is triggered, but it's kinda weird to proceed, here's code client-side function undisguise(player) if(getPlayerTeam(player) == getTeamFromName("Blu"))then triggerServerEvent("undisguising", player, "Blue") elseif(getPlayerTeam(player) == getTeamFromName("Red"))then triggerServerEvent("undisguising", player, "Red") end end addEventHandler("onClientPlayerDamage", root, function(damager) if(damager and getElementData(damager, "playerClass") == "Spy")then if(getElementData(damager, "playerState") == "playing.disguised")then undisguise(damager) end end end ) addEventHandler("onClientPlayerWasted", root, function(killer) if(killer and getElementData(killer, "playerClass") == "Spy")then if(getElementData(killer, "playerState") == "playing.disguised")then undisguise(killer) end end end ) server-side addEventHandler("undisguising", root, function(team) setElementData(client, "playerState", "playing") if(team == "Blue")then addPedClothes(client, "balaclava", "balaclava", 17) addPedClothes(client, "suit1blue", "suit1", 0) addPedClothes(client, "suit1trblue", "suit1tr", 2) addPedClothes(client, "sneakerproblu", "sneaker", 3) setPlayerNametagText(client, getPlayerName(client)) setElementModel(client, getElementData(client, "playerSkin")) setPlayerNametagColor(client, 0, 0, 255) elseif(team == "Red")then addPedClothes(client, "balaclava", "balaclava", 17) addPedClothes(client, "suit1red", "suit1", 0) addPedClothes(client, "suit1trred", "suit1tr", 2) addPedClothes(client, "sneakerprored", "sneaker", 3) setPlayerNametagText(client, getPlayerName(client)) setElementModel(client, getElementData(client, "playerSkin")) setPlayerNametagColor(client, 255, 0, 0) end end ) in client-side when a player damages/kills some other player it'd be triggered to server-side for both?? Link to comment
50p Posted April 18, 2013 Share Posted April 18, 2013 onClientPlayerDamage will be trigger for all clients, so all the clients will trigger the server event. Just check if you want to undisguise the player you hit, if so, trigger the server event and pass the player who you want to undesguise (do not undesguise the client, because that would be you). Link to comment
Tete omar Posted April 18, 2013 Author Share Posted April 18, 2013 No i don't want to undisguise the player i hit, i want when the player who undisguised is damaging/killing another player, the player who is disguised would be undisguised, and how about attaching 'localPlayer' to both events instead of 'root'? Link to comment
50p Posted April 18, 2013 Share Posted April 18, 2013 In that case, check if localPlayer is disguised and is attacker (damager), then send the event to server. Link to comment
Tete omar Posted April 18, 2013 Author Share Posted April 18, 2013 function undisguise(player) if(getPlayerTeam(player) == getTeamFromName("Blu"))then triggerServerEvent("undisguising", player, "Blue") elseif(getPlayerTeam(player) == getTeamFromName("Red"))then triggerServerEvent("undisguising", player, "Red") end end addEventHandler("onClientPlayerDamage", localPlayer, function(damager) if(damager and getElementData(damager, "playerClass") == "Spy")then if(getElementData(damager, "playerState") == "playing.disguised")then undisguise(damager) end end end ) addEventHandler("onClientPlayerWasted", localPlayer, function(killer) if(killer and getElementData(killer, "playerClass") == "Spy")then if(getElementData(killer, "playerState") == "playing.disguised")then undisguise(killer) end end end ) I've tried with this, but it's just triggering for the player who's got damaged not the damager Link to comment
50p Posted April 18, 2013 Share Posted April 18, 2013 You're not doing what I said. In that case, check if localPlayer is disguised and is attacker (damager), then send the event to server. So, if YOU are the attacking Spy and YOU are disguised, then tell the server to undisguise you. Link to comment
Tete omar Posted April 18, 2013 Author Share Posted April 18, 2013 Hi, it worked yes and thanks, but sometimes when the damager undiguises, the tag name color won't be changed, or tag name text won't be their name, and sometimes it totally work, but its fine with clothes, do you know know how do i fix that? edit : here's my code client-side addEventHandler("onClientPlayerDamage", root, function(damager) if(damager and damager == localPlayer and getElementData(damager, "playerClass") == "Spy")then if(getElementData(damager, "playerState") == "playing.invisible")then showingWhenFire(damager) elseif(getElementData(damager, "playerState") == "playing.disguised")then undisguise(damager) end end end ) addEventHandler("onClientPlayerWasted", root, function(killer) if(killer and killer == localPlayer and getElementData(killer, "playerClass") == "Spy")then if(getElementData(killer, "playerState") == "playing.invisible")then showingWhenFire(killer) elseif(getElementData(killer, "playerState") == "playing.disguised")then undisguise(killer) end end end ) server-side addEventHandler("undisguising", root, function(team) setElementData(client, "playerState", "playing") if(team == "Blue")then addPedClothes(client, "balaclava", "balaclava", 17) addPedClothes(client, "suit1blue", "suit1", 0) addPedClothes(client, "suit1trblue", "suit1tr", 2) addPedClothes(client, "sneakerproblu", "sneaker", 3) setPlayerNametagText(client, getPlayerName(client)) setElementModel(client, getElementData(client, "playerSkin")) setPlayerNametagColor(client, 0, 0, 255) outputChatBox(getPlayerName(client) .. " undisguised") elseif(team == "Red")then addPedClothes(client, "balaclava", "balaclava", 17) addPedClothes(client, "suit1red", "suit1", 0) addPedClothes(client, "suit1trred", "suit1tr", 2) addPedClothes(client, "sneakerprored", "sneaker", 3) setPlayerNametagText(client, getPlayerName(client)) setElementModel(client, getElementData(client, "playerSkin")) setPlayerNametagColor(client, 255, 0, 0) outputChatBox(getPlayerName(client) .. " undisguised") end end ) Link to comment
50p Posted April 19, 2013 Share Posted April 19, 2013 For people browsing this topic and trying to help, Tete and I have spoken about this problem on IRC and showed me some more code which may have caused some issues, so ignore the above code which is perfectly fine. Link to comment
Tete omar Posted April 19, 2013 Author Share Posted April 19, 2013 Hi, i'm very thankful to 50p, actually, he didn't fix any codes, he just told me steps to fix the code, and i found the bug and fixed it, thanks 50p 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