abu5lf Posted March 19, 2012 Share 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, Link to comment
myonlake Posted March 19, 2012 Share 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) Link to comment
abu5lf Posted March 19, 2012 Author Share Posted March 19, 2012 Did not work anything, did not work also Link to comment
Castillo Posted March 19, 2012 Share 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 Link to comment
abu5lf Posted March 20, 2012 Author Share 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 Link to comment
abu5lf Posted March 20, 2012 Author Share Posted March 20, 2012 You very much , but the codes colors show ! How to delete ? In GetPlayerName Link to comment
Absence2 Posted March 20, 2012 Share 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 Link to comment
abu5lf Posted March 20, 2012 Author Share 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 Link to comment
Moderators IIYAMA Posted March 20, 2012 Moderators Share 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) Link to comment
Castillo Posted March 20, 2012 Share 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. Link to comment
abu5lf Posted March 20, 2012 Author Share 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 ? Link to comment
Castillo Posted March 20, 2012 Share 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 Link to comment
abu5lf Posted March 21, 2012 Author Share 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 Link to comment
CapY Posted March 21, 2012 Share 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) 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