Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.
GTAONLINE.PL
Tematy otagowane jako: działanie
1. Działanie skryptu tylko z elementdata
Witam, jak zrobi? aby akcja wywal by?a tylko na pojazdach z elementdat? vehicle:id??


    
function getPointFromDistanceRotation(x, y, dist, angle)

    
local a = math.rad(90 - angle);
 
    
local dx = math.cos(a) * dist;
    
local dy = math.sin(a) * dist;
 
    return 
x+dx, y+dy;
 
end
function findRotation( x1, y1, x2, y2 ) 
    
local t = -math.deg( math.atan2( x2 - x1, y2 - y1 ) )
    return 
t < 0 and t + 360 or t
end
addEventHandler
("onClientVehicleCollision", root,
    function(
collider,force, bodyPart, x, y, z, nx, ny, nz)
    if ( 
source == getPedOccupiedVehicle(localPlayer) ) then
    
if getElementData(veh,"vehicle:id") then
    
if collider==nil then
    
if force>1100 then
    local px
,py,pz=getElementPosition(getPedOccupiedVehicle(localPlayer))
    
local dx,dy=getPointFromDistanceRotation(x,y,2,-findRotation(px,py,x,y))
    
triggerServerEvent("wywal",localPlayer,localPlayer,dx-px,dy-py)
    
    
    
end
    end
    end
    end
)

2. Proste działanie
Witam, ot?? mam ma?y problem z owym b??dem:

attempt to perform arithmetic on field 
'?' (a userdata value)

Pr?buje zrobi? kalkulator prosty i zaczo?em od prostego dzia?ania x + x = y
Oczywi?cie na editboxach. Jak to naprawi? pr?bowa?em ju? sposobu guiGetText lecz te? nie dzia?a.
kod

local calc
={
edit={},
}
calc.edit[1] = guiCreateEdit(994, 663, 32, 28, "", false)
guiSetVisible(calc.edit[1], false)
calc.edit[2] = guiCreateEdit(1081, 663, 32, 28, "", false)
guiSetVisible(calc.edit[2], false)
calc.edit[3] =  guiCreateEdit(1160, 661, 47, 34, "", false)
guiSetVisible(calc.edit[3], false)

    if 
isMouseIn(screenW * 0.5427, screenH * 0.7148, screenW * 0.0938, screenH * 0.0481)  and page == "9"  then
        playSound
("click.mp3")                
            
local dodawanie = (calc.edit[1]) + (calc.edit[2])
            
dodawanie = calc.edit[3]
    
end

B??d znajduje si? w tej linijce

            local dodawanie 
= (calc.edit[1]) + (calc.edit[2])
3. działanie funkcji destroyElement
Witam, pisze prace oparta na client side i mam problem z destroy element.
w evencie (wy?ej) mam:

marker 
= createMarker (...)


a po wyj?ciu z pojazdu (server side) mam event, kt?ry usuwa marker, czyli importuje z client side na server side. u?y?em tam:

if isElement (marker) then
destroyElement 
(marker)
end

lecz nic si? nie dzieje, tzn nie usuwa markera. prosz? o pomoc
4. Działanie "destroyElement"
Witam, w jaki spos?b dzia?a destroyElement, bardzo cz?sto mam z ni? problemy i chcia?bym si? dowiedzie?. Poprosz? r?wnie? jaki? przyk?ad
5. lokalne działanie funkcji
Witam, posiadam taki kod po stronie serwera, chcia?bym abym m?g? leczy? gracza tylko w obr?bie kilku metr?w ( aby nie by?o sytuacji ze mozna leczyc gracza z drugiego konca mapy).
Potrzebuje jeszcze co? takiego, ?e je?li gracz jest zdrowy NIE mo?na go leczy? tzn. nie pobiera od niego pieniedzy i nie daje mu hp. Jak to zrobi? ?

addEvent
("Ulecz", true)
addEventHandler("Ulecz", root, function(gracz)
if 
not gracz then return end
setElementHealth
(gracz, 100)
takePlayerMoney(gracz, 50)
givePlayerMoney(client, 50)
outputChatBox("[POGOTOWIE] Zosta?e? uleczony przez lekarza. Op?ata pobrana.", gracz)
outputChatBox("[POGOTOWIE] Uleczy?e? chorego, pacjent zap?aci? za leczenie.", client)
end
)
6. Nie odpowiednie działanie
Trzecim moim problemem jest Suszarka.

Rzecz jest w tym, ?e wysiadaj?c z auta ona przestaje dzia?a? i nie sprawdza kogo to pojazd tak jak powinna to robi?.

[lua]local sw,sh = guiGetScreenSize()

function onSuszarka(target)
if target then
if getElementType(target) == "vehicle" then
vehicle = target
end
end
end
addEventHandler ("onClientPlayerTarget", getRootElement(), onSuszarka)

function wlaczLPM()
render = true
end
bindKey ("mouse1", "down", wlaczLPM)

function wylaczLPM()
render = false
end
bindKey ("mouse1", "up", wylaczLPM)

function dxDrawSuszarkaInfo()
if render then
if vehicle then
if isElement(vehicle) then
--if getPlayerTeam(localPlayer) == getTeamFromName("Policja") then --zamiast Policja dowolna nazwa teamu, wazne by w cudzyslowiu (i taki team faktycznie istnial :P )
if getPedWeapon(localPlayer) == 22 then
local x, y, z = getElementPosition(localPlayer)
local tx, ty, tz = getElementPosition(vehicle)
local dis = getDistanceBetweenPoints3D(x, y, z, tx, ty, tz)
local id = getElementData(vehicle, "car_id") or "Brak ID pojazdu"
local wl = getElementData(vehicle, "car_owner") or "Brak W?a?cicela"
if 80 >= dis then --jestesmy dosyc blisko gracza
local kmh = getVehicleSpeed(vehicle)
dxDrawRectangle(1115/1440*sw, 401/900*sh,...
7. [GF] Nie prawidłowe działanie komendy.
Kod:

else if(opcja==6)
{
tmp = strtok(cmdtext, idx);
if(isnull(tmp))
{
GuiInfo(playerid,""BIALY"U?yj: "ADMIN"/adom 6 (id domu)");
return 1;
}
new numer = strval(tmp);
if(DomInfo[numer][dAktywny]==true)
{
GetPlayerPos(playerid,DomInfo[numer][dWyjscieX],DomInfo[numer][dWyjscieY],DomInfo[numer][dWyjscieZ]);
DomInfo[numer][dWyjscieInt]=GetPlayerInterior(playerid);
DomInfo[numer][dWyjscieVir]=GetPlayerVirtualWorld(playerid);
GuiInfo(playerid,""MAPA"Zmieni?e? interior tego domu!");
return 1;
}
else
{
GuiInfo(playerid,""ADMIN"Nie poprawne id domu!");
}
return 1;
}


Niby wszystko jest prawie ok jednak komenda dzia?a?a gdy mia?em "bWyjscieVir" tyle ?e wstawia?a interior ale nie ustawia?o Wirtualnego ?wiata a r?cznie nie ma sensu ustawia?. W tej chwili mam errrora i prosi?bym o pomoc w naprawieniu.

Kod:

D:r??neserverWPRL.pwn(46595) : error 017: undefined symbol "dWyjscieVir"