danielpaulino Posted September 14, 2019 Share Posted September 14, 2019 boa noite eu baixei um script da internet de celular, e eu não to conseguindo colocar para a transferência de dinheiro seja feita por ID, desde já agradeço function(who, player) local money = getPlayerMoney(source) if player ~= nil then if tonumber(player) >= 200 then if tonumber(player) <= money then toWho = getPlayerFromPartialName(who) conta = getPlayerAccount (source) if isGuestAccount (conta) then outputChatBox("#FFFF00Você precisa estar logado.", source, 255, 255, 255, true) return end nick_do_jogador = getPlayerName ( toWho ) if toWho ~= false then givePlayerMoney(toWho, player) takePlayerMoney(source, player) name = getPlayerName(source) outputChatBox("#FFFF00Você transferiu #00ff00R$" .. player .. "#FFFF00 para #FFFF00" .. nick_do_jogador, source, 255, 255, 255, true) outputChatBox("".. name .. " #FFFF00lhe transferiu #FFFF00R$" .. player .. " #FFFF00!", toWho, 255, 255, 255, true) else outputChatBox("#FFFF00Você não selecionou um jogador da lista!", source, 255, 255, 255,true) end else outputChatBox("#FFFF00Você não tem dinheiro suficiente!", source, 255, 255, 255,true) end else outputChatBox("#FFFF00 O valor mínimo de transferências é R$ 200 !", source, 255, 255, 255,true) end end end ) Link to comment
DNL291 Posted September 15, 2019 Share Posted September 15, 2019 Só seguir a mesma lógica que o outro tópico seu: https://forum.multitheftauto.com/topic/119979-ajuda-samu-por-id-script-id/ Vai precisar do sistema de ID no server e no seu script você coloca a função getPlayerID: function getPlayerID(id) v = false for i, player in ipairs (getElementsByType("player")) do if getElementData(player, "ID") == id then v = player break end end return v end De resto é adicionar o parâmetro id no comando e verificações. 1 Link to comment
danielpaulino Posted September 15, 2019 Author Share Posted September 15, 2019 ah ok vlw assim? function getPlayerID(id) v = false for i, player in ipairs (getElementsByType("player")) do if getElementData(player, "ID") == id then v = player break end end return v end addEvent("onSendMoney", true) addEventHandler("onSendMoney", getRootElement(), function(who, player) local money = getPlayerMoney(source) if player ~= nil then if tonumber(player) >= 200 then if tonumber(player) <= money then toWho = getPlayerID(id) conta = getPlayerAccount (source) if isGuestAccount (conta) then outputChatBox("#FFFF00Você precisa estar logado.", source, 255, 255, 255, true) return end id = getPlayerName ( toWho ) if toWho ~= false then givePlayerMoney(toWho, player) takePlayerMoney(source, player) name = getPlayerName(source) outputChatBox("#FFFF00Você transferiu #00ff00R$" .. player .. "#FFFF00 para #FFFF00" .. nick_do_jogador, source, 255, 255, 255, true) outputChatBox("" [id]" #FFFF00lhe transferiu #FFFF00R$" .. player .. " #FFFF00!", toWho, 255, 255, 255, true) else outputChatBox("#FFFF00Você não selecionou um jogador da lista!", source, 255, 255, 255,true) end else outputChatBox("#FFFF00Você não tem dinheiro suficiente!", source, 255, 255, 255,true) end else outputChatBox("#FFFF00 O valor mínimo de transferências é R$ 200 !", source, 255, 255, 255,true) end end end ) function setAnimation(animationBlock,animationID) if getElementData(source,"PlayerCaido") then outputChatBox("#FFFF00Você não pode usar animações enquanto espera por um samu.", source, 255, 255, 255, true) return end setPedAnimation(source,animationBlock,animationID) end addEvent("setAnimation",true) addEventHandler ("setAnimation",root,setAnimation) function PararAnS() if getElementData(source,"PlayerCaido") then outputChatBox("#FFFF00Você não pode usar animações enquanto espera por um samu.", source, 255, 255, 255, true) return end setPedAnimation(source,nil,nil) end addEvent("setAnimationNil",true) addEventHandler ("setAnimationNil",root,PararAnS) GroupName = "Mecanico" GroupName2 = "Uber" GroupName3 = "Policia" GroupName4 = "SAMU" function ChamarPolicia () local x, y, z = getElementPosition(source) local loc = getZoneName ( x, y, z ) local city = getZoneName ( x, y, z, true ) outputChatBox("#00BFFFVocê chamou a policia, aguarde.", source, 255, 255, 255, true) for theKey,player in ipairs (getElementsByType("player")) do local accName = getAccountName ( getPlayerAccount ( player ) ) if ( isObjectInACLGroup ("user."..accName, aclGetGroup ( GroupName2 ) ) or isObjectInACLGroup ("user."..accName, aclGetGroup ( GroupName3 ) ) or isObjectInACLGroup ("user."..accName, aclGetGroup ( GroupName4 ) ) or isObjectInACLGroup ("user."..accName, aclGetGroup ( GroupName5 ) ) or isObjectInACLGroup ("user."..accName, aclGetGroup ( GroupName6 ) ) ) then outputChatBox("#00BFFF"..getPlayerName(source).." precisa de um policial em "..loc.." ("..city..")", player, 255, 255, 255, true) displayServerMessage(player, ""..getPlayerName(source).." precisa de um policial em "..loc.." ("..city..")", "warning") local blip = createBlipAttachedTo ( source, 30 ) setElementVisibleTo(blip, root, false) setElementVisibleTo(blip, player, true) setTimer ( function() destroyElement(blip) end, 270000, 1) end end end addEvent( "ChamarAPolicia", true ) addEventHandler( "ChamarAPolicia", root, ChamarPolicia) function ChamarSamu () local x, y, z = getElementPosition(source) local loc = getZoneName ( x, y, z ) local city = getZoneName ( x, y, z, true ) outputChatBox("#FF0000Você chamou os médicos, aguarde.", source, 255, 255, 255, true) for theKey,player in ipairs (getElementsByType("player")) do local accName = getAccountName ( getPlayerAccount ( player ) ) if ( isObjectInACLGroup ("user."..accName, aclGetGroup ( GroupName4) ) ) then outputChatBox("#FF0000"..getPlayerName(source).." precisa do SAMU em "..loc.." ("..city..")", player, 255, 255, 255, true) displayServerMessage(player, ""..getPlayerName(source).." precisa do SAMU em "..loc.." ("..city..")", "warning") local blip = createBlipAttachedTo ( source, 22 ) setElementVisibleTo(blip, root, false) setElementVisibleTo(blip, player, true) setTimer ( function() destroyElement(blip) end, 270000, 1) end end end addEvent( "ChamarOSamu", true ) addEventHandler( "ChamarOSamu", root, ChamarSamu) function ChamarMecanico () local x, y, z = getElementPosition(source) local loc = getZoneName ( x, y, z ) local city = getZoneName ( x, y, z, true ) outputChatBox("#FFFF00Você chamou um mecânico, aguarde.", source, 255, 255, 255, true) for theKey,player in ipairs (getElementsByType("player")) do local accName = getAccountName ( getPlayerAccount ( player ) ) if ( isObjectInACLGroup ("user."..accName, aclGetGroup ( GroupName) ) ) then outputChatBox("#FFFF00"..getPlayerName(source).." precisa de um mecânico em "..loc.." ("..city..")", player, 255, 255, 255, true) displayServerMessage(player, ""..getPlayerName(source).." precisa de um mecânico em "..loc.." ("..city..")", "warning") local blip = createBlipAttachedTo ( source, 27 ) setElementVisibleTo(blip, root, false) setElementVisibleTo(blip, player, true) setTimer ( function() destroyElement(blip) end, 270000, 1) end end end addEvent( "ChamarOMecanico", true ) addEventHandler( "ChamarOMecanico", root, ChamarMecanico) function ChamarTaxista () local x, y, z = getElementPosition(source) local loc = getZoneName ( x, y, z ) local city = getZoneName ( x, y, z, true ) outputChatBox("#00FFFFVocê chamou um uber, aguarde.", source, 255, 255, 255, true) for theKey,player in ipairs (getElementsByType("player")) do local accName = getAccountName ( getPlayerAccount ( player ) ) if ( isObjectInACLGroup ("user."..accName, aclGetGroup ( GroupName2) ) ) then outputChatBox("#00FFFF"..getPlayerName(source).." precisa de um uber em "..loc.." ("..city.."), localize-o em seu GPS", player, 255, 255, 255, true) displayServerMessage(player, ""..getPlayerName(source).." precisa de um uber em "..loc.." ("..city.."), localize-o em seu GPS", "warning") local blip = createBlipAttachedTo ( source, 56 ) setElementVisibleTo(blip, root, false) setElementVisibleTo(blip, player, true) setTimer ( function() destroyElement(blip) end, 270000, 1) end end end addEvent( "ChamarOTaxista", true ) addEventHandler( "ChamarOTaxista", root, ChamarTaxista) function ErroL () outputChatBox("#FFFF00Você não pode enviar a localização para sí mesmo.", source, 255, 255, 255, true) end addEvent( "ErroLoc", true ) addEventHandler( "ErroLoc", root, ErroL) function EnviarL (player) local x, y, z = getElementPosition(source) local loc = getZoneName ( x, y, z ) local city = getZoneName ( x, y, z, true ) outputChatBox("#FFFF00Você mandou sua localização para "..getPlayerName(player), source, 255, 255, 255, true) outputChatBox("#FFFF00"..getPlayerName(source).." enviou a própria localização para você. "..loc.." ("..city..")", player, 255, 255, 255, true) local blip = createBlipAttachedTo ( source, 41 ) setElementVisibleTo(blip, root, false) setElementVisibleTo(blip, player, true) setTimer ( function() destroyElement(blip) end, 270000, 1) end addEvent( "EnviarLocalizacao", true ) addEventHandler( "EnviarLocalizacao", root, EnviarL) -----------------------------------Policia local chatSystemDB = dbConnect( 'sqlite', 'Chat System - Database.db' ) dbExec( chatSystemDB, 'CREATE TABLE IF NOT EXISTS `Chat_System` (sourceSerial, blockedSerial)' ) addEvent( 'onServerCheckShow', true ); addEventHandler( 'onServerCheckShow', root, function( player, name ) if ( player and player ~= source ) then triggerClientEvent( player, 'onClientShowWrite', source, source, name ) end end ); addEvent( 'onServerCheckHide', true ); addEventHandler( 'onServerCheckHide', root, function( player ) if ( player and player ~= source ) then triggerClientEvent( player, 'onClientHideWrite', source, source ) end end ); addEvent( 'onServerCheckIfBlocked', true ); addEventHandler( 'onServerCheckIfBlocked', root, function( serial ) local check = dbQuery( chatSystemDB, 'SELECT * FROM `Chat_System` WHERE sourceSerial = ? AND blockedSerial = ?', getPlayerSerial( source ), serial ) local results = dbPoll( check, -1 ) if ( type( results ) == 'table' and #results ~= 0 ) then outputChatBox( '#FF0000• ERROR :#FFFFFF Sorry, You cannot send a message to this player .. it\'s blocked !', source, 255, 255, 255, true ) return end local check = dbQuery( chatSystemDB, 'SELECT * FROM `Chat_System` WHERE sourceSerial = ? AND blockedSerial = ?', serial, getPlayerSerial( source ) ) local results = dbPoll( check, -1 ) if ( type( results ) == 'table' and #results ~= 0 ) then outputChatBox( '#FF0000• ERROR :#FFFFFF Sorry, You cannot send a message to this player .. he was blocked you !', source, 255, 255, 255, true ) return end triggerClientEvent( source, 'buildChattingWith', source ) end ); addEvent( 'onServerSendPoke', true ); addEventHandler( 'onServerSendPoke', root, function( player, serial ) local check = dbQuery( chatSystemDB, 'SELECT * FROM `Chat_System` WHERE sourceSerial = ? AND blockedSerial = ?', getPlayerSerial( source ), serial ) local results = dbPoll( check, -1 ) if ( type( results ) == 'table' and #results ~= 0 ) then outputChatBox( '#FF0000• ERROR :#FFFFFF Sorry, You cannot send a poke to this player .. it\'s blocked or he was blocked you !', source, 255, 255, 255, true ) return end if ( getElementData( player, 'chatStatus' ) == 'Offline' ) then outputChatBox( '#FF0000• ERROR :#FFFFFF Sorry, You cannot send a poke to this player .. it\'s offline !', source, 255, 255, 255, true ) return end triggerClientEvent( player, 'onClientPokePlayer', source, getPlayerName( source ) ) end ); addEvent( 'onServerCheckBlockStatus', true ); addEventHandler( 'onServerCheckBlockStatus', root, function( serial ) local check = dbQuery( chatSystemDB, 'SELECT * FROM `Chat_System` WHERE sourceSerial = ? AND blockedSerial = ?', getPlayerSerial( source ), serial ) local results = dbPoll( check, -1 ) if ( type( results ) == 'table' and #results == 0 or not results ) then triggerClientEvent( source, 'onClientChangeButton', source, 'Block Player' ) return end triggerClientEvent( source, 'onClientChangeButton', source, 'Unblock Player' ) end ); addEvent( 'onServerBlockPlayer', true ); addEventHandler( 'onServerBlockPlayer', root, function( serial, player ) local check = dbQuery( chatSystemDB, 'SELECT * FROM `Chat_System` WHERE sourceSerial = ? AND blockedSerial = ?', getPlayerSerial( source ), serial ) local results = dbPoll( check, -1 ) if ( type( results ) == 'table' and #results ~= 0 ) then return end dbExec( chatSystemDB, 'INSERT INTO `Chat_System` VALUES(?,?)', getPlayerSerial( source ), serial ) triggerClientEvent( source, 'onClientChangeButton', source, 'Desbloquear Player' ) triggerClientEvent( player, 'onClientDestroyChats', source, source ) triggerClientEvent( source, 'onClientDestroyChats', source, player ) end ); addEvent( 'onServerUnblockPlayer', true ); addEventHandler( 'onServerUnblockPlayer', root, function( serial ) local check = dbQuery( chatSystemDB, 'SELECT * FROM `Chat_System` WHERE sourceSerial = ? AND blockedSerial = ?', getPlayerSerial( source ), serial ) local results = dbPoll( check, -1 ) if ( type( results ) == 'table' and #results == 0 or not results ) then triggerClientEvent( source, 'onClientChangeButton', source, 'Block Player' ) return end dbExec( chatSystemDB, 'DELETE FROM `Chat_System` WHERE sourceSerial = ? AND blockedSerial = ?', getPlayerSerial( source ), serial ) triggerClientEvent( source, 'onClientChangeButton', source, 'Block Player' ) end ); addEventHandler( 'onPlayerJoin', getRootElement( ), function( ) triggerClientEvent( root, 'onClientAddPlayer', source, source ) end ); addEventHandler( 'onPlayerQuit', getRootElement( ), function( ) triggerClientEvent( root, 'onClientRemovePlayer', source, source ) end ); addEventHandler( 'onPlayerChangeNick', getRootElement( ), function( old, new ) triggerClientEvent( root, 'onClientRemovePlayer_ChangedName', source, source, old ) end ); addEvent( 'onServerSetPlayerSerial', true ); addEventHandler( 'onServerSetPlayerSerial', root, function( ) setElementData( source, 'chatSystem;playerSerial', getPlayerSerial( source ) ) end ); addEvent( 'onServerChangeStatus', true ); addEventHandler( 'onServerChangeStatus', root, function( Status ) triggerClientEvent( root, 'onClientUpdateStatus', source, source, Status ) end ); addEvent( 'onServerSendMessage', true ); addEventHandler( 'onServerSendMessage', root, function( plr, message ) triggerClientEvent( plr, 'onClientReceiveMessage', source, source, message ) end ); addEvent( 'onServerPutPlayers', true ); addEventHandler( 'onServerPutPlayers', root, function( ) for _, player in ipairs( getElementsByType( 'player' ) ) do local plrName = getPlayerName( player ) local plrStatus = getElementData( player, 'privateChatSystem;playerStatus' ) or 'Online' triggerClientEvent( root, 'onClientPutPlayers', player, plrName, plrStatus ) end end ); --------Chat function ScriptCellRR() local jogadores = getElementsByType("player") for _, player in ipairs(jogadores) do local conta = getPlayerAccount(player) local conta2 = getAccountName(getPlayerAccount(player)) if isGuestAccount(conta) then return else if isObjectInACLGroup("user." .. conta2, aclGetGroup("PMERJ")) then setElementData(player, "cpolicia", true) end end end end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), ScriptCellRR) function CarregarPolAoLogar(_, account) local conta2 = getAccountName(getPlayerAccount(source)) if isObjectInACLGroup("user." .. conta2, aclGetGroup("PMERJ")) then setElementData(source, "cpolicia", true) end end addEventHandler("onPlayerLogin", getRootElement(), CarregarPolAoLogar) -- //#Mensages function displayServerMessage(source, message, type) triggerClientEvent(source, "servermessagesCelular", getRootElement(), message, type) end Link to comment
DNL291 Posted September 16, 2019 Share Posted September 16, 2019 Vai precisar editar o client e trocar o campo do player pelo id. No lado server você vai utilizar o parâmetro who para o ID do player e passar na função getPlayerID para obter o player element. Link to comment
Anderson Mello Posted May 17, 2020 Share Posted May 17, 2020 On 16/09/2019 at 11:25, DNL291 said: Vai precisar editar o client e trocar o campo do player pelo id. No lado server você vai utilizar o parâmetro who para o ID do player e passar na função getPlayerID para obter o player element. Eu tentei fazer da maneira que você explicou porém não estou conseguindo ele sempre cai com uma mensagem "Você não selecionou um jogador da lista!" 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