golanu21
Members-
Posts
650 -
Joined
-
Last visited
Everything posted by golanu21
-
-- Exemplu de conectare la MySQL local host = "secret"; local dbname = "secret"; local username = "secret"; local password = "secret"; function connectToDB() zombie_db = dbConnect("mysql", "dbname="..dbname..";host="..host, username, password, "autoreconnect=1") return zombie_db end function creeazaTabel() zombie_db = connectToDB() local characters = dbExec( zombie_db, "CREATE TABLE IF NOT EXISTS characters (id INT NOT NULL AUTO_INCREMENT, nume VARCHAR(50) NOT NULL, model INT NOT NULL, health FLOAT NOT NULL, posx FLOAT NOT NULL, posy FLOAT NOT NULL, posz FLOAT NOT NULL, PRIMARY KEY (id))") end addEventHandler("onResourceStart", getRootElement(getThisResource()), creeazaTabel) local zombie_db = connectToDB() ip = 0 addEventHandler("onPlayerJoin", getRootElement(), function () if ip == 0 then local x, y, z = getElementPosition(source) dbExec( zombie_db, "INSERT INTO characters (nume, model, health, posx, posy, posz) VALUES (?,?,?,?,?,?)", getPlayerName(source), getElementModel(source), getElementHealth(source), x, y, z ) ip = 1 elseif ip == 1 then cancelEvent() end end) addEventHandler("onPlayerQuit", getRootElement(), function () zombie_db = connectToDB() dbExec( zombie_db, "UPDATE characters SET nume=?, health=?", getPlayerName(source), getElementHealth(source)) end ) function viataCandSpawneaza() zombie_db = connectToDB() local second = dbQuery( zombie_db, "SELECT * FROM characters WHERE nume=?", getPlayerName(source)) local result, numrows = dbPoll(second, -1) if (result and numrows > 0) then for index, row in pairs(result) do setElementHealth(source, row['health']) end end end addEventHandler ( "onPlayerLogin", getRootElement(), viataCandSpawneaza ) this is the full code, but i fixed it with a variabile 0, and when player join, set variabile 1, and when variabile is 1 cancelevent
-
i show you the full script ?
-
addEventHandler("onPlayerJoin", getRootElement(), function () zombie_db = connectToDB() x, y, z = getElementPosition(source) dbExec( zombie_db, "INSERT INTO characters (nume, model, health, posx, posy, posz) VALUES (?,?,?,?,?,?)", getPlayerName(source), getElementModel(source), getElementHealth(source), x, y, z ) end) why when i enter in game with same name a new row is appear ...with same name and same valors...
-
de fiecare data cand intru cu numele MysterYo, apara alt id cu aceleas valori, acelas nume.. dar id 1 id 2 id 3 de cate ori intru
-
ms, dar uite de exemplu am facut sa salveze viata in baza de date... acuma cum fac cand intra in joc sa ii dea valoarea care e la health ?
-
local characters = dbExec( zombie_db, "CREATE TABLE IF NOT EXISTS characters (id INT PRIMARY KEY NOT NULL, nume CHAR(50) NOT NULL, model INT NOT NULL, health REAL NOT NULL, posx REAL NOT NULL, posy REAL NOT NULL, posz REAL NOT NULL)") aici e problema.. zice ca se dubleaza PRIMARY KEY
-
Acelasi lucru si pentru health => "health" am incercat si asa... dar tot nu functioneaza.. imd dau eroarea
-
alta eroare -- Exemplu de conectare la MySQL local host = "localhost"; local dbname = "zo"; local username = "root"; local password = ""; function connectToDB() zombie_db = dbConnect("mysql", "dbname="..dbname..";host="..host, username, password, "autoreconnect=1") return zombie_db end function creeazaTabel() zombie_db = connectToDB() local characters = dbExec( zombie_db, "CREATE TABLE IF NOT EXISTS characters (id INT PRIMARY KEY NOT NULL, nume CHAR(50) NOT NULL, model INT NOT NULL, health REAL NOT NULL, posx REAL NOT NULL, posy REAL NOT NULL, posz REAL NOT NULL)") end addEventHandler("onResourceStart", getRootElement(getThisResource()), creeazaTabel) addEventHandler("onPlayerJoin", getRootElement(), function () zombie_db = connectToDB() x, y, z = getElementPosition(source) dbExec( zombie_db, "INSERT INTO characters (nume, model, health, posx, posy, posz) VALUES (?,?,?,?,?,?)", getPlayerName(source), getElementModel(source), getElementHealth(source), x, y, z ) end) addEventHandler("onPlayerQuit", getRootElement(), function () zombie_db = connectToDB() dbExec( zombie_db, "UPDATE `??` SET `??`=`?`", "characters", health, getElementHealth(source)) end ) WARNING: cdb\server.lua:32: dbExec failed; (1054) Unknown column '''' in 'field list'
-
yes... Quantumz is deserved to be moderator here... and what you want ...? go to your spain section...
-
+1 P.S.: I retire from being moderator I hope all votes go to him. Why that? Also, QuantumZ said: QuantumZ can't help we any time, but when his help we .... all is finished ..
-
aaa, da corect.. mersi mult ca ma ajuti
-
+1 P.S.: I retire from being moderator I hope all votes go to him.
-
local sWidth, sHeight = guiGetScreenSize (); addEventHandler("onClientRender", root, function() msg = "text" dxDrawText(msg,sWidth/2, sHeight/2, sWidth, sHeight,tocolor(0,255,255,175),1.0,"bankgothic","left","top",false,false,false) end ) for me it's work
-
because i make guys to laugh
-
Doar tablename, column etc. '??' = pentru tabel/coloane ? = pentru valori (ai grija ca dupa query sa fie scrise in ordine numele tabelelor si al coloanelor precum si al valorilor) ai putea sa imi oferi un exemplu te rog ?, ca de exemplu am facut asta dar nu functioneaza.. in DB arata 0 addEventHandler("onPlayerQuit", getRootElement(), function () zombie_db = connectToDB() dbExec( zombie_db, "UPDATE `??` SET `??`=?", characters, health, getElementHealth(source) ) end) si imi da o eroare : WARNING: cdb\server.lua:31: dbExec failed; (1146) Table 'zo.''' doesn't exist
-
function handlingChange() setModelHandling(423, "mass", 10000.0) setModelHandling(423, "turnMass", 50000.0) setModelHandling(423, "dragCoeff", 2.0) setModelHandling(423, "centerOfMass", { 0.0, 0.0, -0.6 } ) setModelHandling(423, "percentSubmerged", 80) setModelHandling(423, "tractionMultiplier", 0.70) setModelHandling(423, "tractionLoss", 0.9) setModelHandling(423, "tractionBias", 0.5) setModelHandling(423, "numberOfGears", 5) setModelHandling(423, "maxVelocity", 154.0) setModelHandling(423, "engineAcceleration", 35.0) setModelHandling(423, "engineInertia", 10.0) setModelHandling(423, "driveType", "awd") setModelHandling(423, "engineType", "petrol") setModelHandling(423, "brakeDeceleration", 11.0) setModelHandling(423, "brakeBias", 0.45) setModelHandling(423, "ABS", false) setModelHandling(423, "steeringLock", 30.0) setModelHandling(423, "suspensionForceLevel", 1.4) setModelHandling(423, "suspensionDamping", 0.10) setModelHandling(423, "suspensionHighSpeedDamping", 0.0) setModelHandling(423, "suspensionUpperLimit", 0.40) setModelHandling(423, "suspensionLowerLimit", -0.40) setModelHandling(423, "suspensionFrontRearBias", 0.5) setModelHandling(423, "suspensionAntiDiveMultiplier", 0.3) setModelHandling(423, "seatOffsetDistance", 0.20) setModelHandling(423, "collisionDamageMultiplier", 0.20) setModelHandling(423, "monetary", 35000) setModelHandling(423, "modelFlags", 0x40006800) setModelHandling(423, "handlingFlags", 0x1300005) setModelHandling(423, "headLight", 9) setModelHandling(423, "tailLight", 1) setModelHandling(423, "animGroup", 0) local hp = getElementHealth(source) if hp == 0 then return end end addEventHandler("onResourceStart", resourceRoot, handlingChange) NOT TESTED
-
addEventHandler("onClientRender", root, function() local screenWidth, screenHeight = guiGetScreenSize ( ) dxDrawText ( msg, 320, screenHeight - 320, screenWidth, screenHeight, tocolor ( 255, 99, 8, 255 ), 2.2, "arial" ) end ) Not tested
-
dbExec( char_db, "UPDATE `??` SET `??`=?", tableName, columnName, columnValue ) aici trebuie sa modific si '''''??'''' sau doar tablename column.. etc
-
ce nui bn ? Edit: acum am vazut si eu ca ai editat ) Edit2: merge perfect, mersi P.S.: tu ai merita sa fi moderator , acum sincer
-
-- Exemplu de conectare la MySQL local host = "localhost"; local dbname = "zo"; local username = "root"; local password = ""; function connectToDB() zombie_db = dbConnect("mysql", "dbname="..dbname..";host="..host, username, password, "autoreconnect=1") return zombie_db end function creeazaTabel() local characters = dbExec( zombie_db, "CREATE TABLE characters (id INT PRIMARY KEY NOT NULL, nume CHAR(50) NOT NULL, model INT NOT NULL, health REAL NOT NULL, posx REAL NOT NULL, posy REAL NOT NULL, posz REAL NOT NULL)") end addEventHandler("onResourceStart", getRootElement(getThisResource()), creeazaTabel) WARNING: cdb\server.lua:15: Bad argument @ 'dbExec' [Expected db-connection at argument 1, got nil]
-
cumva mai tre sa fac dala cu setting.xml... ? ca la valhalla ?
