Jump to content

Negriukas

Members
  • Posts

    71
  • Joined

  • Last visited

Everything posted by Negriukas

  1. I tried this but it didnt work, Debug shows nothing.. server function onPlayerRammed(target) if target and source then killPed(target, source, 49, 9) end end addEvent("onPlayerRammed",true) addEventHandler ( "onPlayerRammed", getRootElement (), onPlayerRammed) function onPedRammed(victim) if victim and source then killPed(victim, source, 49, 9) end end addEvent("onPedRammed",true) addEventHandler ( "onPedRammed", getRootElement (), onPedRammed) client addEvent("onClientPedRammed") addEvent("onClientPlayerRammed") function checkForRamming(killer, weapon, bodypart, loss) if wasEventCancelled() then return end if getVehicleOccupant(killer, 0) and getElementType(getVehicleOccupant(killer, 0)) == "player" and getVehicleOccupant(killer, 0) ~= localPlayer then return end if not getVehicleOccupant(killer, 0) and source ~= localPlayer then return end if getElementHealth(source) - loss <= 0 then return end if loss > 7 then setElementHealth(source, 0) if getElementType(source) == "player" then triggerServerEvent("onPlayerRammed", source, killer, weapon, bodypart, loss) else triggerServerEvent("onPedRammed", source, killer, weapon, bodypart, loss) end end end addEventHandler("onClientPedRammed", root, checkForRamming) addEventHandler("onClientPlayerRammed", root, checkForRamming) function onClientPedRammed(killer, weapon, bodypart, loss) if not getElementType(source) == "ped" then return end if weapon == 49 and getElementType(killer) == "vehicle" then triggerEvent("onClientPedRammed", source, killer, weapon, bodypart, loss) end end addEventHandler ("onClientPedDamage", root, onClientPedRammed) function onClientPlayerRammed(killer, weapon, bodypart, loss) if not getElementType(source) == "player" then return end if weapon == 49 and getElementType(killer) == "vehicle" then triggerEvent("onClientPlayerRammed", source, killer, weapon, bodypart, loss) end end addEventHandler ("onClientPlayerDamage", root, onClientPlayerRammed)
  2. Hello, Is it possible to ram players with cars? I mean like when i damage another player he instantly die, If it's possible please tell me events and function that would be useful to make that. Thank you
  3. To answer your main question, Yes it is. Thanks.
  4. Same thing, + It works fine i just asked if it's okay like that... Can you write something useful in stead of spamming to increase the number of posts...
  5. Attempt to compare arithmet with boolean and getPedBonePosition is returning false bad pointer at 'ped'
  6. Hello, I'm trying to fix some weapons range by writing this simple script, anyway is it safe like this way? server: --FIXING WEAPON PROPERTIES function setWeaponAutomaticRangeFixOn() rangeProperty = { {"M4", 31, "pro", "weapon_range", 200}, {"M4", 31, "std", "weapon_range", 150}, {"M4", 31, "poor", "weapon_range", 90}, {"SNIPER", 34, "pro", "weapon_range", 500}, {"SNIPER", 34, "std", "weapon_range", 300}, {"SNIPER", 34, "poor", "weapon_range", 200}, {"AK47", 30, "pro", "weapon_range", 200}, {"AK47", 30, "std", "weapon_range", 150}, {"AK47", 30, "poor", "weapon_range", 90}, } for i,v in ipairs( rangeProperty ) do local weaponID = v[2] local weaponSkill = v[3] local weaponProperty = v[4] local weaponValue = v[5] for i = 1,9 do setWeaponProperty(weaponID, weaponSkill, weaponProperty, weaponValue) end end end function startTheResource() setWeaponAutomaticRangeFixOn() end addEventHandler("onResourceStart", getRootElement(), startTheResource)
  7. Thank you! I'll try to figure out how to make it.
  8. Hello, I'm making my vehicle shop system which it spawn the vehicle near the player exactly like freeroam, Sometimes it works fine and sometimes not because i recently added a isPedOnGround check and it seems that it's not stable. Results: false true
  9. I personally nominate Grafu, This guy seems to know what he is doing
  10. Hello guys, I'm creating my own chatbubbles for my server, And i'm facing some kind of errors which i can't exactly understand, My code was working fine til i added the typing check, which it check when player is typing or if console is active then add a chatbubble showing ("Typing!"), Here is my client side code local messageToDraw = {} local chattingPlayers = {} local chatBubbleFor = {} 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 addPlayerChatBubble(source,message,messagetype) end elseif messagetype == 1 then addPlayerChatBubble(source,message,messagetype) elseif messagetype == "typing" then addPlayerChatBubble(source,"Typing!","typing") else addPlayerChatBubble(source,message,messagetype) end end end function addPlayerChatBubble(source,message,messagetype) local notfirst = false for i,p in ipairs(messageToDraw) do if p[1] == source then p[4] = p[4] + 1 notfirst = true end end local infotable = {source,message,messagetype,0} table.insert(messageToDraw,infotable) setElementData(source, "chatbubblesTyping", true, false) if messagetype ~= "typing" then hidePlayerTypingBubble(source) setTimer(deletePlayerChatBubble, 10000, 1, {source,message,messagetype} ) end if not notfirst then setTimer(deletePlayerChatBubble,showTime + (#message * characterAddition),1,infotable) end end function deletePlayerChatBubble(infotable) for i,p in ipairs(messageToDraw) do if p[1] == infotable[1] and p[2] == infotable[2] then for i2,p2 in ipairs(messageToDraw) do if p2[1] == p[1] and p[4] - p2[4] == 1 then setTimer(deletePlayerChatBubble,showTime + (#p2[2] * characterAddition),1,p2) end end table.remove(messageToDraw,i) break end end end function getTextsToRemove() for i,p in ipairs(messageToDraw) do if p[1] == source then deletePlayerChatBubble(p) end end end addEventHandler("onClientPlayerQuit",getRootElement(),getTextsToRemove) function renderTheDisplay() if showTheBubbles then for i,p in ipairs(messageToDraw) do if isElement(p[1]) then if getElementHealth(p[1]) > 0 then local camPosXl, camPosYl, camPosZl = getPedBonePosition (p[1], 6) local camPosXr, camPosYr, camPosZr = getPedBonePosition (p[1], 7) local x,y,z = (camPosXl + camPosXr) / 2, (camPosYl + camPosYr) / 2, (camPosZl + camPosZr) / 2 local cx,cy,cz = getCameraMatrix() local px,py,pz = getElementPosition(p[1]) local distance = getDistanceBetweenPoints3D(cx,cy,cz,px,py,pz) local posx,posy = getScreenFromWorldPosition(x,y,z+0.050*distance+0.10) local elementtoignore1 = getPedOccupiedVehicle(getLocalPlayer()) or getLocalPlayer() local elementtoignore2 = getPedOccupiedVehicle(p[1]) or p[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 p[4] < maxBubbles ) then -- change this when multiple ignored elements can be specified local width = dxGetTextWidth(p[2],1,"default-bold") dxDrawRectangle(posx - (3 + (0.5 * width)),posy - (2 + (p[4] * 20)),width + 5,19,tocolor(0,0,0,255)) dxDrawRectangle(posx - (6 + (0.5 * width)),posy - (2 + (p[4] * 20)),width + 11,19,tocolor(0,0,0,40)) dxDrawRectangle(posx - (8 + (0.5 * width)),posy - (1 + (p[4] * 20)),width + 15,17,tocolor(0,0,0,255)) dxDrawRectangle(posx - (10 + (0.5 * width)),posy - (1 + (p[4] * 20)),width + 19,17,tocolor(0,0,0,40)) dxDrawRectangle(posx - (10 + (0.5 * width)),posy - (p[4] * 20) + 1,width + 19,13,tocolor(0,0,0,255)) dxDrawRectangle(posx - (12 + (0.5 * width)),posy - (p[4] * 20) + 1,width + 23,13,tocolor(0,0,0,40)) dxDrawRectangle(posx - (12 + (0.5 * width)),posy - (p[4] * 20) + 4,width + 23,7,tocolor(0,0,0,255)) local r,g,b = 255,255,255 if p[3] == 2 then r,g,b = 154, 254, 46 elseif p[3] == 1 then r,g,b = 254,46,154 end dxDrawText(p[2],posx - (0.5 * width),posy - (p[4] * 20),posx - (0.5 * width),posy - (p[4] * 20),tocolor(r,g,b,255),1,"default-bold","left","top",false,false,false) end end end end end end addEventHandler("onClientRender",getRootElement(),renderTheDisplay) function getServerSettings() triggerServerEvent("onAskForBubbleSettings",getLocalPlayer()) end addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),getServerSettings) function saveSettings(settings) showTime = settings[1] characterAddition = settings[2] maxBubbles = settings[3] hideOwn = settings[4] addEvent("onChatbubblesMessageIncome",true) addEventHandler("onChatbubblesMessageIncome",getRootElement(),income) end addEvent("onBubbleSettingsReturn",true) addEventHandler("onBubbleSettingsReturn",getRootElement(),saveSettings) function setPlayerTyping() if (isChatBoxInputActive() or isConsoleActive()) and not typing then triggerServerEvent("onPlayerStartTyping", localPlayer) typing = true end if not (isChatBoxInputActive() or isConsoleActive()) and typing then triggerServerEvent("onPlayerFinishTyping", localPlayer) typing = false end end setTimer(setPlayerTyping, 50, 0) function showPlayerTypingBubble() if source ~= getLocalPlayer() or not hideOwn then addPlayerChatBubble(source, "Typing!", "typing") end end addEvent("onPlayerStartTyping", true) addEventHandler("onPlayerStartTyping", root, showPlayerTypingBubble) function hidePlayerTypingBubble(me) if not source then source = me end deletePlayerChatBubble({ source = source, message = "Typing!", messagetype = "typing" }) end addEvent("onPlayerFinishTyping", true) addEvent("onClientPlayerChat", true) addEventHandler("onPlayerFinishTyping", root, hidePlayerTypingBubble) addEventHandler("onClientPlayerChat", root, hidePlayerTypingBubble) function updateList(newEntry, newStatus) chattingPlayers[newEntry] = newStatus if(not chatBubbleFor[newEntry]) then showPlayerTypingBubble(localPlayer) end hidePlayerTypingBubble(localPlayer) end addEvent("updateChatList", true) addEventHandler ( "updateChatList", getRootElement(), updateList ) ERROR: chatbubbles/client:76:attempt to compare number with boolean
  11. I still get the same error
  12. So i edited scoreboard for that i added those lines to the scoreboard client side script, if content.type == "image+text" and fileExists(content.src) then local itemHeight = content.height or dxGetFontHeight( fontscale(teamHeaderFont, scoreboardScale), teamHeaderFont ) local itemWidth = content.width or content.height/itemHeight * content.width if itemHeight > dxGetFontHeight( fontscale(teamHeaderFont, scoreboardScale), teamHeaderFont ) then itemHeight = dxGetFontHeight( fontscale(teamHeaderFont, scoreboardScale), teamHeaderFont ) end content.color = content.color or tocolor(255,255,255,255) content.rot = content.rot or 0 content.rotOffX = content.rotOffX or 0 content.rotOffY = content.rotOffY or 0 dxDrawImage ( topX+theX, y, itemWidth, itemHeight, content.src, content.rot, content.rotOffX, content.rotOffY, content.color, drawOverGUI ) dxDrawText( content.text, topX+theX+itemWidth+s(4)+s(1), y+s(1), topX+x+s(1+column.width), y+s(11)+dxGetFontHeight( fontscale(teamHeaderFont, scoreboardScale), teamHeaderFont ), tocolor( 0, 0, 0, a or 255 ), fontscale(teamHeaderFont, s(1)), teamHeaderFont, "left", "top", true, false, drawOverGUI ) dxDrawText( content.text, topX+theX+itemWidth+s(4), y, topX+x+s(column.width), y+dxGetFontHeight( fontscale(teamHeaderFont, scoreboardScale), teamHeaderFont ), tocolor( r or 255, g or 255, b or 255, a or 255 ), fontscale(teamHeaderFont, s(1)), teamHeaderFont, "left", "top", true, false, drawOverGUI ) end What's next? By the way here is my code which it exports country name and image, exports["scoreboard"]:addScoreboardColumn( "", getRootElement() , 3, 20, "") function showcountry() local flag = exports.admin:getPlayerCountry ( source ) local ip = getPlayerIP( source ) if flag then setElementData(source,"",":admin/client/images/flags/"..flag..".png") else flag = "Unknown" end end addEventHandler("onPlayerJoin",getRootElement(), showcountry) exports["scoreboard"]:addScoreboardColumn( "Country", getRootElement() , 4, 120, "Country") addEventHandler("onPlayerJoin", getRootElement(), function() local country = exports['admin']:getPlayerCountry(source) local ip = getPlayerIP( source ) if country then local thecountry = countryNames[country] setElementData(source, "Country", thecountry) else country = "Unknown" end end)
  13. Alright thanks, I based mine on this thePlayer = me, _ = command, who = target, much = how much xp, So no need for "who" and "much" right? I'm just a beginner trying to learn thats why i made a lot of mistakes in this code, And i couldnt find any example of exporting functions in a random topic or sometihng alike..
  14. I did: Here is a part from meta <script src="server.lua" type="server" /> <script src="client.lua" type="client" /> Or do you mean this? <export function="exampleExport3" type="shared" /> And i dont understand the second tip And the third tip i made just a typo while writting the topic and i fixed it
  15. Hello, I'm adding some exported functions to my xp system which is based on element datas "EXP" and "Level", Anyway when i tried to export them I get those errors, This is the meta file. <export function="addPlayerXP" type="server"/> <export function="addPlayerXP" type="client"/> <export function="setPlayerXP" type="server"/> <export function="setPlayerXP" type="client"/> <export function="takePlayerXP" type="server"/> <export function="takePlayerXP" type="client"/> <export function="getPlayerXP" type="server"/> <export function="getPlayerXP" type="client"/> And the server side code. function setPlayerXP(thePlayer, _, who, XP) local thePlayer = getPlayerName(who) setElementData(thePlayer, "EXP", XP) end function addPlayerXP(thePlayer, _, who, much) local thePlayer = getPlayerName(who) local H = getElementData(thePlayer, "EXP") or 0 local number = much setElementData(thePlayer, "EXP", tonumber(H) + number) end function getPlayerXP(thePlayer, _, who, XP) local thePlayer = getPlayerName(who) getElementData(thePlayer, "EXP", XP) end function takePlayerXP(thePlayer, _, who, much) local thePlayer = getPlayerName(who) local H = getElementData(thePlayer, "EXP") or 0 local number = much setElementData(thePlayer, "EXP", tonumber(H) - number) end And server side of my bots script. addEvent( "onAlphaBotWasted" , true) addEventHandler( "onAlphaBotWasted", getRootElement(), function( killer ) local money = 5000 local xp = 5 local points = getElementData(killer, "Points") or 0 exports.Experience:addPlayerXP(killer, xp) givePlayerMoney( killer, tonumber(money)) setElementData(killer, "Points", tonumber(H)+math.random(1,5)) triggerClientEvent(killer, "onClientAlphaBotWasted", killer, money) end)
  16. Hello, So i'm making my own nametags system and i need to draw the "_" in every player name with a space, like example if my name is "Franklin_Clinton" it will draw "Franklin Clinton" etc and thanks. This is a little part of my code detects = { { "_", " " }, } local playerName = getPlayerName(player) for k,v in ipairs (detects) do if string.find( string.lower ( playerName ),v[1]) then playerName = playerName:gsub ( playerName, v[2] ) end end The problem is that it repalce the whole player name with a space and it suppose to replace only the string "_"
  17. Negriukas

    check

    I made an achievement system, and i'm trying to give the player an award after first time using jetpack..
  18. Negriukas

    check

    Hello guys, I made a script to set Player element data "Jetpack" true if he have a jetpack otherwise False but not working, here is my code. Server: function checkWhoHaveJetpack() for index, thePlayer in ipairs(getElementsByType("player"))do if doesPedHaveJetPack(thePlayer) then setElementData(thePlayer, "Jetpack", "Jetpack") end end end setTimer(checkWhoHaveJetpack, 1000, 0)
  19. Not working, I fixed the second argument in addEventHandler but still playing the sound and showing the Greet after logging in, Hope someone help, Thanks.
×
×
  • Create New...