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: nil
1. Attempt to compare nil with number
Hej! Mam problem jakiego dozna?em podczas pisania kodu do zasobu virtualparking dla s?u?b na w?asny serwer. Niestety, co? posz?o nie tak, i przy wyborze jakiegokolwiek samochodu z parkingu, wyrzuca komunikat:

ERROR: [factions]/virtualparking/s.lua:242attempt to compare nil with number


242 linijka mojego kodu:

if getElementData(player,"player:rank") < 1 then exports["factions-noti"]:notierror("#ff0000Nie posiadasz wystarczaj?cej rangi aby skorzysta? z tego pojazdu",player) return end


pr?bowa?em w taki spos?b, ale dalej nic z tego..
if tonumber(getElementData(localPlayer,"player:rank")) < 1 then
2. attempt to compare number with nil - pokazuje 13 linia blad
s=Vector2(guiGetScreenSize())
msgs={}

types={
[1]={"succes.png"},
[2]={"info.png"},
[3]={"error.png"},
}

function newNoti(el,txt,type)
if el==localPlayer then
if type>3 or type<0 or not tonumber(type) then
type=2
end
local type=types[type][1]
table.insert(msgs,{txt=txt,typ=type,easingFunction="Linear",startTime=getTickCount(),endTime=getTickCount()+5000})
end
end

addCommandHandler("dodaj",function(cmd,typ,...)
local msg=table.concat({...}," ")
newNoti(localPlayer,msg,tonumber(type))
end)

addEventHandler("onClientRender",root,function()
offset=0
for _,v in ipairs(msgs)do
local now = getTickCount()
local elapsedTime = now - v.startTime
local duration = v.endTime - v.startTime
local progress = elapsedTime / duration

local fAnimationTime = getEasingValue(progress, v.easingFunction)

local alpha = (1-fAnimationTime)*255
if alpha<0 then
table.remove(msgs,1)
end
dxDrawRectangle(15, 638+offset, 391, 62, tocolor(57, 57, 57, 182), false)
dxDrawImage(201, 676+offset, 0, 0, v.typ, 0, 0, 0, tocolor(255, 255, 255, alpha), false)
dxDrawImage(822, 428+offset, 0, 0,v.typ, 0, 0, 0, tocolor(255, 255, 255, alpha), false)
dxDrawImage(742, 393+offset, 0, 53, v.typ, 0, 0, 0, tocolor(255, 255, 255, alpha), false)
dxDrawImage(15, 636+offset, 391, 64...
3. A nil value przy ShowPlayerHudComponentVisible
Siema, mam problemik, gdy? zrobi?em testowy hud a mam problem z podana w nazwie funkcj?.
Tu macie kod i b??d:
B??D: attempt to call 'ShowPlayerHudComponentVisible' (a nil value)

Kod:

hud
={}
czescihuda={
    {
"ammo","armour","clock","health","money","weapon","wanted"}
}

hud.font=dxCreateFont("font.ttf",15,false,"antialiased")
hud.font2=dxCreateFont("font.ttf",20,false,"antialiased")
hud.font3=dxCreateFont("font.ttf",20,false,"antialiased")
hud.font4=dxCreateFont("font.ttf",15,false,"antialiased")



addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),function()
    for 
i=1,#czescihuda[1] do
        
showPlayerHudComponentVisible(czescihuda[1][i], false)
    
end
end
)
4. attempt to compare number with nil
zacz??em powoli rozumie? mysql i no korzysta? z tego dobrodziejstwa lecz co? mi nie wychodzi

      
function biznesNowe(thePlayertarget)
id getElementData(thePlayer"dbid")
zapomnialemoTym  mysql:query_fetch_assoc("SELECT * FROM `characters` WHERE `Liderbiznesu` = '?' AND `id` = '"..id.."'")
    if 
zapomnialemoTym 0 then
        outputChatBox
("komunikat!",thePlayer,255,255,255)
end
end

na samym pocz?tku by?o samo ? tego '
ps. nada?em se wartosc 1 ale raczej wychodzi? mi taki b??d jak w tytule
5. attempt to call global 'guiCreateWindow' (a nil value)
takie co? mi wyskoczy?o i nie wiem co zrobi? wszystko jest ok, ale jak uruchamiam skrypt taki oto komunikat


okno 
guiCreateWindow(0.360.420.200.07"nazwa"true)
6. nil value i ipairs
for kv in ipairs (playersOnPoliceTeam and getPlayersInTeamgetTeamFromName"Los Santos Police Department" ) ) ) do


