abu5lf Posted March 19, 2012 Posted March 19, 2012 server side triggerClientEvent("new", getRootElement(),message) restriction = {} addCommandHandler("roll", function(thePlayer) local playerName = getPlayerName(thePlayer) if restriction[playerName] then local sMessage = "You have to wait 30 seconds" outputChatBox(sMessage, thePlayer, 255, 0, 0) else restriction[playerName] = true setTimer(restrictionEnd, 100, 1, playerName) randomroll = math.random(1, 3000) roller = math.random(1, 4) Weapon = math.random(1, 40) if roller == 1 then givePlayerMoney(thePlayer, randomroll) local sMessage = playerName .. '#FFFF00 roll and wins ' .. randomroll .. ' !' outputChatBox(sMessage, getRootElement(), 255, 255, 0, true) elseif roller == 2 then local sMessage = playerName .. ' roll and is now changed the Weapon ' .. Weapon .. '!' giveWeapon(thePlayer, Weapon) outputChatBox(sMessage, getRootElement(), 255, 255, 0, true) end end end ) function restrictionEnd(playerName) restriction[playerName] = nil end client side addEvent( 'new', true ) local sMessage = '' function fStart( sText ) sMessage = sText end function fDraw( ) if sMessage ~= '' then dxDrawText ( "message :", 17.0, 189.0, 61.0, 206.0, tocolor( 255,0,0,255 ), 1.0, "default-bold", "left", "top", false, false, false ) dxDrawText ( sMessage, 61.0, 189.0, 264.0, 226.0, tocolor( 255,225,225,255 ), 1.0, "default-bold", "left", "top", false, false, false ) end end addEventHandler( 'new', root, fStart ) addEventHandler( 'onClientRender', root, fDraw ) , 1.0, ╔═╦╦╦╗╔╦═╦═╦═╦═╦╦╦╦╦╦╦═╦╦╦╦╗ ║║║║║╠╝║║╚╣║║║║║║║║║║║║║║║║║ ║║║║║╚╦╦═╦╦╦╦╣║║║║║║║║║║║║║║ ║║║║╠═╣╠╝╔══╝║║║║║╟╢║║║║║╟╢║ ╚╩══╩══╩═╩═══╩╩══╩╩═╩╩╩═╩╩═╝ «سبحانك اللهم وبحمدك أشهد أن لا إله إلا أنت أستغفرك وأتوب إليك» M7mdAl7arthy : لتواصل سكايب
myonlake Posted March 19, 2012 Posted March 19, 2012 Commands Roll your dice: /roll Server-side triggerClientEvent("new", root, message) local restriction = {} addCommandHandler("roll", function(player, cmd) local playerName = getPlayerName(player) if restriction[playerName] then local sMessage = "You have to wait 30 seconds" outputChatBox(sMessage, player, 255, 0, 0) else restriction[playerName] = true setTimer(restrictionEnd, 100, 1, playerName) local randomroll = math.random(1, 3000) local roller = math.random(1, 4) local weapon = math.random(1, 40) if roller == 1 then givePlayerMoney(player, randomroll) local sMessage = playerName .. '#FFFF00 roll and wins ' .. randomroll .. ' !' outputChatBox(sMessage, root, 255, 255, 0, true) elseif roller == 2 then local sMessage = playerName .. ' roll and is now changed the Weapon ' .. Weapon .. '!' giveWeapon(player, weapon) outputChatBox(sMessage, root, 255, 255, 0, true) end end end ) function restrictionEnd(playerName) restriction[playerName] = nil end Client-side local sMessage = '' function fStart(sText) sMessage = sText end function fDraw() if sMessage ~= '' then dxDrawText("message :", 17.0, 189.0, 61.0, 206.0, tocolor(255, 0, 0, 255), 1.0, "default-bold", "left", "top", false, false, false) dxDrawText(sMessage, 61.0, 189.0, 264.0, 226.0, tocolor(255, 225, 225, 255), 1.0, "default-bold", "left", "top", false, false, false) end end addEvent("new", true) addEventHandler("new", root, fStart) addEventHandler("onClientRender", root, fDraw) If I helped you, please click the like button on the right Thanks!
abu5lf Posted March 19, 2012 Author Posted March 19, 2012 Did not work anything, did not work also ╔═╦╦╦╗╔╦═╦═╦═╦═╦╦╦╦╦╦╦═╦╦╦╦╗ ║║║║║╠╝║║╚╣║║║║║║║║║║║║║║║║║ ║║║║║╚╦╦═╦╦╦╦╣║║║║║║║║║║║║║║ ║║║║╠═╣╠╝╔══╝║║║║║╟╢║║║║║╟╢║ ╚╩══╩══╩═╩═══╩╩══╩╩═╩╩╩═╩╩═╝ «سبحانك اللهم وبحمدك أشهد أن لا إله إلا أنت أستغفرك وأتوب إليك» M7mdAl7arthy : لتواصل سكايب
Castillo Posted March 19, 2012 Posted March 19, 2012 -- client side: local sMessage = '' function fStart(sText) sMessage = sText end function fDraw() if sMessage ~= '' then dxDrawText("message :", 17.0, 189.0, 61.0, 206.0, tocolor(255, 0, 0, 255), 1.0, "default-bold", "left", "top", false, false, false) dxDrawText(sMessage, 61.0, 189.0, 264.0, 226.0, tocolor(255, 225, 225, 255), 1.0, "default-bold", "left", "top", false, false, false) end end addEvent("new", true) addEventHandler("new", root, fStart) addEventHandler("onClientRender", root, fDraw) -- server side: local restriction = {} addCommandHandler("roll", function(player, cmd) local playerName = getPlayerName ( player ) if restriction[player] then local sMessage = "You have to wait 30 seconds" outputChatBox(sMessage, player, 255, 0, 0) else restriction[player] = true setTimer(restrictionEnd, 30000, 1, player) local randomroll = math.random(1, 3000) local roller = math.random(1, 4) local weapon = math.random(1, 40) if ( roller == 1 ) then givePlayerMoney(player, randomroll) local sMessage = playerName .. '#FFFF00 roll and wins ' .. randomroll .. ' !' triggerClientEvent("new", root, sMessage) elseif ( roller == 2 ) then local sMessage = playerName .. ' roll and is now changed the Weapon ' .. getWeaponNameFromID ( weapon ) .. '!' giveWeapon(player, weapon) triggerClientEvent("new", root, sMessage) else local sMessage = "Good luck next time!" outputChatBox ( sMessage, player, 255, 0, 0) end end end ) function restrictionEnd(player) restriction[player] = nil end San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
abu5lf Posted March 20, 2012 Author Posted March 20, 2012 (edited) You very much , but the codes colors show ! How to delete ? ---------- Does the message appear in front of everyone? Edited March 20, 2012 by Guest ╔═╦╦╦╗╔╦═╦═╦═╦═╦╦╦╦╦╦╦═╦╦╦╦╗ ║║║║║╠╝║║╚╣║║║║║║║║║║║║║║║║║ ║║║║║╚╦╦═╦╦╦╦╣║║║║║║║║║║║║║║ ║║║║╠═╣╠╝╔══╝║║║║║╟╢║║║║║╟╢║ ╚╩══╩══╩═╩═══╩╩══╩╩═╩╩╩═╩╩═╝ «سبحانك اللهم وبحمدك أشهد أن لا إله إلا أنت أستغفرك وأتوب إليك» M7mdAl7arthy : لتواصل سكايب
abu5lf Posted March 20, 2012 Author Posted March 20, 2012 You very much , but the codes colors show ! How to delete ? In GetPlayerName ╔═╦╦╦╗╔╦═╦═╦═╦═╦╦╦╦╦╦╦═╦╦╦╦╗ ║║║║║╠╝║║╚╣║║║║║║║║║║║║║║║║║ ║║║║║╚╦╦═╦╦╦╦╣║║║║║║║║║║║║║║ ║║║║╠═╣╠╝╔══╝║║║║║╟╢║║║║║╟╢║ ╚╩══╩══╩═╩═══╩╩══╩╩═╩╩╩═╩╩═╝ «سبحانك اللهم وبحمدك أشهد أن لا إله إلا أنت أستغفرك وأتوب إليك» M7mdAl7arthy : لتواصل سكايب
Absence2 Posted March 20, 2012 Posted March 20, 2012 local restriction = {} addCommandHandler("roll", function(player, cmd) local playerName = getPlayerName ( player ) if restriction[player] then local sMessage = "You have to wait 30 seconds" outputChatBox(sMessage, player, 255, 0, 0) else restriction[player] = true setTimer(restrictionEnd, 30000, 1, player) local randomroll = math.random(1, 3000) local roller = math.random(1, 4) local weapon = math.random(1, 40) if ( roller == 1 ) then givePlayerMoney(player, randomroll) local sMessage = playerName .. ' roll and wins ' .. randomroll .. ' !' triggerClientEvent("new", root, sMessage) elseif ( roller == 2 ) then local sMessage = playerName .. ' roll and is now changed the Weapon ' .. getWeaponNameFromID ( weapon ) .. '!' giveWeapon(player, weapon) triggerClientEvent("new", root, sMessage) else local sMessage = "Good luck next time!" outputChatBox ( sMessage, player, 255, 0, 0) end end end ) function restrictionEnd(player) restriction[player] = nil end
abu5lf Posted March 20, 2012 Author Posted March 20, 2012 local restriction = {} addCommandHandler("roll", function(player, cmd) local playerName = getPlayerName ( player ) if restriction[player] then local sMessage = "You have to wait 30 seconds" outputChatBox(sMessage, player, 255, 0, 0) else restriction[player] = true setTimer(restrictionEnd, 30000, 1, player) local randomroll = math.random(1, 3000) local roller = math.random(1, 4) local weapon = math.random(1, 40) if ( roller == 1 ) then givePlayerMoney(player, randomroll) local sMessage = playerName .. ' roll and wins ' .. randomroll .. ' !' triggerClientEvent("new", root, sMessage) elseif ( roller == 2 ) then local sMessage = playerName .. ' roll and is now changed the Weapon ' .. getWeaponNameFromID ( weapon ) .. '!' giveWeapon(player, weapon) triggerClientEvent("new", root, sMessage) else local sMessage = "Good luck next time!" outputChatBox ( sMessage, player, 255, 0, 0) end end end ) function restrictionEnd(player) restriction[player] = nil end I mean you name the player ╔═╦╦╦╗╔╦═╦═╦═╦═╦╦╦╦╦╦╦═╦╦╦╦╗ ║║║║║╠╝║║╚╣║║║║║║║║║║║║║║║║║ ║║║║║╚╦╦═╦╦╦╦╣║║║║║║║║║║║║║║ ║║║║╠═╣╠╝╔══╝║║║║║╟╢║║║║║╟╢║ ╚╩══╩══╩═╩═══╩╩══╩╩═╩╩╩═╩╩═╝ «سبحانك اللهم وبحمدك أشهد أن لا إله إلا أنت أستغفرك وأتوب إليك» M7mdAl7arthy : لتواصل سكايب
Moderators IIYAMA Posted March 20, 2012 Moderators Posted March 20, 2012 I don't get what you mean. You mean this? outputChatBox(sMessage, player, 255, 0, 0) This is the outputchatbox inclusive color. R G B Now my question, are you a pro/normal scripter or are somebody that add scrips? I get ... (omg I hate your avatar) Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Castillo Posted March 20, 2012 Posted March 20, 2012 You very much , but the codes colors show ! How to delete ? ---------- Does the message appear in front of everyone? local restriction = {} addCommandHandler("roll", function(player, cmd) local playerName = getPlayerName ( player ):gsub ( "#%x%x%x%x%x%x", "" ) if restriction[player] then local sMessage = "You have to wait 30 seconds" outputChatBox(sMessage, player, 255, 0, 0) else restriction[player] = true setTimer(restrictionEnd, 30000, 1, player) local randomroll = math.random(1, 3000) local roller = math.random(1, 4) local weapon = math.random(1, 40) if ( roller == 1 ) then givePlayerMoney(player, randomroll) local sMessage = playerName .. '#FFFF00 roll and wins ' .. randomroll .. ' !' triggerClientEvent("new", root, sMessage) elseif ( roller == 2 ) then local sMessage = playerName .. ' roll and is now changed the Weapon ' .. getWeaponNameFromID ( weapon ) .. '!' giveWeapon(player, weapon) triggerClientEvent("new", root, sMessage) else local sMessage = "Good luck next time!" outputChatBox ( sMessage, player, 255, 0, 0) end end end ) function restrictionEnd(player) restriction[player] = nil end That'll remove the HEX colors. And yes, it'll appear to everyone. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
abu5lf Posted March 20, 2012 Author Posted March 20, 2012 You very much , but the codes colors show ! How to delete ? ---------- Does the message appear in front of everyone? local restriction = {} addCommandHandler("roll", function(player, cmd) local playerName = getPlayerName ( player ):gsub ( "#%x%x%x%x%x%x", "" ) if restriction[player] then local sMessage = "You have to wait 30 seconds" outputChatBox(sMessage, player, 255, 0, 0) else restriction[player] = true setTimer(restrictionEnd, 30000, 1, player) local randomroll = math.random(1, 3000) local roller = math.random(1, 4) local weapon = math.random(1, 40) if ( roller == 1 ) then givePlayerMoney(player, randomroll) local sMessage = playerName .. '#FFFF00 roll and wins ' .. randomroll .. ' !' triggerClientEvent("new", root, sMessage) elseif ( roller == 2 ) then local sMessage = playerName .. ' roll and is now changed the Weapon ' .. getWeaponNameFromID ( weapon ) .. '!' giveWeapon(player, weapon) triggerClientEvent("new", root, sMessage) else local sMessage = "Good luck next time!" outputChatBox ( sMessage, player, 255, 0, 0) end end end ) function restrictionEnd(player) restriction[player] = nil end That'll remove the HEX colors. And yes, it'll appear to everyone. How can I make it appear on the same player only ? ╔═╦╦╦╗╔╦═╦═╦═╦═╦╦╦╦╦╦╦═╦╦╦╦╗ ║║║║║╠╝║║╚╣║║║║║║║║║║║║║║║║║ ║║║║║╚╦╦═╦╦╦╦╣║║║║║║║║║║║║║║ ║║║║╠═╣╠╝╔══╝║║║║║╟╢║║║║║╟╢║ ╚╩══╩══╩═╩═══╩╩══╩╩═╩╩╩═╩╩═╝ «سبحانك اللهم وبحمدك أشهد أن لا إله إلا أنت أستغفرك وأتوب إليك» M7mdAl7arthy : لتواصل سكايب
Castillo Posted March 20, 2012 Posted March 20, 2012 You want to make it appear just to the player who used the command? if so: local restriction = {} addCommandHandler("roll", function(player, cmd) local playerName = getPlayerName ( player ):gsub ( "#%x%x%x%x%x%x", "" ) if restriction[player] then local sMessage = "You have to wait 30 seconds" outputChatBox(sMessage, player, 255, 0, 0) else restriction[player] = true setTimer(restrictionEnd, 30000, 1, player) local randomroll = math.random(1, 3000) local roller = math.random(1, 4) local weapon = math.random(1, 40) if ( roller == 1 ) then givePlayerMoney(player, randomroll) local sMessage = playerName .. '#FFFF00 roll and wins ' .. randomroll .. ' !' triggerClientEvent( player, "new", player, sMessage) elseif ( roller == 2 ) then local sMessage = playerName .. ' roll and is now changed the Weapon ' .. getWeaponNameFromID ( weapon ) .. '!' giveWeapon(player, weapon) triggerClientEvent( player, "new", player, sMessage) else local sMessage = "Good luck next time!" outputChatBox ( sMessage, player, 255, 0, 0) end end end ) function restrictionEnd(player) restriction[player] = nil end San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
abu5lf Posted March 21, 2012 Author Posted March 21, 2012 local sMessage = '' function fStart(sText) sMessage = sText end setTimer ( function fDraw() if sMessage ~= '' then dxDrawText("Roll :", 17.0, 189.0, 61.0, 206.0, tocolor(255, 255, 0, 255), 1.0, "default-bold", "center", "bottom", false, false, false) dxDrawText(sMessage, 61.0, 189.0, 264.0, 226.0, tocolor(0, 225, 0, 255), 1.0, "default-bold", "center", "bottom", false, false, false, false) end end function ( ) removeEventHandler ( "onClientRender", root, ffDraw ) end ,1500,1 ) addEvent("new", true) addEventHandler("new", root, fStart) addEventHandler("onClientRender", root, fDraw) Removal did not work ╔═╦╦╦╗╔╦═╦═╦═╦═╦╦╦╦╦╦╦═╦╦╦╦╗ ║║║║║╠╝║║╚╣║║║║║║║║║║║║║║║║║ ║║║║║╚╦╦═╦╦╦╦╣║║║║║║║║║║║║║║ ║║║║╠═╣╠╝╔══╝║║║║║╟╢║║║║║╟╢║ ╚╩══╩══╩═╩═══╩╩══╩╩═╩╩╩═╩╩═╝ «سبحانك اللهم وبحمدك أشهد أن لا إله إلا أنت أستغفرك وأتوب إليك» M7mdAl7arthy : لتواصل سكايب
CapY Posted March 21, 2012 Posted March 21, 2012 local sMessage = '' function fStart(sText) sMessage = sText end function fDraw() if sMessage ~= '' then dxDrawText("Roll :", 17.0, 189.0, 61.0, 206.0, tocolor(255, 255, 0, 255), 1.0, "default-bold", "center", "bottom", false, false, false) dxDrawText(sMessage, 61.0, 189.0, 264.0, 226.0, tocolor(0, 225, 0, 255), 1.0, "default-bold", "center", "bottom", false, false, false, false) end setTimer ( function ( ) removeEventHandler ( "onClientRender", root, ffDraw ) end ,1500,1) end addEvent("new", true) addEventHandler("new", root, fStart) addEventHandler("onClientRender", root, fDraw)
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