Jump to content

AlexMiller

Members
  • Posts

    33
  • Joined

  • Last visited

Everything posted by AlexMiller

  1. It is "Which". Isn't that Valhalla gaming one?
  2. HI everyone, it's about 2 months that i'm trying to understand what i did wrong in the following script, that would give a player the weapons he had when lastly logged. Here is a part of the script, check if is there any weap on each slot, in this case, the number 5: if not (isGuestAccount (getPlayerAccount (source))) then paccount = getPlayerAccount (source) if (paccount) then slot5 = getPedWeapon (source, 5) slot5a = getPedTotalAmmo (source, 5) setAccountData (paccount, "rpg-slot5", slot5) setAccountData (paccount, "rpg-slot5Ammo", slot5a) end end So far, it is OK, as they get stored correctly on the DB... Now, on the player login, the weapon can't be given to the player, but i don't get any error. Here is the code: if not (isGuestAccount (getPlayerAccount (source))) then local accountData = getAccountData (theCurrentAccount, "rpg-money") if (accountData) then lslot5 = tonumber(getAccountData (theCurrentAccount, "rpg-slot5")) lslot5a = tonumber(getAccountData (theCurrentAccount, "rpg-slot5Ammo")) if not lslot5 == 0 then setTimer (giveWeapon, 2000, 1, source, lslot5, lslot5a) end Do you see any mistake? Thanks for the help!
  3. Alright, it works, but I did this: function( upgrades, colors, paintjob ) local player = getVehicleOccupant( source ) local actupgrds = getAccountData( getPlayerAccount( player ), "carupg") local str = ""; for i, id in pairs( upgrades ) do str = str .. tostring( id ) .. ","; end str = str:sub( 1, -2 ) local str = actupgrds.. "," .. tostring(str) setAccountData( getPlayerAccount( player ), "carupg", str ) setAccountData( getPlayerAccount( player ), "paintjob", paintjob ) end) Thanks 50p
  4. Mmm, i have another problem. If the player has a vehicle tuned with exhausts ( f.e. ID: 1020) and roof ( 1027 ), and goes to the modhsop to get a spoiler ( 1040 ). The table that was 1020,1027 will became 1040 and not 1020,1027 and 1040. What shall I do?
  5. Yes but... How to add a loop that looks first at the first terms before the comma and adds the upgrade, second at the second one, etc... ? By splitting I still don't know how to continue... EDIT: I managed to, thanks!
  6. Thanks again for the answer. After putting that I finally receive a correct result! Now the problem is, how do you think that I can retrieve only the ID number without comma, and then adding it singularly to a car?
  7. Alright, thanks 50p for answering me. I'm trying to modify your resource a little, just to save the upgrades made by the shop on another DB, where my char datas are saved. Then, to save everything as a string, I just have to do to following?: stringupgrades = tostring( upgrades ) setAccountData(getPlayerAccount(source, "carupgrs",stringupgrades)) EDIT: I tried to, and I got no error during the server run, but by having a look in the char table I can see this where there should be upgrade IDs: table: 03DF45B8
  8. Hi there. I have a variable containing all upgrades that the modshop is going to put in my car ( "upgrades" ) and I wanted them to be saved in another DB, in only 1 row (like "1001,1002,1003). Is it possible to?
  9. There was the problem, thanks you now it properly works!
  10. Can anyone help me out with this?
  11. Alright. That 2 ouputchatboxs were written to check if the variables were wroking fine. function PayDay(plr, givepay) local reincome = 200 local account = getPlayerAccount (plr) local findcar = tonumber(getAccountData (account, "car")) if findcar ~= 481 then local itscost = tonumber(getAccountData (account, "carcost")) outputChatBox("cost is " ..itscost) outputChatBox("car is " ..findcar) local tax2 = itscost/1000 else local tax2 = "0" end local whatisgiven = reincome - tax2 local playerList = getElementsByType("player") for key,val in ipairs(playersList) do givePlayerMoney(val, whatisgiven) end
  12. I'm using it locally, in the same script, in the same function.
  13. Hi there. I'm ahving some problems with my payday script. It gets the cost of the car a player has and divides it for 1000 to get the tax you have to pay for owning it. The problem is that when i try to perform this arithmetic: local tax2 = itscost /1000 I get this error: I have already checked if itscost is true by using some outputchatbox and printing it. It shows the car cost correctly. Thanks for helping!
  14. Thank you both R3mp and subenji99, now everything its ok. My panel properly works now. If anyone wants me to post here my Vehicle panel working, just ask me.
  15. Thank you for answering my proble. I really didn't see that Events, however i don't think there's a lot to learn by changing an event. Maybe, you was talking about the label's behavoir. I have to test the new changes with someone that joins the server. But the labels still doesn't change when i0m on the vehicle. I made some changes and this is the new code: EDIT: I changed again the code, because I fixed the problem. Now I have a new problem ( ), forget the previous: When I press 1,2,3 in the chatbox the text PRESSED 1,2,3 is outputted, but nothing changes, so the debugger says that: Bad argument @'isPedInVehicle' line etc. What's the problem here? function enginefunc( key , state ) if ( state == "down" ) then local player = getLocalPlayer outputChatBox("PRESSED 1") local playervehicle = getPedOccupiedVehicle ( player ) if isPedInVehicle ( player ) then local engine1 = getVehicleEngineState ( theVehicle ) if ( engine1 == false ) then guiSetText ( Engine_Label, "Engine status: Off " ) else guiSetText ( Engine_Label, "Engine status: On " ) end end end end function lightsfunc( key , state ) if ( state == "down" ) then local player = getLocalPlayer outputChatBox("PRESSED 2") local playervehicle = getPedOccupiedVehicle ( player ) if isPedInVehicle ( player ) then if isVehicleLocked ( theVehicle ) then guiSetText ( Doors_Label, "Door status: Locked " ) else guiSetText ( Doors_Label, "Door status: Unlocked " ) end end end end function doorsfunc( key , state ) if ( state == "down" ) then local player = getLocalPlayer outputChatBox("PRESSED 3") local playervehicle = getPedOccupiedVehicle ( player ) if isPedInVehicle ( player ) then if isVehicleLocked ( theVehicle ) then guiSetText ( Doors_Label, "Door status: Locked " ) else guiSetText ( Doors_Label, "Door status: Unlocked " ) end end end end That will be the part where i'll learn nothing, i think, any suggestion? Thank you.
  16. As title, I made a GUI, a vehicle panel GUI, that tells to driver the state of engine, lights and doors. The problem is that if I enter a vehicle, i see the panel, but eveyone sees my panel too and I everyone's ones. And i've another problem, the status is realoaded each time I enter the vehicle, not everytime i press the engine, lights or lockcar button... Here's the entire GUI code: addEventHandler("onClientVehicleEnter", getRootElement(), function(thePlayer, seat) Panel_Window = guiCreateWindow(751,159,174,123,"VEHICLE PANEL",false) guiWindowSetMovable(Panel_Window,false) guiWindowSetSizable(Panel_Window,false) Engine_Label = guiCreateLabel(0.0747,0.252,0.8046,0.2195,"Engine status: Off ",true,Panel_Window) guiLabelSetColor(Engine_Label,255,255,255) guiLabelSetVerticalAlign(Engine_Label,"top") guiLabelSetHorizontalAlign(Engine_Label,"left",false) Doors_Label = guiCreateLabel(0.069,0.6829,0.8621,0.1951,"Door Status: Locked ",true,Panel_Window) guiLabelSetColor(Doors_Label,255,255,255) guiLabelSetVerticalAlign(Doors_Label,"top") guiLabelSetHorizontalAlign(Doors_Label,"left",false) Lights_Label = guiCreateLabel(0.069,0.4715,0.8046,0.2114,"Lights Status: On ",true,Panel_Window) guiLabelSetColor(Lights_Label,255,255,255) guiLabelSetVerticalAlign(Lights_Label,"top") guiLabelSetHorizontalAlign(Lights_Label,"left",false) playervehicle = getPedOccupiedVehicle ( thePlayer ) if getVehicleOverrideLights ( playervehicle ) == 2 then guiSetText ( Lights_Label, "Lights status: On " ) else guiSetText ( Lights_Label, "Lights status: Off " ) end playervehicle = getPedOccupiedVehicle ( thePlayer ) if isVehicleLocked ( playervehicle ) then guiSetText ( Doors_Label, "Door status: Locked " ) else guiSetText ( Doors_Label, "Door status: Unlocked " ) end playervehicle = getPedOccupiedVehicle ( thePlayer ) local engine1 = getVehicleEngineState ( playervehicle ) if ( engine1 == false ) then guiSetText ( Engine_Label, "Engine status: Off " ) else guiSetText ( Engine_Label, "Engine status: On " ) end end ) function enginefunc( key , state ) if ( keyState == "down" ) then local player = getLocalPlayer outputChatBox("PRESSED 1") playervehicle = getPedOccupiedVehicle ( plr ) if isPedInVehicle ( plr ) then local engine1 = getVehicleEngineState ( playervehicle ) if ( engine1 == false ) then guiSetText ( Engine_Label, "Engine status: Off " ) else guiSetText ( Engine_Label, "Engine status: On " ) end end end end function lightsfunc( key , state ) if ( keyState == "down" ) then local player = getLocalPlayer outputChatBox("PRESSED 2") playervehicle = getPedOccupiedVehicle ( plr ) if isPedInVehicle ( plr ) then if isVehicleLocked ( playervehicle ) then guiSetText ( Doors_Label, "Door status: Locked " ) else guiSetText ( Doors_Label, "Door status: Unlocked " ) end end end end function doorsfunc( key , state ) if ( keyState == "down" ) then local player = getLocalPlayer outputChatBox("PRESSED 3") playervehicle = getPedOccupiedVehicle ( plr ) if isPedInVehicle ( plr ) then if isVehicleLocked ( playervehicle ) then guiSetText ( Doors_Label, "Door status: Locked " ) else guiSetText ( Doors_Label, "Door status: Unlocked " ) end end end end function chiavi2 () local bind1 = bindKey( "1", "down", "enginefunc" ) local bind2 = bindKey( "2", "down", "lightsfunc" ) local bind3 = bindKey( "3", "down", "doorsfunc" ) if bind1 and bind2 and bind3 then outputChatBox( "Keys bound") end end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), chiavi2) addEventHandler("onClientVehicleExit", getRootElement(), function(thePlayer, seat) destroyElement(Panel_Window) end ) I hope someone can help me. I wrote the same question in another section, it was ignored, so i thought it was the wrong one... Thank you.
  17. I'm in love with all your script, i'll try this one later. Well done!
  18. start mabako services of DP2.0 version and when the server is up write upgrade in the console, it will work, as it worked for me.
  19. As title, I made a GUI, a vehicle panel GUI, that says the driver the state of engine, lights and doors. The problem is that if I enter a vehicle, i see the panel, but eveyone sees my panel too. And i've another problem, the status is realoaded each time I enter the vehicle, not everytime i press the engine, lights lockcar button... Here's the entire GUI code: addEventHandler("onClientVehicleEnter", getRootElement(), function(thePlayer, seat) Panel_Window = guiCreateWindow(751,159,174,123,"VEHICLE PANEL",false) guiWindowSetMovable(Panel_Window,false) guiWindowSetSizable(Panel_Window,false) Engine_Label = guiCreateLabel(0.0747,0.252,0.8046,0.2195,"Engine status: Off ",true,Panel_Window) guiLabelSetColor(Engine_Label,255,255,255) guiLabelSetVerticalAlign(Engine_Label,"top") guiLabelSetHorizontalAlign(Engine_Label,"left",false) Doors_Label = guiCreateLabel(0.069,0.6829,0.8621,0.1951,"Door Status: Locked ",true,Panel_Window) guiLabelSetColor(Doors_Label,255,255,255) guiLabelSetVerticalAlign(Doors_Label,"top") guiLabelSetHorizontalAlign(Doors_Label,"left",false) Lights_Label = guiCreateLabel(0.069,0.4715,0.8046,0.2114,"Lights Status: On ",true,Panel_Window) guiLabelSetColor(Lights_Label,255,255,255) guiLabelSetVerticalAlign(Lights_Label,"top") guiLabelSetHorizontalAlign(Lights_Label,"left",false) playervehicle = getPedOccupiedVehicle ( thePlayer ) if getVehicleOverrideLights ( playervehicle ) == 2 then guiSetText ( Lights_Label, "Lights status: On " ) else guiSetText ( Lights_Label, "Lights status: Off " ) end playervehicle = getPedOccupiedVehicle ( thePlayer ) if isVehicleLocked ( playervehicle ) then guiSetText ( Doors_Label, "Door status: Locked " ) else guiSetText ( Doors_Label, "Door status: Unlocked " ) end playervehicle = getPedOccupiedVehicle ( thePlayer ) local engine1 = getVehicleEngineState ( playervehicle ) if ( engine1 == false ) then guiSetText ( Engine_Label, "Engine status: Off " ) else guiSetText ( Engine_Label, "Engine status: On " ) end end ) function enginefunc( key , state ) if ( keyState == "down" ) then local player = getLocalPlayer outputChatBox("PRESSED 1") playervehicle = getPedOccupiedVehicle ( plr ) if isPedInVehicle ( plr ) then local engine1 = getVehicleEngineState ( playervehicle ) if ( engine1 == false ) then guiSetText ( Engine_Label, "Engine status: Off " ) else guiSetText ( Engine_Label, "Engine status: On " ) end end end end function lightsfunc( key , state ) if ( keyState == "down" ) then local player = getLocalPlayer outputChatBox("PRESSED 2") playervehicle = getPedOccupiedVehicle ( plr ) if isPedInVehicle ( plr ) then if isVehicleLocked ( playervehicle ) then guiSetText ( Doors_Label, "Door status: Locked " ) else guiSetText ( Doors_Label, "Door status: Unlocked " ) end end end end function doorsfunc( key , state ) if ( keyState == "down" ) then local player = getLocalPlayer outputChatBox("PRESSED 3") playervehicle = getPedOccupiedVehicle ( plr ) if isPedInVehicle ( plr ) then if isVehicleLocked ( playervehicle ) then guiSetText ( Doors_Label, "Door status: Locked " ) else guiSetText ( Doors_Label, "Door status: Unlocked " ) end end end end function chiavi2 () local bind1 = bindKey( "1", "down", "enginefunc" ) local bind2 = bindKey( "2", "down", "lightsfunc" ) local bind3 = bindKey( "3", "down", "doorsfunc" ) if bind1 and bind2 and bind3 then outputChatBox( "Keys bound") end end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), chiavi2) addEventHandler("onClientVehicleExit", getRootElement(), function(thePlayer, seat) destroyElement(Panel_Window) end ) I hope someone can help me. Thank you
  20. I used your example and i used account's data. That's what i made : function onPlayerQuit3 ( ) local account = getPlayerAccount ( source ) if ( account ) then local money = getPlayerMoney ( source ) local health = getElementHealth ( source ) setAccountData ( account, "rpg.money", money ) if ( health == 0 ) then setAccountData ( account, "rpg.health", 100 ) else setAccountData ( account, "rpg.health", health ) end end end function onPlayerJoin3 ( ) local account = getPlayerAccount ( source ) if ( account ) then local money = getAccountData ( account, "rpg.money" ) local health = getAccountData ( account, "rpg.health" ) if ( money ) then setPlayerMoney ( source, money ) end if ( health ) then setElementHealth ( source, health ) end end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit3 ) addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerJoin3 ) I tested it and i works, thank you Gamesnert for that, and robhol, for your lua's guide. (i started learning lua from your guide )
  21. Maybe i haven't understand, do you think i don't have to use sql tables, but accounts stored in xmls?
  22. Hi there, i'd like to have a databse table and, on player login with resource "logingui" ( i think with the exported event "clientLoginSuccess" but i'm not sure ) the server gives the player the cash the player has the last time he logged in. I did this script but it doesn't work... : function aggiorna (source) local sourcemoney = getPlayerMoney ( source ) result2 = executeSQLQuery("SELECT cash FROM cashes WHERE player=?", source ) executeSQLQuery("UPDATE cashes SET cash=? WHERE player='".. source .."'", sourcemoney ) outputChatBox ( "Money updated", source ) end addEventHandler ( "onPlayerQuit", getRootElement(), aggiorna ) function daisoldi (source) local result = executeSQLSelect ( "cashes", "cash", "player = '" .. source .. "'" ) givePlayerMoney ( source, result[1].cash ) end addEventHandler ( "clientSuccessLogin", getRootElement(), daisoldi ) function creatavola ( ) executeSQLQuery("CREATE TABLE IF NOT EXISTS cashes ( cash NUMERIC, player TEXT )" ) local source = getLocalPlayer outputChatBox ( "SQL Table successfully created" , source ) end addEventHandler ( "onResourceStart", getRootElement(), creatavola ) For non-italia readers ( 98% of forum members ), "aggiorna" means refresh. "daisoldi" means givemoney . "creatavola" means createtable. The table is created but when it have to refresh player money i get this error: ' attempt to concatenate a local 'source' ( a userdata value ) ' Thank you.
  23. Hi there, i'm making a RPG Script and now with SQL Scripting i'll need some help because i0m having some problems and i now realised i cant develop a server on my own . So here are my current server's features: - Not-tested arrest script cause i made it yesterday and no one came in my server so i could'nt test it - 2 Selectionable factions by a GUI: Police and Groove - 2 bases with vehicle spawned: Groove Street and the Police Department - Each faction's base has an interior only enterable by the team member of that faction ( ex. Only police can enter police department ) - Animated peds on each base like gangsters in groove street and policemen in PD - By having problems with binding keys you can for now use commands to lock, switch engine, toggle lights and toggle cursor - Is possible to fix your car by typing /fixcar and it will cost you 250$ - Each kill will give you 250, each arrest 500 Maybe i forgot something... However, please don't answer only to say i haven't a good server, i'd like you to answer me to help me with the server ( Sorry for my not very well written-english, i'm Italian ) if you want to help me, you can always PM me Thank you.
  24. Thanks for all, now everything works perfectly
×
×
  • Create New...