-
Posts
21,935 -
Joined
-
Last visited
-
Days Won
6
Everything posted by Castillo
-
Copy the script again and tell me if it creates them now.
-
I don't understand what do you mean, it should destroy the labels when you click another button, and create them again with the new information.
-
It wouldn't return just one element, as it's creating many labels, try this: btn_show_points = guiCreateButton(349,47,114,36,"Points",false) btn_show_cash = guiCreateButton(474,47,114,36,"Cash",false) btn_show_wins = guiCreateButton(349,97,114,36,"Wins",false) btn_show_ttset = guiCreateButton(474,97,114,36,"Top times set",false) btn_show_played = guiCreateButton(349,47,114,36,"Maps played",false) btn_show_deaths = guiCreateButton(474,47,114,36,"Deaths",false) function theButtons () if source == btn_show_points then triggerServerEvent("recievePrefix", localPlayer, "points") end if source == btn_show_cash then triggerServerEvent("recievePrefix", localPlayer, "money_q") end if source == btn_show_ttset then triggerServerEvent("recievePrefix", localPlayer, "ttset") end if source == btn_show_played then triggerServerEvent("recievePrefix", localPlayer, "mapsplayed") end if source == btn_show_deaths then triggerServerEvent("recievePrefix", localPlayer, "deaths") end end addEventHandler ( "onClientGUIClick", btn_show_points, theButtons ) addEventHandler ( "onClientGUIClick", btn_show_cash, theButtons ) addEventHandler ( "onClientGUIClick", btn_show_ttset, theButtons ) addEventHandler ( "onClientGUIClick", btn_show_played, theButtons ) addEventHandler ( "onClientGUIClick", btn_show_deaths, theButtons ) addEvent( 'onAccountsSend',true ) local labels = { } addEventHandler( 'onAccountsSend',root, function( t ) for index, lbls in pairs(labels) do for index, label in ipairs(lbls) do if isElement(label) then destroyElement(label) end end end labels = { } if #labels == 0 then for index, data in ipairs( t ) do labels[index] = guiCreateColorLabel( 13,20 * index + 39,500,276,'#ffffff#'..tostring( index )..": "..tostring( data.account ),false ) if index == 10 then break end end end end ) function guiCreateColorLabel(ax, ay, bx, by,str, parent, bool) local pat = "(.-)#(%x%x%x%x%x%x)" local s, e, cap, col = str:find(pat, 1) local last = 1 local labels = {} while s do if cap == "" and col then r,g,b = tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)) end if (s ~= 1) or cap ~= "" then local w = dxGetTextWidth(cap) lbl = guiCreateLabel(ax, ay, ax + w, by,cap,parent, bool) table.insert(labels, lbl) if (r == nil) then r = 255 end if (g == nil) then g = 255 end if (b == nil) then b = 255 end guiLabelSetColor(lbl,r,g,b) ax = ax + w r,g,b = tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)) end last = e + 1 s, e, cap, col = str:find(pat, last) end if (last <= #str) then cap = str:sub(last) local w = dxGetTextWidth(cap) lbl2 = guiCreateLabel(ax, ay, ax + w, by,cap,parent, bool) table.insert(labels, lbl2) guiLabelSetColor(lbl2,r,g,b) end return labels end
-
Try this: btn_show_points = guiCreateButton(349,47,114,36,"Points",false) btn_show_cash = guiCreateButton(474,47,114,36,"Cash",false) btn_show_wins = guiCreateButton(349,97,114,36,"Wins",false) btn_show_ttset = guiCreateButton(474,97,114,36,"Top times set",false) btn_show_played = guiCreateButton(349,47,114,36,"Maps played",false) btn_show_deaths = guiCreateButton(474,47,114,36,"Deaths",false) function theButtons () if source == btn_show_points then triggerServerEvent("recievePrefix", localPlayer, "points") end if source == btn_show_cash then triggerServerEvent("recievePrefix", localPlayer, "money_q") end if source == btn_show_ttset then triggerServerEvent("recievePrefix", localPlayer, "ttset") end if source == btn_show_played then triggerServerEvent("recievePrefix", localPlayer, "mapsplayed") end if source == btn_show_deaths then triggerServerEvent("recievePrefix", localPlayer, "deaths") end end addEventHandler ( "onClientGUIClick", btn_show_points, theButtons ) addEventHandler ( "onClientGUIClick", btn_show_cash, theButtons ) addEventHandler ( "onClientGUIClick", btn_show_ttset, theButtons ) addEventHandler ( "onClientGUIClick", btn_show_played, theButtons ) addEventHandler ( "onClientGUIClick", btn_show_deaths, theButtons ) addEvent( 'onAccountsSend',true ) local labels = { } addEventHandler( 'onAccountsSend',root, function( t ) for index, label in pairs(labels) do if isElement(label) then destroyElement(label) end end if #labels == 0 then for index, data in ipairs( t ) do labels[index] = guiCreateColorLabel( 13,20 * index + 39,500,276,'#ffffff#'..tostring( index )..": "..tostring( data.account ),false ) if index == 10 then break end end end end )
-
Kenix: That won't work, he want's a script that you can spawn it via the vehicle name too. E.g: /createvehicle
-
addCommandHandler("createvehicle", function (thePlayer, cmd, ...) for index, v in ipairs({ ... }) do vehicleModel = tonumber(v) if (not vehicleModel) then vehicleModel = getVehicleModelFromName(v) end end local x, y, z = getElementPosition(thePlayer) local vehicle = createVehicle(tonumber(vehicleModel), x, y, z) if (vehicle) then outputChatBox("The vehicle: ".. getVehicleName(vehicle) .." was created.",thePlayer,0,255,0) end end )
-
I have no idea, you must have something wrong, as it works fine in my server.
-
addEvent( 'onPlayerRaceWasted',true ) addEvent( "stats", true ) exports[ 'scoreboard' ]:addScoreboardColumn( 'Wins' ) exports[ 'scoreboard' ]:addScoreboardColumn( 'Fails' ) exports[ 'scoreboard' ]:addScoreboardColumn( 'Skill' ) local restriction = { } function restrictionEnd( playerName ) restriction[ playerName ] = nil end function updateRatio ( thePlayer ) if isElement( thePlayer ) then local account = getPlayerAccount( theplayer ) if account then if isGuestAccount( account ) then return end local wins = getAccountData( account, "Wins" ) or 0 local loses = getAccountData( account, "Fails" ) or 0 if loses == 0 then setAccountData( account, "ratio", "-" ) setElementData( thePlayer,'ratio', '-' ) else local kdr = round( wins / loses, 2 ) setAccountData( account, "ratio", kdr ) setElementData( thePlayer,'ratio', kdr ) end end end end function publicstatsinfo( ) if isElement( source ) then local account = getPlayerAccount( source ) if account then if isGuestAccount( account ) then return end local askdname = getPlayerName( source ) local wins = getAccountData( account, "Wins" ) or 0 local loses = getAccountData( account, "Fails" ) or 0 local ratio = getAccountData( account, "Skill" ) or 0 if (loses and wins) then outputChatBox("#FFA824*" .. askdname .. " won " .. tostring( wins ) .. " times and he lost " ..tostring( loses ).. " times, his ratio is " .. tostring( ratio ) .. "%", root, 255, 12, 15, true) else outputChatBox("#FFA824*" .. askdname .. " doesen't losed or won " , root, 255, 12, 15, true) end end else outputChatBox( "Error source is not player" ) end end function checkCommand( message, messageType ) if messageType == 0 then if message == "!stats" then triggerEvent( "stats", source ) elseif message == "!st" then triggerEvent( "stats", source ) cancelEvent( ) end end end function getPlayerFromNamePart( thePlayerName ) local thePlayer = getPlayerFromName( thePlayerName ) if thePlayer then return thePlayer end for _,thePlayer in ipairs( getElementsByType 'player' ) do if string.find( string.gsub( getPlayerName( thePlayer ):lower( ),"#%x%x%x%x%x%x", "" ), thePlayerName:lower( ), 1, true ) then return thePlayer end end return false end function DestructionWin( vehicle ) local alivePlayers = getAlivePlayers( ) if (#alivePlayers == 1) then if isElement( alivePlayers[1] ) then local account = getPlayerAccount( alivePlayers[1] ) if isGuestAccount( account ) then return end local count = tonumber( getAccountData( account,"Wins" ) or 0 ) + 1 setAccountData( account,"Wins",count ) setElementData( alivePlayers[1],'Wins', count ) outputChatBox ( "#FFA824The player " .. getPlayerName( alivePlayers[1] ) .. " won!", root, 255, 255, 255, true ) end else local account = getPlayerAccount( source ) if isGuestAccount( account ) then return end local loses = tonumber( getAccountData( account,"Fails" ) or 0 ) + 1 setAccountData( account,"Fails", loses ) setElementData( source,'Fails', loses ) end end addCommandHandler("stats", function ( thePlayer, cmd, whoToCheck ) local playerName = getPlayerName( thePlayer ) if restriction[ playerName ] then outputChatBox( "#FFA824You have to wait 30 seconds", thePlayer, 255, 0, 0, true ) else restriction[ playerName ] = true setTimer( restrictionEnd, 30000, 1, playerName ) local player = getPlayerFromNamePart( whoToCheck ) if player then local account = getPlayerAccount( player ) if account then if isGuestAccount( account ) then return end local wins = getAccountData( account, "Wins" ) or 0 local loses = getAccountData( account, "Fails" ) or 0 local ratio = math.max( 0, math.min( 100, math.floor( wins / ( loses + wins ) * 100 ) ) ) outputChatBox( "#FFA824*[sTATS] Player's "..tostring( getPlayerName( player ) ).." stats : " , root, 255, 12, 15, true ) outputChatBox( "#FFA824*Wins: "..tostring( wins ).."!", root, 255, 12, 15, true ) outputChatBox( "#FFA824*Loses: "..tostring( loses ).."!", root, 255, 12, 15, true ) outputChatBox( "#FFA824*Ratio: "..tostring( ratio ).."% !", root, 255, 12, 15, true ) end else outputChatBox( "Player not found!" ) end end end ) addEventHandler( 'onPlayerJoin',root, function( ) setElementData( source,'Wins', 0 ) setElementData( source,'Fails', 0 ) setElementData( source,'Skill', 0 ) end ) addEventHandler( "stats", root, publicstatsinfo ) addEventHandler( "onPlayerChat", root, checkCommand ) addEventHandler( "onPlayerRaceWasted", root,DestructionWin ) addEventHandler("onPlayerLogin",root, function (_,account) local wins = getAccountData( account, "Wins" ) or 0 local loses = getAccountData( account, "Fails" ) or 0 if (wins and loses) then setElementData(source,"Wins",wins) setElementData(source,"Fails",loses) updateRatio(source) end end) Should load the stats on login.
-
I don't know why you need the 'if' check. function theButtons() triggerServerEvent("recievePrefix", localPlayer, "Points") end addEventHandler ( "onClientGUIClick", btn_show_points, theButtons, false )
-
Vehicle mod: https://community.multitheftauto.com/index.php?p= ... ls&id=3781 Skin mod: https://community.multitheftauto.com/index.php?p= ... ls&id=3780
-
I wasn't talking about the second script, I meant the first one.
-
addEventHandler( 'onGamemodeMapStart',root, function (map) local map = getResourceName(map) local result = executeSQLQuery ( "SELECT * FROM Top WHERE map = '" ..map.. "'" ) if (not result or #result == 0) then executeSQLQuery( "INSERT INTO Top VALUES ('"..map.."','No one', '"..tonumber(100)..":"..tonumber(100).."')" ) local resultt = executeSQLQuery ( "SELECT * FROM Top WHERE map = '" ..map.. "'" ) setElementData( root,'playerName',tostring( resultt[1]['player'] ) ) setElementData( root,'timeMT',tostring( resultt[1]['time'] ) ) triggerClientEvent('clientStart',root) else setElementData( root,'playerName',tostring( result[1]['player'] ) ) setElementData( root,'timeMT',tostring( result[1]['time'] ) ) triggerClientEvent('clientStart',root) end end ) If it didn't work, then post your whole script.
-
You must add 'source' at the end of the timer function. addEventHandler( 'onPlayerLogin',root, function( ) local level = getAccountData(getPlayerAccount(source),'My Level') timer[ source ] = setTimer( function (player) local account = getPlayerAccount( player ) if not isGuestAccount( account ) then local result = executeSQLQuery("SELECT money FROM Money WHERE player= '"..getPlayerName(player).."'") local money = tonumber(result[1]['money']) if money <= tonumber(50000) and getElementData( - ERROR in this line,'Race Wins') < 10 then setAccountData( account,'My Level','Newbie' ) setElementData( - ERROR in this line,'Level','Newbie' ) elseif money <= tonumber(250000) and money > tonumber(50000) and getElementData(player,'Race Wins') < 50 and getElementData(player,'Race Wins') > 10 then setAccountData( account,'My Level','Regular' )....
-
What exactly doesn't work? I just tested it and it destroyed my vehicle.
-
"uTimers" is a table which is used to store player timers.
-
addCommandHandler("reset", function () for index, account in ipairs(getAccounts()) do exports["bank"]:setBankAccountBalance(getAccountName(account), 0) end end) WARNING: IF YOUR BANK RESOURCE ISN'T CALLED "bank" THEN CHANGE IT IN THE SCRIPT.
-
You're talking about "CDM", not "CMD". As far as I know, you can change the camera in the map files.
-
Selling a login panel for 30 Pounds (47.32 Dollars) is almost a robbery, no offense.
-
Is not a function. And should use it when you need it only.
-
-- giveAllMoney function: function giveAllMoney(thePlayer, commandName, money) if (exports.global:isPlayerLeadAdmin(thePlayer)) then if (not money) then outputChatBox("SYNTAX: /" .. commandName .. " [Money]", thePlayer, 255, 194, 14) else local username = getPlayerName(thePlayer) local hiddenAdmin = getElementData(thePlayer, "hiddenadmin") if (hiddenAdmin==0) then local adminTitle = exports.global:getPlayerAdminTitle(thePlayer) exports.global:sendMessageToAdmins("AdmCmd: " .. getPlayerName(thePlayer) .. " gave all players online " .. money .. " dollars.") outputChatBox("" .. tostring(adminTitle) .. " " .. getPlayerName(thePlayer) .. " gave all players online " .. money .. " dollars.", getRootElement(), 255, 255, 255) else outputChatBox("Hidden Admin gave all players online " .. money .. " dollars.", getRootElement(), 255, 255, 255) end for index, player in ipairs(getElementsByType("player")) do exports.global:giveMoney(player, tonumber(money)) end outputChatBox("You have given $" .. money .. " to all players ", thePlayer) end end end addCommandHandler("giveallmoney", giveAllMoney, false, false) -- giveMoney function: function giveMoney(thePlayer, commandName, target, money) if (exports.global:isPlayerLeadAdmin(thePlayer)) then if not (target) then outputChatBox("SYNTAX: /" .. commandName .. " [Partial Player Nick] [money]", thePlayer, 255, 194, 14) else local username = getPlayerName(thePlayer) local targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick(thePlayer, target) if targetPlayer then local hiddenAdmin = getElementData(thePlayer, "hiddenadmin") if (hiddenAdmin==0) then local adminTitle = exports.global:getPlayerAdminTitle(thePlayer) exports.logs:logMessage("[GIVE] " .. getPlayerName(thePlayer):gsub("_", " ") .. " gave " .. targetPlayerName .. " to $" .. money, 23) exports.global:sendMessageToAdmins("AdmCmd: " .. getPlayerName(thePlayer) .. " gave " .. targetPlayerName .. " " .. money .. " dollars.") outputChatBox("Admin " .. username .. " has given you $" .. money .. ".", targetPlayer) outputChatBox("" .. tostring(adminTitle) .. " " .. getPlayerName(thePlayer) .. " gave " .. targetPlayerName .. " " .. money .. " dollars.", getRootElement(), 255, 255, 255) else outputChatBox("Hidden Admin gave " .. targetPlayerName .. " " .. money .. " dollars.", getRootElement(), 255, 255, 255) end exports.global:giveMoney(targetPlayer, money) outputChatBox("You have given " .. targetPlayerName .. " $" .. money .. ".", thePlayer) end end end end addCommandHandler("givemoney", giveMoney, false, false)
-
@Evil-Codr: What part didn't you understand of my first reply? the player get's killed by vehicle explosion, there's no way to detect if it was a hunter and the killer.
-
No se, seguro que si alguien sabe te va a ayudar .
-
That's like a example, if the rocket has a target and the target is a vehicle and the vehicle has a driver, then output it's name to the client.
-
function projectileCreation() local target = getProjectileTarget(source) if (target and getElementType(target) == "vehicle" and getVehicleController(target)) then local player = getVehicleController(target) outputChatBox(getPlayerName(player)) end end addEventHandler("onClientProjectileCreation", getRootElement(), projectileCreation)