Jump to content

PauloCascus

Members
  • Posts

    57
  • Joined

  • Last visited

Everything posted by PauloCascus

  1. Hello guys again and again, I have the problem with SQL couze i have not enough knowledge about this: syntax error here is mine lua and SQL it is function to create your character: i don't know all paths are right or not but i have got error with syntax oly in dbExec( connection, "INSERT INTO ....... Some "pro" can to check code and say to me there are all right or i've did mistakes Becouze idk, SQL is hard to me addEventHandler("onResourceStart", resourceRoot, function () connection = dbConnect ("sqlite", "character.db" ) if connection then dbExec ( connection, "CREATE TABLE IF NOT EXISTS character ( account TEXT, heroname TEXT, herolastname TEXT, heroage INT, herocountry TEXT, herolang TEXT) " ) outputDebugString ( "Successfully connected to character database" ) else outputDebugString ( "Failed to connect to character database" ) end end ) function createHero(heroname,herolastname, heroage, herocountry, herolang) if not (heroname == "") then if not (herolastname == "") then if not heroname:find("%W") then if not (heroage == "") then if not (herocountry == "") then if not (herolang == "") then local account = getPlayerAccount(source) local accountname = getAccountName(account) local herona = dbQuery( connection, "SELECT * FROM character ( heroname=?") local heroln = dbQuery( connection, "SELECT * FROM character ( herolastname=?") if not (heroname == herona) and not ( herolastname == heroln ) then dbExec( connection,"INSERT INTO character ( account=?, heroname=?, herolastname=?, heroage=?, herocountry=?, herolang=?", accountname, heroname, herolastname, heroage, herocountry, herolang) triggerClientEvent(source,"changeMessage",getRootElement(),"2","Character seccessfully created","green") else triggerClientEvent(source,"changeMessage",getRootElement(),"2","This name already taken", "red") triggerClientEvent(source,"changeMessage",getRootElement(),"4","", "red") end else triggerClientEvent(source,"changeMessage",getRootElement(),"2","Please enter your language", "red") triggerClientEvent(source,"changeMessage",getRootElement(),"4","", "red") end else triggerClientEvent(source,"changeMessage",getRootElement(),"2","Please enter your country", "red") triggerClientEvent(source,"changeMessage",getRootElement(),"4","", "red") end else triggerClientEvent(source,"changeMessage",getRootElement(),"2","Please enter your birthday date", "red") triggerClientEvent(source,"changeMessage",getRootElement(),"4","", "red") end else triggerClientEvent(source,"changeMessage", getRootElement(), "2","Your name has invalid characters", "red") end else triggerClientEvent(source,"changeMessage", getRootElement(), "2","Please enter your last name", "red") end else triggerClientEvent(source,"changeMessage", getRootElement(), "2","Please enter your name", "red") end end addEvent("createHero",true) addEventHandler("createHero",getRootElement(),createHero)
  2. you mean this wont work? i know that there are mistakes, couze im wrote it like example how to work with xml and what he need to use his xml file i have gave him example and then he need to think how to use it I'm not lua teacher
  3. add the group into the xml group="Admin" and then add into lua server side Additional option to get player ACL group like local xml = xmlLoadFile ("spawn.xml") local class = xmlFindChild(xml,"class",0) local color = xmlFindChild(class,"color",0) local skin = xmlFindChild(class,"skin",0) local spawn = xmlFindChild(class,"spawnpoint",0) local r = xmlNodeGetAttribute(color,"red") local g = xmlNodeGetAttribute(color,"green") local b = xmlNodeGetAttribute(color,"blue") local skinid = xmlNodeGetAttribute(skin,"id") local x = xmlNodeGetAttribute(spawn,"x") local y = xmlNodeGetAttribute(spawn,"y") local z = xmlNodeGetAttribute(spawn,"z") local rot = xmlNodeGetAttribute(spawn,"rot") local acl = xmlNodeGetAttribute(xml, "group") local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) ---------- --and then you need to add this into the spawn script ------- if isObjectInACLGroup ("user."..accName, aclGetGroup ( "..tostring ( acl ).." ) ) then spawnPlayer(source, tonumber(x), tonumber(y), tonumber(z), tonumber(rot), tonumber(skinid)) setPlayerNametagColor(source, tonumber(r), tonumber(g), tonumber(b) end And i think you need to use GUI Panel for this spawn
  4. if username:find("%w") then if (accountAdded) then exports.gtc:sendMessage("You have successfully registered. Username: " .. username .. ", password: " .. password .. " ",0,255,0, source ) triggerClientEvent(source,"hideRegisterWindow",getRootElement()) end else triggerClientEvent(source,"set_warning_text",getRootElement(),"MG:RP Register","Choose a different username or password.") end i have added this, i thought that's it's working but when i'm type only characters like: $%^, i've got error message that you name is invalid, but when i've used Paulo$%^, i 'm registered
  5. oh my god i have the problem, i'm stupid i need to add at the server side something like: if ( username == input:gsub("[^%w]","")) then .................. ............................................... else outputChatBox("Choose another username, you can't use signs like: )(*&^%$#@!" ...... end ? or if (username:gsub("[^%w]","")) then lol i have tested this like if ( username == username:gsud("[^%w]","")) then and when i'm tried to register username like Paulo, i've got, Choose another username When i have tried to use $%^&, i have registered When i use $%^&Paulo registered too
  6. what you need to do it ? why you create fire ? need more info better if you will post a part of lua with createFire function
  7. How i can disallow to use bad signs like: %^&*$#@ and etc when player use registration ?
  8. I'm gonna help you to understand how to use this. So, you want it to be triggered for every police vehicle? I guess you mean you mean to every player who is in a police vehicle. That isn't possible from client-side, unless you want to add unnecesary extra processing both for client and server by triggering events from client and back from server. So, in the server script is where we'll use some of that code you have there. You gotta paste the following in the part where you trigger the client event. Use your common sense to know if there's something to replace, remove, or add; I'm only explaining how to do this particular stuff work, NOT how to make it compatible to your whole code: local polveh = getElementsByType("vehicle") for i, v in ipairs (polveh) do --Let's loop through every policecar if getElementData(polveh,"Service") == "Police" then --I hope the car itself has this element data, not the player pl = getVehicleOccupant(polveh) --Let's only retrieve the player who's the driver of a policecar (it isn't a good idea to trigger the event more than once per car) triggerClientEvent(root, "policeradio", pl) --trigger that client event to EVERY player that exists (hence that "root") end end --This "for" loop will be done for every single policecar, remember that! Now, for the client-side: addEvent("policeradio", true) addEventHandler("policeradio", root, function() local x, y, z = getElementPosition( source ) local polveh = getPedOccupiedVehicle( source ) policeradio = playSound3D("policead.mp3",x,y,z, true) attachElements(polveh, policeradio) end end ) This should work. You can delete my comments (the gray text) when you paste the codes; they're only there to help you understand why and how it all works. Also, remember to eventually destroy the sound! but this sound plays only for player into the police car ?
  9. I'm gonna help you to understand how to use this. So, you want it to be triggered for every police vehicle? I guess you mean you mean to every player who is in a police vehicle. That isn't possible from client-side, unless you want to add unnecesary extra processing both for client and server by triggering events from client and back from server. So, in the server script is where we'll use some of that code you have there. You gotta paste the following in the part where you trigger the client event. Use your common sense to know if there's something to replace, remove, or add; I'm only explaining how to do this particular stuff work, NOT how to make it compatible to your whole code: local polveh = getElementsByType("vehicle") for i, v in ipairs (polveh) do --Let's loop through every policecar if getElementData(polveh,"Service") == "Police" then --I hope the car itself has this element data, not the player pl = getVehicleOccupant(polveh) --Let's only retrieve the player who's the driver of a policecar (it isn't a good idea to trigger the event more than once per car) triggerClientEvent(root, "policeradio", pl) --trigger that client event to EVERY player that exists (hence that "root") end end --This "for" loop will be done for every single policecar, remember that! Now, for the client-side: addEvent("policeradio", true) addEventHandler("policeradio", root, function() local x, y, z = getElementPosition( source ) local polveh = getPedOccupiedVehicle( source ) policeradio = playSound3D("policead.mp3",x,y,z, true) attachElements(polveh, policeradio) end end ) This should work. You can delete my comments (the gray text) when you paste the codes; they're only there to help you understand why and how it all works. Also, remember to eventually destroy the sound! great thanks but i'm not so noob in scripting to do not know that --------- [[]] and other methods like this just like decoder
  10. I want when Bank Robbery will be started, radio into the police cars will advert it for all cops addEvent("policeradio", true) addEventHandler("policeradio", root, function() local polveh = getElementsByType("vehicle") if ( getElementData(polveh,"Service") == "Police" ) then policeradio = playSound3D("policead.mp3",x,y,z, true) attachElements(polveh, policeradio) end end ) but when i have opened first door into the bank, debug string said, that getElementData got table WTF ? I have used it with players and Data: Robbery, Robber or Assistant and there are no problems with table... Then i have tried to use ipairs and then debug string said that: policeradio got table attachElements got table Sadness, i can't to create sound in all police cars at the moment when Bank Robbery starting ?
  11. then no problems, i have fixed it ty for something
  12. What is that for? detection of colshape i'm need just getElemenetsWithinColShape(ColShape,"player" ) yeah ?
  13. sorry but what you means ? I've got this method from HouseRob and it's works there
  14. I want to add get/setElementData to the code like There are bank robbery and i want to takes all players within colshape and set data "Robber" for gang mates of man who opened first door: Robber and Assistant for other addEvent...event of door opening addEventHandler.. door opening too function(Door) if Door=="Door1" then destroyElement....... moveObject....... createMarker...... for i,g in ipairs (getElementsWithinColShape(getElementColShape(colShape),"player")) do local sGang = getElementData(source,"gang", gangName) local pGang = getElementData(g,"gang", gangName ) if sGang == pGang then setElementData(g,"Robbery", robber ) elseif sGang ~= pGang then setElementData(g,"Robbery", assistant) end end //////// When i have starting script all is good But i have opeing door then debug string sending me this : warning : scriptfolder BadArgument @ setElementData [ Expected argument at argument 3, got none ] warning : scriptfolder BadArgument @ getElementsWithinColShape [ expected colshape at argument 1, got boolean ] error ; bad argument #1 in ipairs [ table expected got boolean ] I can send full script only for advenced people
  15. But if i will remove this code, flowers will damage players which i want to heal
  16. When i have added damage blocker into the Client-side, medic stopped to heal .... Anybody can say what's wrong here ? Server-side local skin = {[274]=true, [275] = true, [276]=true} function healFlowers (attacker, attackerweapon, bodypart, loss) theHealth = getElementHealth (source) if not skin[getElementModel(attacker)] then return end if ( theHealth == 100 ) then givePlayerMoney( attacker, 0 ) end if (attackerweapon == 14) and (loss > 1) and ( theHealth < 100 ) then setElementHealth ( source, theHealth+20 ) givePlayerMoney (attacker, 10*theHealth) end end addEventHandler ("onPlayerDamage", getRootElement(), healFlowers ) medicVehicles = { [416]=true } medicSkins = { [274]=true, [275]=true, [276]=true } function medicenterVehicle ( player, seat, jacked ) if ( medicVehicles[getElementModel ( source )] ) and ( not medicSkins[getElementModel ( player )] ) and ( seat == 0 ) then cancelEvent() outputChatBox ( "Only paramedics can drive this vehicle.", player ) end end addEventHandler ( "onVehicleStartEnter", getRootElement(), medicenterVehicle ) Client-side addEventHandler ( "onClientPlayerDamage",localPlayer, function ( attacker, weapon, bodypart) if weapon == 14 then cancelEvent() end end)
  17. oh you set my serial on the white list lol nice it's working ty guys
  18. X .. local Whitelist = { ["080209AF2E09E389F6C55AFB6B5A5A54"] = true, } addEventHandler( "onPlayerConnect", root, function (_, _, _, serial) if not ( Whitelist[ serial ] ) then cancelEvent( true, "You are not on the whitelist" ) end end ) idk maybe i have stupid server, but it's now working too
  19. hey guys i want to create whitelist, but when resource started, debugscrip output this: malformed number near '080209AF2E09E389F6C55AFB6B5A5A54' so i can't create table with serial numbers ? local whitelist = { [080209AF2E09E389F6C55AFB6B5A5A54] } addEventHandler("onPlayerConnect", root, setWhiteList ) function setWhiteList ( source, serial, allow ) local serial = getPlayerSerial ( source ) if serial then local allow = unpack ( whitelist [serialNumber] ) if ( serial == allow ) then end if ( serial ~= allow ) then kick( source, getThisResource(), "You are not in whitelist" ) end end end end
  20. i said about Spawn Name like Drug Dealer i think it must to be as : --- at the beggining of script xml = xmlLoadFile("file.xml") ---------------------------------------------------------- Then player select spawn options and press the button "Spawn" children = xmlFindChild( xml, spawn ) for i,v in ipairs(children) do spawnname = xmlNodeGetAttribute(v,"name") local x = xmlNodeGetAttribute(v,"spawnX") local y = xmlNodeGetAttribute(v,"spawnY") local z = xmlNodeGetAttribute(v,"spawnZ") local rot = xmlNodeGetAttribute (v, "rot" ) local skin = xmlNodeGetAttribute (v, "skin" ) spawnPlayer( source ,x,y,z, rot, skin, 0, 0, name ) end end
  21. Hey guys how i can to use xml file for spawn player I want to create spawn panel with xml but i don't know how synchronize panel with xml file So i thought about it like: local xml = xmlLoadFile ( xmlName ) then will be created GUI panel and when player will press button, function like: local xmlSpawn = xmlNodeGetAttribute ( xml, name ) if xmlSpawn == "SpawnName" then local PosX = xmlNodeGetAttribute ( xml, spawnX ) local PosY = xmlNodeGetAttribute ( xml, spawnY ) local PosZ = xmlNodeGetAttribute ( xml, spawnZ ) local Rot = xmlNodeGetAttribute ( xml, rot ) local Skin = xmlNodeGetAttribute ( xml, skin ) spawnPlayer ( thePlayer, tonumber(PosX), tonumber(PosY), tonumber(PosZ), tonumber(Rot), skin ) but i think i will need to create so many xml's for every spawn... so sadly Somebody can help me and show me a way of using xml, which will be better <spawn name="SpawnName" spawnX="positionX" spawnY="positionY" spawnZ="positionZ" rot="rotation" skin="50"/>
  22. i tried to create signalization it's not work
  23. i tried to create signalization
×
×
  • Create New...