a w debugscripcie wyswietla sie to -
bad argument #1 to 'ipairs' [table excepted, got boolean
7. Button nil value
Witam posiadam frakcje z gm PSSM i we frakcji SAPD nie moge wyciaga? pojazd?w z prakingu wirtualnego.


[lua]local screenW, screenH = guiGetScreenSize()

function pokazgui()
exports["buttons"]:createCustomWindow("Wirtualny Parking", screenW * 0.2016, screenH * 0.2286, screenW * 0.6092, screenH * 0.5805, tocolor(255, 255, 255, 255), false)
exports["buttons"]:createCustomButton("Akademia", screenW * 0.2192, screenH * 0.3019, screenW * 0.1094, screenH * 0.0600, tocolor(255,255,255,255), false)
exports["buttons"]:createCustomButton("Radiow?z", screenW * 0.3692, screenH * 0.3019, screenW * 0.1094, screenH * 0.0600, tocolor(255,255,255,255), false)
exports["buttons"]:createCustomButton("Radiow?z2", screenW * 0.5292, screenH * 0.3019, screenW * 0.1094, screenH * 0.0600, tocolor(255,255,255,255), false)
exports["buttons"]:createCustomButton("Merit", screenW * 0.6792, screenH * 0.3019, screenW * 0.1094, screenH * 0.0600, tocolor(255,255,255,255), false)
exports["buttons"]:createCustomButton("Enforcer", screenW * 0.2192, screenH * 0.4019, screenW * 0.1094, screenH * 0.0600, tocolor(255,255,255,255), false)
exports["buttons"]:createCustomButton("Premier", screenW * 0.3692, screenH * 0.4019, screenW * 0.1094, screenH * 0.0600, tocolor(255,255,255,255), false)
exports["buttons"]:createCustomButton("Holownik", screenW ...
8. attempt to call global 'playSound' (a nil value)
my?l? i my?l? jak zrobi? by nie wywala?o wciska?em wsz?dzie ju?
attempt to call global 'playSound' (a nil value)

[lua]addCommandHandler("b", function(plr,cmd,cel,x,bantype,...)
if BWADMIN(plr,3) or BWADMIN(plr,2) or BWADMIN(plr,1) or BWADMIN(plr,5) or BWADMIN(plr,4) or BWADMIN(plr,7) then
local reason=table.concat({...}, " ")
if not cel or not tonumber(x) or not bantype or not reason then
--outputChatBox("#007aff(ⓘ) #FFFFFFU?ycie: /b <nick/ID> <ilo??> <m/h/d> <pow?d>", plr, 255,255,255, true)
triggerClientEvent(plr, 'onClientAddNotification', plr, "U?ycie: /b <nick/ID> <ilo??> <m/h/d> <pow?d>nm - Minuty h - Godziny d - Dni ", 'info')
return
end
local target=exports["bw-core"]:findPlayer(plr,cel)
if not target then
triggerClientEvent(plr, 'onClientAddNotification', plr, "Nie znaleziono podanego gracza.", 'error')
return
end
if (BWADMIN(plr,7) == false) and BWADMIN(target,7) then return end
if target then
local muza = playSound("ban.mp3") return
end
--reason = reason.." |od "..getPlayerName(plr):gsub("#%x%x%x%x%x%x","").."|"
if bantype=="m" or bantype=="h" or bantype=="d" then
if bantype=="m" then
exports["bw-db"]:bazaustaw("INSERT INTO bw_zbanowanij (serial,reason,time,type) VALUES (?,?,NOW() +...
9. attempt to index local 'getnajwyzszydim' (a nil value)
mam problem z kodem 27 linia local dim=split(getnajwyzszydim.intdim_wnetrza,",")

[lua]addCommandHandler("adddomek2",
function(plr,cmd,cena,miejsca_parkingowe,id_interioru,id_garazu,pozycja_wyjscia)
if not iswlasciciel(plr) and (getElementData(plr,"dbid")~=1) then
return
end
if not cena or not tonumber(cena) or not miejsca_parkingowe or not id_interioru or not id_garazu then
exports["komunikaty"]:komunikat("/adddomek [cena] [miejsca_parkingowe] [id_interioru <0-23>] [id_garazu] [x,y,z_wyjscia]", plr)
return
end
local z_i=nil
for i,v in ipairs(inside) do
if (tonumber(id_interioru)==i) then
z_i=v
end
end
if not z_i then
exports["komunikaty"]:komunikat("Nieprawid?owy identyfikator interioru.", plr)
return
end
local pozycja=string.format("%s,%s,%s", z_i.poz[1], z_i.poz[2], z_i.poz[3])
if not pozycja_wyjscia then
local px,py,pz=getElementPosition(plr)
pozycja_wyjscia=string.format("%s,%s,%s", px,py,pz)
end
local pozycja_markera=string.format("%s,%s,%s", z_i.marker_wejscie[1], z_i.marker_wejscie[2], z_i.marker_wejscie[3])
local getnajwyzszydim=exports.DB:pobierzWyniki("SELECT intdim_wnetrza FROM domy ORDER BY id DESC LIMIT 1")
local dim=split(getnajwyzszydim.intdim_wnetrza,",")
dim=tonumber(dim[2])
dim=dim+1
addDomek(plr,cena,miejsca_parkingowe,pozycja,z_i....
10. attempt to compare number with nil
[lua]
bindKey("mouse1", "down", function()
if kliki > 99 then
setElementData(localPlayer, "mozna:klikac:drwal", false)
kliki = 0
end
end)
addEventHandler("onClientMarkerHit", markerNapad , function()
triggerServerEvent("giveMoney", localPlayer, pieniadz)
exports["np-notyfikacje"]:noti(" wykonano: "..kasa.."$")
local kasa = math.random(10, 200)
gui(localPlayer)
kliki = kliki+1
end)

[/lua]
nie pokazuje GUI a pokazuje ,?e z t? linijk? jest cos nie tak
if kliki > 99 then

natomiast kod gui wygl?da tak
[lua]
function gui()
setElementData(localPlayer, "mozna:klikac:drwal", true)
if kliki > 99 then return end
addEventHandler("onClientRender", root, function()
if not getElementData(localPlayer, "mozna:klikac:drwal") then return end
dxDrawText("Klikaj, aby ?ci?? drzewon"..kliki.."/100", (288+1)*px, (253-1)*py, (766+1)*px, (435-1)*py, tocolor(0, 0, 0, 255), 3.00*px, "default-bold", "center", "top", false, false, false, false, false)
dxDrawText("Klikaj, aby ?ci?? drzewon"..kliki.."/100", (288-1)*px, (253+1)*py, (766-1)*px, (435+1)*py, tocolor(0, 0, 0, 255), 3.00*px, "default-bold", "center", "top", ...
11. skrypty/s.lua:90 attempt to index filed '?' (a nil value)
ERROR: skrypty/s.lua:90 attempt to index filed '?' (a nil value)

function load_magazynier_table()
    
local q exports.MXL_dbb:mysql_query("select * from MXL_users order by punkty_magazynier desc")
    
local ranking_table = {}

    for 
1,do
>>>
90        table.insert(ranking_tableq[i]["login"]..": "..q[i]["punkty_magazynier"].." punkt?w")
    
end

    
return ranking_table
end
12. attempt to call global 'guiCreateWindow' (a nil value)
DB 3 pokazuje error w 7 linijce :

Kod:

attempt to call global 'guiCreateWindow' (a nil value)



 local okno guiCreateWindow(0.350.290.300.43"Lista log?w serwerowych"true
13. PHP | zwracanie tylko nil
Witam, mam problem, ot?? ten kod u?y?em w CallRemote, wszystko fajnie dzia?a, wysy?a wiadomo?? na maila:
Kod:


try {
$mailer->SMTPDebug = 2;
$mailer->isSMTP();

if ($developmentMode) {
$mailer->SMTPOptions = [
'ssl'=> [
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
]
];
}


$mailer->Host = 'z';
$mailer->SMTPAuth = true;
$mailer->Username = 'z';
$mailer->Password = 'z';
$mailer->SMTPSecure = 'z';
$mailer->Port = z;

$mailer->setFrom('z', 'Administrator z');
$mailer->addAddress($target, 'Gracz z');
$mailer->isHTML(true);
$mailer->Subject = $subject;
$mailer->Body = $message;

$mailer->send();
mta::doReturn(true,$player);

$mailer->ClearAllRecipients();

} catch (Exception $e) {
echo "EMAIL SENDING FAILED. INFO: " . $mailer->ErrorInfo;
}

Natomiast, mimo u?ycia mta::doReturn zwraca tylko nil.
Z g?ry dzi?kuj?.
14. a nil value
witam robi? system ban?w lecz nie wiem co jest tak kod
end
            setElementData
(client"player:uid"result[1].id)
                if (
isPlayerBanned(source)) then return end

            triggerClientEvent
(client"logging:result"resourceRoottrue"Zalogowa?e? si? pomyslnie","git")
b??d:s_logging.lua:80: attempt to call global 'isPlayerBanned' (a nil value) jest to sprawek kodu my?l? ?e pomo?e kto?
15. attempt to call global 'getAdmin' (a nil value)
Witam co? nie ??czy nie wiem o co chodzi pr?bowa?em co? zmienia? ale nie dzia?a.

B??d : ERROR: [skrypty]/YL-pojazdy/s_vehbuy.lua:278: attempt to call global 'getAdmin' (a nil value)


Skrypt:

addEventHandler
("onVehicleStartEnter"resourceRoot, function(plr,seat,jacked)
    if 
seat == 0 then
        local rent
=getElementData(source"vehicle:rent")
        
local group=getElementData(source"vehicle:ownedGroup")
        if 
group == "0" then group "Brak" end
        local player
=getElementData(source"vehicle:ownedPlayer")
        if (
getAdmin(plr,4)) then
            
return
        
end
        
if rent and (type(rent) == "table"then
            
for i,s in pairs(rent) do
                if 
tonumber(s) == getElementData(plr,"player:sid"then
                
return end
            end
        end
        
        local plrgroup 
getElementData(plr,"player:organization")
        if 
plrgroup then
            
if getSettings(plr,false,"organization") == group then return end
        end
        
if player and player ~= getSettings(plr,false,"owner"then
            outputChatBox
("* Nie posiadasz kluczyk?w do tego pojazdu."plr)
            
cancelEvent()
        
end
    end
end
)
16. a nil value
db3
attempt to call global '3DResim' (a nil value)

ta funkcja
[lua]
function _3DResim(TheElement,Image,distance,height,width,R,G,B,alpha)
local x, y, z = getElementPosition(TheElement)
local x2, y2, z2 = getElementPosition(localPlayer)
local distance = distance or 20
local height = height or 1
local width = width or 1
local checkBuildings = checkBuildings or true
local checkPeds = checkPeds or false
local checkObjects = checkObjects or true
local checkDummies = checkDummies or true
local seeThroughStuff = seeThroughStuff or false
local ignoreSomeObjectsForCamera = ignoreSomeObjectsForCamera or false
local ignoredElement = ignoredElement or nil
if (isLineOfSightClear(x, y, z, x2, y2, z2, checkBuildings, checkPeds , checkObjects,checkDummies,seeThroughStuff,ignoreSomeObjectsForCamera,ignoredElement)) then
local sx, sy = getScreenFromWorldPosition(x, y, z+height)
if(sx) and (sy) then
local distanceBetweenPoints = getDistanceBetweenPoints3D(x, y, z, x2, y2, z2)
if(distanceBetweenPoints < distance) then
dxDrawMaterialLine3D(x, y, z+1+height-(distanceBetweenPoints/distance), x, y, z+height, Image, width-(distanceBetweenPoints/dis...
17. attempt to call global 'mysql_connect' (a nil value)
Witam, mam problem z skryptem DB
Wyskakuje mi taki b?ad jak w temacie.
18. attempt to concatenate global (a nil value)
No wi?c 3 dni temu zacz??em nauk? j?zyka Lua (chc? w przysz?o?ci postawi? jaki? serwer MTA:SA) i postanowi?em na swoje pierwsze zadanie wykona? prost? prac? dowoziciela Pizzy. W pewnym momencie gracz musi stan?? w obr?bie markera, b?d?c na skuterze. I problem w tym, ?e mam problem ze sprawdzeniem tego - wyskakuje b??d.

Po stronie clienta za ka?dym razem, gdy wsi?dzie w jakikolwiek pojazd jest zapisywana zmienna z jego nazw?:

[lua]
function checkVehicles()
theVehicle = getPedOccupiedVehicle(source)
pojazd = getVehicleName(theVehicle)
end
addEventHandler("onClientPlayerVehicleEnter",getRootElement(),checkVehicles)
[/lua]


a po stronie serwera jest utworzony marker i funkcja przywo?uj?ca zmienn? pojazd (t? po stronie clienta):

[lua]
marker = createMarker(2101.810546875,-1806.984375,11.5546875, 'cylinder', 4.0, 255,100,0,100)

function MarkerHit( hitElement, matchingDimension )
local elementType = getElementType( hitElement )
outputChatBox( elementType.." inside myMarker", getRootElement(), 255, 255, 0 )
outputChatBox("pojazd: "..pojazd)
end
addEventHandler( "onMarkerHit", marker, MarkerHit )
[/lua]


No i przy wej?ciu w marker w okienku czatu, ?e player wszed? w marker, przy wjechaniu skuterem, wyskakuje ?e player i vehicle - co jest wporzadku. Problem jest z t? dan? pojazd. W konsoli przy ka?dym wej?ciu w marker pojawia si? komunikat:

ERROR: mojserverscript.lua:66: attempt to concatenate glo...
19. [MySQL] Połączenie bazy danych (a nil value)
M?j problem wygl?da na b??dzie po??czenia MySQL tzn
Kod:

ERROR: [skrypty_glowne]/ogrpg-db/s_db.lua:53: attempt to call global 'mysql_connect' (a nil value)

Nie mam poj?cia w czym jest problem, wszystko jest po??czone tak jak nale?y lecz nie wiem z jakiego powodu wyskakuje ten b??d.. Za pomoc PIWO :D
20. SMS API - attempt to index a nil value
Do zamkni?cia :)
21. attempt to index field '?' (a nil value)
Mam tak? komende i ona poprawnie nie dzia?a w logach wyskakuje taki b??d
server.lua:288: attempt to index field '?' (a nil value)






addCommandHandler
("kp",
function(
plr,cmd,car_id)
    
local car_idtonumber(car_id)
    
local PrivCarOwner getElementData(PrivCarSystem.DATA[player_id].vehicle,"PrivOwnerCar") --tutaj jest nick gracza (288 linijka)
    
local players getPlayerFromName(PrivCarOwner)
    
setElementData(players ,"PrivCarId"0)
end)
22. baza danych zwraca nil
Chcia?bym pobra? z bazy danych model samochodu, jaki ma si? zrespi?, lecz niestety baza danych zwraca nil, zamiast modelu. B??d: Bad argument @ 'createVehicle' [Expected number at argument 1, got nil]

addEventHandler("onResourceStart"resourceRoot
    function()
        
baza dbConnect("sqlite""vehicles.db")
    
end
)

addCommandHandler("spawn",
    function(
playerSource)
        
local query dbQuery(baza"SELECT ? FROM `cars` WHERE owner=?""model"getAccountName(getPlayerAccount(playerSource)))
        
local result dbPoll(query, -1)
        
outputDebugString(tostring(result))
        
local posXposYposZ getElementPosition(playerSource)
        
createVehicle(tonumber(result[1]), posXposYposZ)
        
dbFree(query)
    
end
)
23. Debugging (a nil value)
Runtime error at line -1:.....logowaniec_logo.lua:23. attempt to call global 'getRootElement' (a nil value). Podobny error po stronie serwera w 1 linijce. Nie dzia?a r?wnie? triggering - my?la?em z godzink? i za nic nie wiem co jest nie tak.
CLIENT:
[code]GUIEditor = {
window = {},
button = {},
label = {},
edit ={}
}

function pokazLogowanie()
GUIEditor.window[1] = guiCreateWindow(150, 169, 996, 417, "Panel Logowania", false)
guiWindowSetMovable(GUIEditor.window[1], false)
guiWindowSetSizable(GUIEditor.window[1], false)
button = guiCreateButton(823, 341, 153, 66, "Zaloguj", false, GUIEditor.window[1])
GUIEditor.button[1] = guiCreateButton(19, 341, 153, 66, "Rejestracja", false, GUIEditor.window[1])
GUIEditor.edit[1] = guiCreateEdit(532, 193, 228, 26, "", false, GUIEditor.window[1])
GUIEditor.edit[2] = guiCreateEdit(532, 235, 228, 26, "", false, GUIEditor.window[1])
GUIEditor.label[1] = guiCreateLabel(485, 200, 37, 19, "Login:", false, GUIEditor.window[1])
GUIEditor.label[2] = guiCreateLabel(484, 239, 38, 16, "Haslo:", false, GUIEditor.window[1])
GUIEditor.label[3] = guiCreateLabel(390, 170, 384, 19, "Witaj na serwerze Sunny RolePlay! Wpisz login oraz haslo i zacznij gre!", false, GUIEditor.window[1])
guiSetVisible(GUIEditor.window[1], true)
showCursor(true)
addEventHandler("onClientGUIClick", bu...