Jump to content

Wisam

Members
  • Posts

    168
  • Joined

  • Last visited

Everything posted by Wisam

  1. Hello, So i have here a chat bubble script and its about when a player talk in localchat or main chat a bubble will pop up above his head and i have a small bug i hope you help me with its when a bubble pop up a players head it never disappear. Here's the script: Client Side: local textsToDraw = {} local hideown local showtime local characteraddition local maxbubbles local showthebubbles = true function income(message,messagetype) if source ~= getLocalPlayer() or not hideown then if messagetype == 2 then if getPlayerTeam(source) == getPlayerTeam(getLocalPlayer()) then addText(source,message,messagetype) end else addText(source,message,messagetype) end end end function addText(source,message,messagetype) local notfirst = false for i,v in ipairs(textsToDraw) do if v[1] == source then v[4] = v[4] + 1 notfirst = true end end local infotable = {source,message,messagetype,0} table.insert(textsToDraw,infotable) if not notfirst then setTimer(removeText,showtime + (#message * characteraddition),1,infotable) end end function removeText(infotable) for i,v in ipairs(textsToDraw) do if v[1] == infotable[1] and v[2] == infotable[2] then for i2,v2 in ipairs(textsToDraw) do if v2[1] == v[1] and v[4] - v2[4] == 1 then setTimer(removeText,showtime + (#v2[2] * characteraddition),1,v2) end end table.remove(textsToDraw,i) break end end end function getTextsToRemove() for i,v in ipairs(textsToDraw) do if v[1] == source then removeText(v) end end end function handleDisplay() if showthebubbles then for i,v in ipairs(textsToDraw) do if isElement(v[1]) then if getElementHealth(v[1]) > 0 then local camPosXl, camPosYl, camPosZl = getPedBonePosition (v[1], 6) local camPosXr, camPosYr, camPosZr = getPedBonePosition (v[1], 7) local x,y,z = (camPosXl + camPosXr) / 2, (camPosYl + camPosYr) / 2, (camPosZl + camPosZr) / 2 --local posx,posy = getScreenFromWorldPosition(x,y,z+0.25) local cx,cy,cz = getCameraMatrix() local px,py,pz = getElementPosition(v[1]) local distance = getDistanceBetweenPoints3D(cx,cy,cz,px,py,pz) local posx,posy = getScreenFromWorldPosition(x,y,z+0.020*distance+0.10) local elementtoignore1 = getPedOccupiedVehicle(getLocalPlayer()) or getLocalPlayer() local elementtoignore2 = getPedOccupiedVehicle(v[1]) or v[1] if posx and distance <= 45 and ( isLineOfSightClear(cx,cy,cz,px,py,pz,true,true,false,true,false,true,true,elementtoignore1) or isLineOfSightClear(cx,cy,cz,px,py,pz,true,true,false,true,false,true,true,elementtoignore2) ) and ( not maxbubbles or v[4] < maxbubbles ) then -- change this when multiple ignored elements can be specified local width = dxGetTextWidth(v[2],1,"default") dxDrawRectangle(posx - (3 + (0.5 * width)),posy - (2 + (v[4] * 20)),width + 5,19,tocolor(0,0,0,255)) dxDrawRectangle(posx - (6 + (0.5 * width)),posy - (2 + (v[4] * 20)),width + 11,19,tocolor(0,0,0,40)) dxDrawRectangle(posx - (8 + (0.5 * width)),posy - (1 + (v[4] * 20)),width + 15,17,tocolor(0,0,0,255)) dxDrawRectangle(posx - (10 + (0.5 * width)),posy - (1 + (v[4] * 20)),width + 19,17,tocolor(0,0,0,40)) dxDrawRectangle(posx - (10 + (0.5 * width)),posy - (v[4] * 20) + 1,width + 19,13,tocolor(0,0,0,255)) dxDrawRectangle(posx - (12 + (0.5 * width)),posy - (v[4] * 20) + 1,width + 23,13,tocolor(0,0,0,40)) dxDrawRectangle(posx - (12 + (0.5 * width)),posy - (v[4] * 20) + 4,width + 23,7,tocolor(0,0,0,255)) local r,g,b = 255,255,255 if v[3] == 2 then r,g,b = getTeamColor(getPlayerTeam(v[1])) end dxDrawText(v[2],posx - (0.5 * width),posy - (v[4] * 20),posx - (0.5 * width),posy - (v[4] * 20),tocolor(r,g,b,255),1,"default","left","top",false,false,false) end end end end end end function getServerSettings() triggerServerEvent("onAskForBubbleSettings",getLocalPlayer()) end function saveSettings(settings) showtime = settings[1] characteraddition = settings[2] maxbubbles = settings[3] hideown = settings[4] addEvent("onChatbubblesMessageIncome",true) addEventHandler("onChatbubblesMessageIncome",getRootElement(),income) end function toggleBubblesOnOff() showthebubbles = not showthebubbles outputChatBox("Toggled chatbubbles " ..( not showthebubbles and "#FF0000off#FFFFFF." or "#00FF00on#FFFFFF." ),255,255,255,true) end addEventHandler("onClientPlayerQuit",getRootElement(),getTextsToRemove) addEventHandler("onClientRender",getRootElement(),handleDisplay) addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),getServerSettings) addEvent("onBubbleSettingsReturn",true) addEventHandler("onBubbleSettingsReturn",getRootElement(),saveSettings) addCommandHandler("chatbubbles",toggleBubblesOnOff) Server Side: local showtime = tonumber(get("chatbubbles.DefaultTime")) local characteraddition = tonumber(get("chatbubbles.PerCharacterAddition")) local maxbubbles = get("chatbubbles.MaxBubbles") if maxbubbles == "false" then maxbubbles = false else maxbubbles = tonumber(maxbubbles) end local hideown = get("chatbubbles.HideOwn") if hideown == "true" then hideown = true else hideown = false end function sendMessageToClient(message,messagetype) if not wasEventCancelled() then if messagetype == 0 or messagetype == 2 then triggerClientEvent("onChatbubblesMessageIncome",source,message,messagetype) end end end function returnSettings() local settings = { showtime, characteraddition, maxbubbles, hideown } triggerClientEvent(source,"onBubbleSettingsReturn",getRootElement(),settings) end addEventHandler("onPlayerChat",getRootElement(),sendMessageToClient) addEvent("onAskForBubbleSettings",true) addEventHandler("onAskForBubbleSettings",getRootElement(),returnSettings)
  2. Always wanted to create you're own free server? Well, this is the right place.. a tutorial for how to create a free online server its free and simple. Enjoy!
  3. Hey I have advanced mute system script and I want to turn it to advanced ban system. Here is the script. function muteOurPlayer(player, command, mutedguy, time, reason) if mutedguy and time and reason then local muted = getPlayerFromName(mutedguy) if muted then if( not isPlayerMuted(muted) ) then setPlayerMuted(muted, true) outputChatBox("#FF0000"..getPlayerName(muted).." has been muted for"..time.."#FF0000 minutes. ("..reason.."#FF0000 )", getRootElement(), 255, 0, 0, true) setElementData(muted, "Muted", 1) setElementData(muted, "MutedTime", time) setElementData(muted, "Reason", reason) -- setTimer(setPlayerMuted(muted, false), time*60*1000, 1) -- setTimer(outputChatBox(mutedguy.." has been unmuted.", getRootElement()), time*60*1000, 1) end end else outputChatBox("MUTE SYNTAX: /mmute ", player) end end addCommandHandler("mmute", muteOurPlayer) function unmuteOurPlayer(player, command, unmutedguy) if unmutedguy then local unmuted = getPlayerFromName(unmutedguy) if unmuted then if isPlayerMuted(unmuted) then setPlayerMuted(unmuted, false) setElementData(unmuted, "Muted", 0) setElementData(unmuted, "MutedTime", 0) removeElementData(unmuted, "Reason") outputChatBox("#ADFF2F"..getPlayerName(unmuted).."#FFFFFF has been unmuted by#ADFF2F "..getPlayerName(player).."#FFFFFF. ", getRootElement(),255, 255, 255, true) end end else outputChatBox("UNMUTE SYNTAX: /unmute ", player) end end addCommandHandler("unmmute", unmuteOurPlayer) function unmuteChecker() players = getElementsByType("player") for i,thePlayer in ipairs(players) do if getElementData(thePlayer, "Muted") == 1 then if getElementData(thePlayer, "MutedTime") == 1 then setPlayerMuted(thePlayer, false) outputChatBox("#ADFF2F"..getPlayerName(thePlayer).."#FFFFFF has been unmuted by server. (#ADFF2FTime Passed#FFFFFF)", getRootElement(),255, 255, 255, true) else oldValue = getElementData(thePlayer, "MutedTime") setElementData(thePlayer, "MutedTime", oldValue-1) end end end end setTimer(unmuteChecker, 60000, 0) function muteList(player, command) players = getElementsByType("player") outputChatBox("List of muted players:", player) outputChatBox("----------------------", player, 255, 255, 255, true) for i,thePlayer in ipairs(players) do if getElementData(thePlayer, "Muted") == 1 then outputChatBox("Name: #ADFF2F"..getPlayerName(thePlayer).."#FFFFFF - Time: #ADFF2F"..getElementData(thePlayer,"MutedTime").."#FFFFFF minutes - Reason: #ADFF2F"..getElementData(thePlayer,"Reason"), player, 255, 255, 255, true) end end end addCommandHandler("mutelist", muteList) I want to replace /mmute with /bban , You can delete (if its advanced ban system) the unban function and the banlist function , because we can see bans in the admin panel.
  4. Hey, Im now starting my new hosted server and i need some scripters. Server info: Slots: 100 Admins/Supermoderators/Moderators: 4/2/2 Gamemode: Freeroam/Gangs, and contains: turfing, bank robbery, gangs...etc If you got a real scripting expirence you can join our server and be Moderator/Supermoderator.
  5. i used tis: run setPlayerNametagShowing (Wisam, true) and didnt worked, it says: Wisam executed command: setPlayerNametagShowing (Wisam, false) Command results: false [boolean]
  6. Oh i found them, but its it: setPlayerNametagShowing (playerName, false) if i wanted to hide the blip?
  7. Searched here but couldn't find anything
  8. Hi.. Im wisam, today i wanted to ask about some simple run codes... my friend gave them to me and now i lost them so i need them back... some small run codes i need: 1. hide the player name. 2. hide the player's blip 3. Hide the player. or you can help me better, tell me where i can find ALL the runcodes. Thank You, Regards
  9. how to load the command to the server without making a resource ? lame , im a newbie scripter and im learning
  10. Hey John... your resources in the community is very intersting and you are a very good mapper so i wanted to suggest you to make a very simple script i couldnt make..it is a command example: when i type /mastertop i get warped to location that it calls mastertop. i hope you make this script..Ty
  11. Hey Bauss.. i liked your toolbox very much..but i downloaded it and loaded it and its not working can you helo me ?!
  12. Hey.. i have a problem with the dxscoreboard...the problem is i want the dxscoreboard for my DM server,it include: state,race rank,victories..etc....and i couldnt add these becasue im newbie scripter. Help me.
  13. LMFAO there is a report , thanks anyway
  14. Hello.. i needed a very simple script good for RPG and race and its the /report command, i couldnt make this script so can some one make it for me ? the /report command...it sends a messege/report/suggestion to every online admins. if someone made this script post in in MTA community or here in the forum...ill appreciate this.. Thank You.
×
×
  • Create New...