Cze??.Chyba troch? si? zap?dzi?em na zamkni?cie tego tematu.Chcem zrobi? triggera po stronie S ?eby w nim hajs dawa?o i wywo?a? go w C.Lecz nie wiem czemu ale mi nie dzia?a.
Trigger:
Cze??,
pisz? w?a?nie skrypt, kt?ry po wej?ciu w marker otwiera GUI, w kt?rym trzeba wpisa? ID pojazdu z nast?pnie zatwierdzi? je, aby auto si? pojawi?o. Kod wylgl?da tak:
Client (sama funkcja, w kt?rej jest u?yty trigger):
local function Spawncara (modelPojazdu) local modelPojazdu = guiGetText(gui.pole) modelPojazdu = tonumber(modelPojazdu)
if modelPojazdu then
triggerServerEvent("pokliknieciu", resourceRoot, modelPojazdu) outputChatBox("Wpisz poprawne ID pojazdu", 255, 0, 0)
else outputChatBox("Wpisz poprawne ID pojazdu", 255, 0, 0) end
end
addEventHandler("onClientGUIClick", gui.przycisk, Spawncara, false)
Server
function zespawnuj (client, modelPojazdu) createVehicle (modelPojazdu, -84.14467, 1114.58337, 19.74997) end
addEvent("pokliknieciu", true) addEventHandler("pokliknieciu", resourceRoot, zespawnuj)
Wyskakuje takie ostrze?enie, pojazd si? nie spawnuje
WARNING: [Deip]Ccarsserwer.lua:2: Bad argument @ 'createVehicle' [Expected number at argument 1, got nil]
witam. Mam funkcje po stronie clienta, w ktorej sa dxdrawtexty i inne duperele, ale chcial bym zrobic, zeby sie to pojawialo po zalogowaniu przez gracza, i jak mam to triggerowac? Jak po stronie clienta po prostu stworzylem event "pozalogowaniu" i w serwerze triggerowalem go w evencie onplayerlogin to nie dzialalo, i w sumie sie nie dziwie, ale nie wiem jak mam to inaczej zrobic, wiec pytam. Dzieki, jak cos to piwko i respekt oferuje.
Siemka, mam problem z triggerowaniem funkcji z servera do clienta.
Tworz? kod po cliencie i chcia?bym aby po wykonaniu czynno?ci o kt?rej jest mowa w c.lua zmieni?o mi handling, i musz? to zrobi? po s.lua i triggerem do clienta.
Lecz nie za bardzo wychodzi mi zrobienie triggera.
Tutaj daje potrzebny kod:
s.lua:
[lua]
function getVehicleHandlingProperty ( element, property )
if isElement ( element ) and getElementType ( element ) == "vehicle" and type ( property ) == "string" then
local handlingTable = getVehicleHandling ( element )
local value = handlingTable[property]
if value then
return value
end
end
return false
end
addEvent("handling", true)
addEventHandler("handling", resourceRoot, function()
local fast = getVehicleHandlingProperty(pVehicle,"engineAcceleration")
local maxfast = getVehicleHandlingProperty(pVehicle,"maxVelocity")
setVehicleHandling(pVehicle,"engineAcceleration",fast+15)
setVehicleHandling(pVehicle, "maxVelocity",maxfast+500)
end)
[/lua]
c.lua:
[lua]
if isPedInVehicle(localPlayer) then
local pVehicle = getPedOccupiedVehicle(localPlayer)
triggerServerEvent("handling", pVehicle, localPlayer)
[/lua]
W cliencie jest jeszcze wcze?niej kod, ale nie jest on potrzebny ?eby go tu poda?, bo chodzi tylko o wykonaniu triggera.
Witam, mimo ?e ca?y skrypt jest dobrze napisany przy wpisywaniu komendy server nie chce triggerowa? clienta.
DB3: server triggered clientside event ILogow, but event is not added clientside
server:
addCommandHandler("logi", function(plr)
if getElementData(plr,"player:uid") == 1 then
local spr = exports["ogrpg-db"]:dbGet("SELECT * FROM ogrpg_logi") triggerClientEvent(plr, "lLogow", plr, spr) end
end)
client:
addEvent("lLogow", true) addEventHandler("lLogow", root, function(s) result = s
guiSetVisible(okno, true) showCursor(true) guiGridListClear(lista)
if not s then return end for _, p in pairs(s) do local spr = guiGridListAddRow(lista) guiGridListSetItemText(lista, spr, 1, p["id"], false, false) guiGridListSetItemText(lista, spr, 2, p["nick"], false, false) guiGridListSetItemText(lista, spr, 3, p["tresc"], false, false) end
end)
Trigger z clienta do clienta nie dziala db3 a nil value. Prosze o pomoc , stawiam piwerko
function sprawdzanieslot2() local thePlayer = getPlayerFromName ( playerName )
if getPlayerCurrentSlots() <= getPlayerMaxAviableSlots() then
triggerClientEvent ("slotymax2", thePlayer)
else triggerClientEvent ("slotypuste2", thePlayer) end
end
setTimer(sprawdzanieslot2, 3000, 0)
Witam mam problem z triggerem eventu do serwera, wywala b??d w db3, kod i db3 podane poni?ej. Stawiam zimne Piwerko!!
Kod:
function sprawdzanieslot(source)
if getPlayerCurrentSlots() <= getPlayerMaxAviableSlots() then
triggerServerEvent (source, "slotymax", source) outputChatBox("Sprawdzenie")
else triggerServerEvent (source, "slotypuste", source) outputChatBox("Sprawdzenie2") end
end
addCommandHandler("spp",sprawdzanieslot)
db3:
Bad argument @ 'triggerServerEvent'[Expected element at argument 2, got string 'slotymax'']
Witam ot?? mam problem z Triggerem eventu do clienta (gracza) ten napis "przeprzekroczy?es limit" dzia?a. Stawiam Piwerko
kod do wysylania eventu:
function newObject(thePlayer)
if maxobjectysciany[client] >= 5 then
outputChatBox("przekroczy?es limit", client) triggerClientEvent (thePlayer, "wylgui", thePlayer) end
end
addCommandHandler("spr",newObject)
odbi?r eventu od servera:
addEvent("wylgui",true)
function wylaczgui () guiSetVisible(baseCPanel.window[1], not guiGetVisible ( baseCPanel.window[1] )) showCursor ( false ) end
addEventHandler("wylgui", root, wylaczgui)
addEventHandler("onVehicleDamage",root,function(plr) local thePlayer = getVehicleOccupant(source)
if getElementModel(getPedOccupiedVehicle(thePlayer))==425 then if getElementHealth(getPedOccupiedVehicle(thePlayer))<51 then
triggerClientEvent(plr,"lowhp",plr) end
end
end)
Witam. Postanowi?em, ?e spr?buje zrobi? ju? jaki? bardziej zaawansowany skrypt, z tabelami etc. Decyzja pad?a na prace dowozu z punktu A do B, lecz pojawi? si? pewien b??d.
Ot?? gdy marker na stacji zostaje uderzony przez cysterne, to nic si? nie dzieje. DB3 nic nie pokazuje.
function wynagrodzenie(plr, praca) import = exports['ogrpg-db']:dbGet('SELECT * FROM zarobki WHERE nazwa=?', praca) Z = import[1]
if Z.aktywnapremia == 'Nie' then if getElementData(plr, 'player:premium') == true then
givePlayerMoney(plr, Z.nazwa, Z.zarobekpremium)
else givePlayerMoney(plr, Z.nazwa, Z.zarobek) end elseif Z.aktywnapremia == 'Tak' then if getElementData(plr, 'player:premium') == true then
givePlayerMoney(plr, Z.nazwa, Z.zarobekpremia*Z.zarobekpremium)
else givePlayerMoney(plr, Z.nazwa, Z.zarobekpremia*Z.zarobek) end
end
end
A w mecie mam export zrobiony tak:
<export function="wynagrodzenie" type="server" />
Wi?kszo?? prac mam po stronie klienta, w zwi?zku z tym moje pytanie:
Jak zrobi? export function po stronie klienta? Chcia?em, ?eby na stronie klienta znajdowa?a si? jedynie funkcja, kt?ra b?dzie triggerowa? na stron? serwera (na funkcj? "wynagrodzenie"), lecz nie wiem jak to napisa? - zawsze mam problemy z pierwszym i trzecim argumentem.
createMarker(1555.32166, -2172.73315, 13.54688-0.90,"cylinder",1,255,0,0) --Chce to po stronie klij?ta
end
addEventHandler("onMarkerHit",marker,rozpraca)
if getElementType(hitElement) == "player" then else return end
local pojazd_egz = createVehicle(609, 2470.16040, -1658.91223, 12.93086) warpPedIntoVehicle ( hitElement, pojazd_egz )
end
addEvent("pojazd", true) addEventHandler("pojazd", root, pojazd1)
C:
local marker_prawo = createMarker( 2483.83643, -1665.55420, 12.34375, "cylinder", 1.5)
function pojazd (hitMark, plr, marker_prawo)
triggerServerEvent("pojazd", localPlayer)
end
addEventHandler("onClientMarkerHit", marker_prawo, pojazd)
Cze??. Zrobi?em skrypt na po?ar, ale chcia?bym, aby widzieli go wszyscy.
local function burn(commandName, theSize)
if tonumber(theSize) then
local x, y, z = getElementPosition(getLocalPlayer()) createFire(x, y, z, tonumber(theSize)) end
end
addEvent( "burn", true ) addEventHandler( "burn", localPlayer, burn )
S-side:
function dass ( gracz ) triggerClientEvent ( gracz, "burn" ) end
addEventHandler ( "onResourceStart", getRootElement(), dass )
Jest jaki? b??d w DB3. M?g?by mi kto? to poprawi??
w jaki spos?b przekaza? dane tak by po stronie server w tym even'cie "genderforwarded" mo?na by?o u?ywa? elementu "source" lub dopisa? do funkcji "player" i to by dzia?a?o, poniewa? u?ywaj?c tego source, oraz po paru testach player okazuje si?, ?e konsola wywala b??d typu expected element at argument.. bla bla.
Witam,
Tworze przechowywalnie i niestety nie wiem jak tego errora naprawi? aby by?o prawid?owo , dla mnie nie wida? zadnego b??du
error:
S-SIDE function aktualizacja() local id = getPlayerName(source) local result = dbExec(przecho,"SELECT * FROM pojazdy WHERE Wlasciciel=? AND przecho=1",id)
if result then
triggerClientEvent(source,"przecho:pojazdy", source, result) end
end
addEvent("przecho:upload",true) addEventHandler("przecho:upload",root,aktualizacja)
C-SIDE
function update(result) guiGridListClear(grindlist)
if not result then return end for i,v in pairs(result) do local row = guiGridListAddRow(grindlist) guiGridListSetItemText(grindlist, row, 1, v["ID"], false, false) guiGridListSetItemText(grindlist, row, 2, getVehicleNameFromModel(v["Model"]), false, false) end
end
addEvent("przecho:pojazdy", true) addEventHandler("przecho:pojazdy", root, update)
S - SIDE[lua]
function banPlayerCommand ( theClient, cmd, nick, reason, time, ... )
local accName = getAccountName ( getPlayerAccount ( theClient ))
if isObjectInACLGroup("user."..accName, aclGetGroup("RCON")) or isObjectInACLGroup("user."..accName, aclGetGroup("Admin")) or isObjectInACLGroup("user."..accName, aclGetGroup("Moderator")) then
if cmd and nick and reason and time then
local who = getPlayerFromName( nick )
if who then
local gracz = getPlayerName( theClient )
local reason = table.concat({...},"")
--banPlayer ( who, theClient, reason, time )
triggerClientEvent(getRootElement(),"ban",root, "nick", "reason", "gracz")
else
outputChatBox("Nie ma takiego gracza na serwerze!", theClient)
end
else
outputChatBox("U?yj: /zbanuj <nick> <pow?d> <czas>", theClient)
end
else
outputChatBox("Nie masz uprawnie? !", theClient)
end
end
addCommandHandler ( "zbanuj", banPlayerCommand )[/lua]
C - SIDE
[lua]addEvent("ban",true)
addEventHandler("ban",root,
function ()
addEventHandler("onClientRender",root,pban)
end
)
Nie wiem czy poprawnie nazwa?em temat (najwyzej zmienie)
Wi?c tak, pr?bowa?em nauczy? si? triggerowania na skryptach YLgames i chcia?em aby skinshop a dok?adnie wybranie skina by?o tylko dla ACL "VIP" i w triggerze serwera da?em takie co? :
addEvent("onPlayerEditSkin", true)
addEventHandler("onPlayerEditSkin", root, function(model)
local accName = getAccountName ( getPlayerAccount ( source ) )
if isObjectInACLGroup ("user."..accName, aclGetGroup ( "VIP" ) ) then
setElementModel(source, model)
setElementData(source, "gracz_ubranie", model)
end
end)
No i w DB3 nic nie wy?wietla a problem jest taki, ?e wybieram skina i mi go ustawia nawet gdy nie jestem w ACL "VIP".
Daje piwko i respekt