Witam mam problem z jednym skryptem bo mam zrobione ze klikajac U w??cza si? kr?tkofal?wka i wszystk ogra ale jest jeden problem poniewa? ten skrypt wyswietla si? na ca?y serwer a ja bym chcia? by np. gracz w teamie Policja,Straz Pozarna,Pogotowie mogli u?ywa? ta krotkofalowke i jeszcze by tylko ci co sa w teamie Policja,Straz,Pogotowie tylko oni widzieli ta rozmowe na krotkofalowce jezeli kto? mnie nie zrozumia? postaram si? bardziej wyt?umaczy? KOD
addCommandHandler("Kr?tkofal?wka", function(plr, cmd, ...)
local r,g,b = getTeamColor(getPlayerTeam(plr))
local x,y,z = getElementPosition(plr)
local msg = table.concat(arg, " ")
if getTeamName(getPlayerTeam(plr)) == "NAZWA TEAMU" then
for i,v in ipairs(getElementsByType("player")) do
playSoundFrontEnd(v, 49)
outputChatBox("#ffe300* #FF0000Kr?tkofal?wka#ffe300: #0047FF"..msg,v,r,g,b,true)
end
end
end)
if isPlayerInRangeOfPoint(v,px,py,pz,chat_range) then
?
aha, a gdzie zmienna chat_range? usun??em ci ten warunek.
Split, git ale nie wpadle? dobrze bo napisa?em ze chce tam doda? 3 teamy nie jeden i pozmieniales mi tam w
addCommander
bo ca?y kod jest taki
chat_range=100
addEventHandler("onPlayerJoin",getRootElement(),
function ()
bindKey(source,"u","down","chatbox","Kr?tkofal?wka")
end)
addEventHandler("onResourceStart",getResourceRootElement(getThisResource()),
function ()
for index, player in pairs(getElementsByType("player")) do
bindKey(player,"u","down","chatbox","Kr?tkofal?wka")
end
end)
function isPlayerInRangeOfPoint(player,x,y,z,range)
local px,py,pz=getElementPosition(player)
return ((x-px)^2+(y-py)^2+(z-pz)^2)^0.5<=range
end
function onChat( player,_,...)
local px,py,pz=getElementPosition(player)
local msg = table.concat({...}, " ")
local nick=getPlayerName(player)
local r,g,b = getTeamColor(getPlayerTeam(player))
for _,v in ipairs(getElementsByType("player")) do
if isPlayerInRangeOfPoint(v,px,py,pz,chat_range) then
outputChatBox("#ffe300* #FF0000Kr?tkofal?wka#ffe300: #0047FF"..msg,v,r,g,b,true)
end
end
end
addCommandHandler("Kr?tkofal?wka",onChat)
addCommandHandler("Kr?tkofal?wka", function(plr, cmd, ...)
local r,g,b = getTeamColor(getPlayerTeam(plr))
local x,y,z = getElementPosition(plr)
local msg = table.concat(arg, " ")
if getTeamName(getPlayerTeam(plr)) == "NAZWA TEAMU" or getTeamName(getPlayerTeam(plr)) == "NAZWA TEAMU" or getTeamName(getPlayerTeam(plr)) == "NAZWA TEAMU" then
for i,v in ipairs(getElementsByType("player")) do
playSoundFrontEnd(v, 49)
outputChatBox("#ffe300* #FF0000Kr?tkofal?wka#ffe300: #0047FF"..msg,v,r,g,b,true)
end
end
end)
[ Dodano: 2014-12-15, 21:35 ] Split, przepraszam nie ten kod wzioem oke split jest git ale nie ma tego souda i nie chce aby ka?dy gracz co nie jest w teamie mogl uzy? "U" chce aby mu napisalo tak "Nie Masz Uprawnien Do Krotkofalowki"
addCommandHandler("Kr?tkofal?wka", function(plr, cmd, ...)
if getTeamName(getPlayerTeam(plr)) == "NAZWA TEAMU" or getTeamName(getPlayerTeam(plr)) == "NAZWA TEAMU" or getTeamName(getPlayerTeam(plr)) == "NAZWA TEAMU" then
local r,g,b = getTeamColor(getPlayerTeam(plr))
local x,y,z = getElementPosition(plr)
local msg = table.concat(arg, " ")
for i,v in ipairs(getElementsByType("player")) do
if getTeamName(getPlayerTeam(v)) == "NAZWA TEAMU" or getTeamName(getPlayerTeam(v)) == "NAZWA TEAMU" or getTeamName(getPlayerTeam(v)) == "NAZWA TEAMU" then
playSoundFrontEnd(v, 49)
outputChatBox("#ffe300* #FF0000Kr?tkofal?wka#ffe300: #0047FF"..msg,v,r,g,b,true)
end
end
else
outputChatBox("Nie masz uprawnie?!", plr)
end
end)
Ostatnio zmieniony przez Terr9909 2014-12-16, 18:05, w całości zmieniany 1 raz
tak jak napisa?em na poczatku gracz w teamie Policja,Pogotowie,Straz Pozarna mog? u?ywa? Krotkofalowki gracz z innego teamu NIE MO?E ma mu pisac ze nie ma uprawnien i jeszcze aby gracze z tego teamu Policja,Pogotowie,Straz Pozarna mieli text z tej krotkofalowki.
addCommandHandler ( "krotkofalowka", function ( plr, cmd, ... )
if ... then
if getPlayerTeam ( plr ) then
if getTeamName ( getPlayerTeam ( plr ) ) ~= "Policja" or "Pogotowie" or "Stra? Po?arna" then
return outputChatBox ( "Nie masz uprawnie?", plr ) end
team = getPlayerTeam ( plr )
for _,v in ipairs ( getPlayersInTeam ( team ) ) do
outputChatBox ( table.concat ( {...}, " " ), v )
end
end
end
end)
Nie możesz pisać nowych tematów Nie możesz odpowiadać w tematach Nie możesz zmieniać swoich postów Nie możesz usuwać swoich postów Nie możesz głosować w ankietach