Jump to content

I beg you please fix my script...


SirniNamaz

Recommended Posts

Posted (edited)

CLIENT:

x,y = guiGetScreenSize() 
guiDrugs = guiCreateWindow(x-285-20,y-253-20,285,253,"F3 - Drug Manager",false) 
lblDrug = guiCreateLabel(17,31,32,16,"Drug:",false,guiDrugs) 
lblAmount = guiCreateLabel(203,31,50,15,"Amount:",false,guiDrugs) 
rdoCannabis = guiCreateRadioButton(15,55,135,17,"Cannabis",false,guiDrugs) 
guiRadioButtonSetSelected(rdoCannabis,true) 
rdoHeroin = guiCreateRadioButton(15,79,135,17,"Heroin",false,guiDrugs) 
rdoCocaine = guiCreateRadioButton(15,104,135,17,"Cocaine",false,guiDrugs) 
rdoLSD = guiCreateRadioButton(15,129,135,17,"LSD",false,guiDrugs) 
rdoEcstasy = guiCreateRadioButton(15,154,135,17,"Ecstasy",false,guiDrugs) 
rdoOpium = guiCreateRadioButton(15,180,135,17,"Opium",false,guiDrugs) 
btnTakeHit = guiCreateButton(39,208,96,30,"Take a Hit",false,guiDrugs) 
btnSell = guiCreateButton(145,208,96,30,"Sell",false,guiDrugs) 
lblCannabis = guiCreateLabel(200,54,54,14,"0",false,guiDrugs) 
guiLabelSetVerticalAlign(lblCannabis,"center") 
guiLabelSetHorizontalAlign(lblCannabis,"center",false) 
lblHeroin = guiCreateLabel(200,76,54,14,"0",false,guiDrugs) 
guiLabelSetVerticalAlign(lblHeroin,"center") 
guiLabelSetHorizontalAlign(lblHeroin,"center",false) 
lblCocaine = guiCreateLabel(200,102,54,14,"0",false,guiDrugs) 
guiLabelSetVerticalAlign(lblCocaine,"center") 
guiLabelSetHorizontalAlign(lblCocaine,"center",false) 
lblLSD = guiCreateLabel(200,127,54,14,"0",false,guiDrugs) 
guiLabelSetVerticalAlign(lblLSD,"center") 
guiLabelSetHorizontalAlign(lblLSD,"center",false) 
lblEcstasy = guiCreateLabel(200,153,54,14,"0",false,guiDrugs) 
guiLabelSetVerticalAlign(lblEcstasy,"center") 
guiLabelSetHorizontalAlign(lblEcstasy,"center",false) 
lblOpium = guiCreateLabel(200,179,54,14,"0",false,guiDrugs) 
guiLabelSetVerticalAlign(lblOpium,"center") 
guiLabelSetHorizontalAlign(lblOpium,"center",false) 
guiSetVisible(guiDrugs,false) 
  
function drugShowHide () 
  if (guiGetVisible(guiDrugs)==false) then 
    guiSetVisible(guiDrugs,true) 
    showCursor(true) 
  else 
    guiSetVisible(guiDrugs,false) 
    showCursor(false) 
  end 
end 
bindKey("F3","down",drugShowHide) 
  
  
addEvent("getDrugAmount",true) 
addEventHandler("getDrugAmount",getRootElement(), 
function() 
    amountCannabis = guiGetText(lblCannabis) 
    amountHeroin = guiGetText(lblHeroin) 
    amountCocaine = guiGetText(lblCocaine) 
    amountLSD = guiGetText(lblLSD) 
    amountEcstasy = guiGetText(lblEcstasy) 
    amountOpium = guiGetText(lblOpium) 
    triggerServerEvent("saveDrugAmount",getLocalPlayer(),getLocalPlayer(),amountCannabis,amountHeroin,amountCocaine,amountLSD,amountEcstasy,amountOpium) 
end) 
  
  
  
function outputDrug (var1, var2, var3, var4, var5, var6) 
    guiSetText (lblCannabis,tostring(var1)) 
    guiSetText (lblHeroin,tostring(var2)) 
    guiSetText (lblCocaine,tostring(var3)) 
    guiSetText (lblLSD,tostring(var4)) 
    guiSetText (lblEcstasy,tostring(var5)) 
    guiSetText (lblOpium,tostring(var6)) 
end 
addEvent( "outputDrug2", true ) 
addEventHandler( "outputDrug2", getRootElement(), outputDrug ) 
  
  
addEvent("firstTime",true) 
addEventHandler("firstTime",getRootElement(), 
function() 
    guiSetText(lblCannabis,"0") 
    guiSetText(lblHeroin,"0") 
    guiSetText(lblCocaine,"0") 
    guiSetText(lblLSD,"0") 
    guiSetText(lblEcstasy,"0") 
    guiSetText(lblOpium,"0") 
end) 
  

SERVER:

function getTextQuit() 
    triggerClientEvent(source,"getDrugAmount",getRootElement()) 
end 
addEventHandler("onPlayerQuit",getRootElement(),getTextQuit) 
  
  
addEvent("saveDrugAmount",true) 
addEventHandler("saveDrugAmount",getRootElement(), 
function(player,amountCannabisS,amountHeroinS,amountCocaineS,amountLSDS,amountEcstasyS,amountOpiumS) 
    playeraccount = getPlayerAccount(player) 
    if (playeraccount) then 
        setAccountData(playeraccount,"amountCannabis",amountCannabisS) 
        setAccountData(playeraccount,"amountHeroin",amountHeroinS) 
        setAccountData(playeraccount,"amountCocaine",amountCocaineS) 
        setAccountData(playeraccount,"amountLSDS",amountLSDS) 
        setAccountData(playeraccount,"amountEcstasy",amountEcstasyS) 
        setAccountData(playeraccount,"amountOpium",amountOpiumS) 
    end 
end) 
  
  
function loadDrugAmount() 
    playeraccount = getPlayerAccount(source) 
    if (playeraccount) then 
        amountCannabis2 = getAccountData(playeraccount,"amountCannabis") 
        amountHeroin2 = getAccountData(playeraccount,"amountHeroin") 
        amountCocaine2 = getAccountData(playeraccount,"amountCocaine") 
        amountLSD2 = getAccountData(playeraccount,"amountLSDS") 
        amountEcstasy2 = getAccountData(playeraccount,"amountEcstasy") 
        amountOpium2 = getAccountData(playeraccount,"amountOpium") 
        triggerClientEvent ( "outputDrug2", getRootElement(), amountCannabis2, amountHeroin2, amountCocaine2, amountLSD2, amountEcstasy2, amountOpium2 ) 
        else 
        triggerClientEvent(source,"firstTime",getRootElement()) 
    end 
end 
addEventHandler("onPlayerLogin",getRootElement(),loadDrugAmount) 
  

idk why id doesnt work but it doesn't output the numbers

Edited by Guest
Posted

Any errors at the debugscript?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Mind posting them here?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
Mind posting them here?
function outputDrug (var1, var2, var3, var4, var5, var6) 
    guiSetText ( lblCannabis,var1) 
    guiSetText ( lblHeroin,var2) 
    guiSetText ( lblCocaine,var3) 
    guiSetText ( lblLSD,var4) 
    guiSetText ( lblEcstasy,var5) 
    guiSetText ( lblOpium,var6) 
end 

Posted

I was talking about the errors, not the script lines.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
I was talking about the errors, not the script lines.

sorry for that.. actually now i succeded to fix the errors by adding tostring command and there are no errors now. but my problem is that it writes 'false' in label, but i want it to write my amount of drugs.

ps. the error i fixed was that it needed to be converted to string

Posted
function getTextQuit ( ) 
    triggerClientEvent ( source,"getDrugAmount", source ) 
end 
addEventHandler ( "onPlayerQuit", root, getTextQuit ) 
  
addEvent ( "saveDrugAmount", true ) 
addEventHandler ( "saveDrugAmount", root, 
    function ( player, amountCannabisS, amountHeroinS, amountCocaineS, amountLSDS, amountEcstasyS, amountOpiumS ) 
        local playeraccount = getPlayerAccount ( player ) 
        if ( playeraccount ) then 
            setAccountData ( playeraccount, "amountCannabis", tonumber ( amountCannabisS ) ) 
            setAccountData ( playeraccount, "amountHeroin", tonumber ( amountHeroinS ) ) 
            setAccountData ( playeraccount, "amountCocaine", tonumber ( amountCocaineS ) ) 
            setAccountData ( playeraccount, "amountLSDS", tonumber ( amountLSDS ) ) 
            setAccountData ( playeraccount, "amountEcstasy", tonumber ( amountEcstasyS ) ) 
            setAccountData ( playeraccount, "amountOpium", tonumber ( amountOpiumS ) ) 
        end 
    end 
) 
  
function loadDrugAmount ( _, playeraccount ) 
    if ( playeraccount ) then 
        local amountCannabis2 = getAccountData ( playeraccount, "amountCannabis" ) 
        local amountHeroin2 = getAccountData ( playeraccount, "amountHeroin" ) 
        local amountCocaine2 = getAccountData ( playeraccount, "amountCocaine" ) 
        local amountLSD2 = getAccountData ( playeraccount, "amountLSDS" ) 
        local amountEcstasy2 = getAccountData ( playeraccount, "amountEcstasy" ) 
        local amountOpium2 = getAccountData ( playeraccount, "amountOpium" ) 
        triggerClientEvent ( source, "outputDrug2", source, amountCannabis2, amountHeroin2, amountCocaine2, amountLSD2, amountEcstasy2, amountOpium2 ) 
    else 
        triggerClientEvent ( source, "firstTime", source ) 
    end 
end 
addEventHandler ( "onPlayerLogin", root, loadDrugAmount ) 

Not sure if that'll fix it, but try it anyway. If it still doesn't work, then it may be that you are not saving any drug amount at all.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
function getTextQuit ( ) 
    triggerClientEvent ( source,"getDrugAmount", source ) 
end 
addEventHandler ( "onPlayerQuit", root, getTextQuit ) 
  
addEvent ( "saveDrugAmount", true ) 
addEventHandler ( "saveDrugAmount", root, 
    function ( player, amountCannabisS, amountHeroinS, amountCocaineS, amountLSDS, amountEcstasyS, amountOpiumS ) 
        local playeraccount = getPlayerAccount ( player ) 
        if ( playeraccount ) then 
            setAccountData ( playeraccount, "amountCannabis", tonumber ( amountCannabisS ) ) 
            setAccountData ( playeraccount, "amountHeroin", tonumber ( amountHeroinS ) ) 
            setAccountData ( playeraccount, "amountCocaine", tonumber ( amountCocaineS ) ) 
            setAccountData ( playeraccount, "amountLSDS", tonumber ( amountLSDS ) ) 
            setAccountData ( playeraccount, "amountEcstasy", tonumber ( amountEcstasyS ) ) 
            setAccountData ( playeraccount, "amountOpium", tonumber ( amountOpiumS ) ) 
        end 
    end 
) 
  
function loadDrugAmount ( _, playeraccount ) 
    if ( playeraccount ) then 
        local amountCannabis2 = getAccountData ( playeraccount, "amountCannabis" ) 
        local amountHeroin2 = getAccountData ( playeraccount, "amountHeroin" ) 
        local amountCocaine2 = getAccountData ( playeraccount, "amountCocaine" ) 
        local amountLSD2 = getAccountData ( playeraccount, "amountLSDS" ) 
        local amountEcstasy2 = getAccountData ( playeraccount, "amountEcstasy" ) 
        local amountOpium2 = getAccountData ( playeraccount, "amountOpium" ) 
        triggerClientEvent ( source, "outputDrug2", source, amountCannabis2, amountHeroin2, amountCocaine2, amountLSD2, amountEcstasy2, amountOpium2 ) 
    else 
        triggerClientEvent ( source, "firstTime", source ) 
    end 
end 
addEventHandler ( "onPlayerLogin", root, loadDrugAmount ) 

Not sure if that'll fix it, but try it anyway. If it still doesn't work, then it may be that you are not saving any drug amount at all.

it still shows 'false', but maybe its becouse i have 0 drugs and computer thinks 0 is 'false' and 1 is 'true', is there any way to view this database with any tool and edit it

Posted

Here is 100% fixed..

Client:

  
function trolo() 
x,y = guiGetScreenSize() 
guiDrugs = guiCreateWindow(x-285-20,y-253-20,285,253,"F3 - Drug Manager",false) 
lblDrug = guiCreateLabel(17,31,32,16,"Drug:",false,guiDrugs) 
lblAmount = guiCreateLabel(203,31,50,15,"Amount:",false,guiDrugs) 
rdoCannabis = guiCreateRadioButton(15,55,135,17,"Cannabis",false,guiDrugs) 
guiRadioButtonSetSelected(rdoCannabis,true) 
rdoHeroin = guiCreateRadioButton(15,79,135,17,"Heroin",false,guiDrugs) 
rdoCocaine = guiCreateRadioButton(15,104,135,17,"Cocaine",false,guiDrugs) 
rdoLSD = guiCreateRadioButton(15,129,135,17,"LSD",false,guiDrugs) 
rdoEcstasy = guiCreateRadioButton(15,154,135,17,"Ecstasy",false,guiDrugs) 
rdoOpium = guiCreateRadioButton(15,180,135,17,"Opium",false,guiDrugs) 
btnTakeHit = guiCreateButton(39,208,96,30,"Take a Hit",false,guiDrugs) 
btnSell = guiCreateButton(145,208,96,30,"Sell",false,guiDrugs) 
lblCannabis = guiCreateLabel(200,54,54,14,"0",false,guiDrugs) 
guiLabelSetVerticalAlign(lblCannabis,"center") 
guiLabelSetHorizontalAlign(lblCannabis,"center",false) 
lblHeroin = guiCreateLabel(200,76,54,14,"0",false,guiDrugs) 
guiLabelSetVerticalAlign(lblHeroin,"center") 
guiLabelSetHorizontalAlign(lblHeroin,"center",false) 
lblCocaine = guiCreateLabel(200,102,54,14,"0",false,guiDrugs) 
guiLabelSetVerticalAlign(lblCocaine,"center") 
guiLabelSetHorizontalAlign(lblCocaine,"center",false) 
lblLSD = guiCreateLabel(200,127,54,14,"0",false,guiDrugs) 
guiLabelSetVerticalAlign(lblLSD,"center") 
guiLabelSetHorizontalAlign(lblLSD,"center",false) 
lblEcstasy = guiCreateLabel(200,153,54,14,"0",false,guiDrugs) 
guiLabelSetVerticalAlign(lblEcstasy,"center") 
guiLabelSetHorizontalAlign(lblEcstasy,"center",false) 
lblOpium = guiCreateLabel(200,179,54,14,"0",false,guiDrugs) 
guiLabelSetVerticalAlign(lblOpium,"center") 
guiLabelSetHorizontalAlign(lblOpium,"center",false) 
guiSetVisible(guiDrugs,false) 
end 
addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),trolo) 
  
function drugShowHide () 
  if (guiGetVisible(guiDrugs)==false) then 
    guiSetVisible(guiDrugs,true) 
    showCursor(true) 
  else 
    guiSetVisible(guiDrugs,false) 
    showCursor(false) 
  end 
end 
bindKey("F3","down",drugShowHide) 
  
  
  
function oncQuit() 
    amountCannabis = guiGetText(lblCannabis) 
    amountHeroin = guiGetText(lblHeroin) 
    amountCocaine = guiGetText(lblCocaine) 
    amountLSD = guiGetText(lblLSD) 
    amountEcstasy = guiGetText(lblEcstasy) 
    amountOpium = guiGetText(lblOpium) 
    triggerServerEvent("saveDrugAmount",getLocalPlayer(),getLocalPlayer(),amountCannabis,amountHeroin,amountCocaine,amountLSD,amountEcstasy,amountOpium) 
end 
addEventHandler("onClientPlayerQuit",getRootElement(),oncQuit) 
  
  
  
function outputDrug (var1, var2, var3, var4, var5, var6) 
    guiSetText ( lblCannabis,var1) 
    guiSetText ( lblHeroin,var2) 
    guiSetText ( lblCocaine,var3) 
    guiSetText ( lblLSD,var4) 
    guiSetText ( lblEcstasy,var5) 
    guiSetText ( lblOpium,var6) 
end 
addEvent( "outputDrug2", true ) 
addEventHandler( "outputDrug2", getRootElement(), outputDrug ) 
  
  
addEvent("firstTime",true) 
addEventHandler("firstTime",getRootElement(), 
function() 
    outputChatBox ("Test Measage") 
    guiSetText(lblCannabis,"2") 
    guiSetText(lblHeroin,"2") 
    guiSetText(lblCocaine,"0") 
    guiSetText(lblLSD,"0") 
    guiSetText(lblEcstasy,"0") 
    guiSetText(lblOpium,"0") 
end) 
  

Server:

  
addEvent("saveDrugAmount",true) 
addEventHandler("saveDrugAmount",getRootElement(), 
function(player,amountCannabisS,amountHeroinS,amountCocaineS,amountLSDS,amountEcstasyS,amountOpiumS) 
    playeraccount = getPlayerAccount(player) 
    if (playeraccount) then 
        setAccountData(playeraccount,"amountCannabis",tonumber(amountCannabisS)) 
        setAccountData(playeraccount,"amountHeroin",tonumber(amountHeroinS)) 
        setAccountData(playeraccount,"amountCocaine",tonumber(amountCocaineS)) 
        setAccountData(playeraccount,"amountLSDS",tonumber(amountLSDS)) 
        setAccountData(playeraccount,"amountEcstasy",tonumber(amountEcstasyS)) 
        setAccountData(playeraccount,"amountOpium",tonumber(amountOpiumS)) 
    end 
end) 
  
  
function loadDrugAmount() 
    playeraccount = getPlayerAccount(source) 
    if (playeraccount) then 
        amountCannabis2 = getAccountData(playeraccount,"amountCannabis") 
        amountHeroin2 = getAccountData(playeraccount,"amountHeroin") 
        amountCocaine2 = getAccountData(playeraccount,"amountCocaine") 
        amountLSD2 = getAccountData(playeraccount,"amountLSDS") 
        amountEcstasy2 = getAccountData(playeraccount,"amountEcstasy") 
        amountOpium2 = getAccountData(playeraccount,"amountOpium") 
        if (amountCannabis2) then 
        triggerClientEvent (source, "outputDrug2", getRootElement(), amountCannabis2, amountHeroin2, amountCocaine2, amountLSD2, amountEcstasy2, amountOpium2 ) 
        else 
        triggerClientEvent(source,"firstTime",getRootElement()) 
        end 
    end 
end 
addEventHandler("onPlayerLogin",getRootElement(),loadDrugAmount) 
  

http://www.sincitygaming.net - The next generation of gaming!

SinCity Gaming | UltiRace 24/7 - 188.165.199.162:22003

SinCity Gaming | Roleplay Gaming - Beta soon!

SinCity Gaming | Zombie Mode + - 188.165.199.162:22005

Instead of using ip: 188.165.199.162 you can use: sincitygaming.net

Posted

Use this command to check if you have drugs or not:

addCommandHandler ( "checkdrugs", 
    function ( thePlayer ) 
        local playeraccount = getPlayerAccount ( thePlayer ) 
        if ( playeraccount ) then 
            local amountCannabis = getAccountData ( playeraccount, "amountCannabis" ) 
            local amountHeroin = getAccountData ( playeraccount, "amountHeroin" ) 
            local amountCocaine = getAccountData ( playeraccount, "amountCocaine" ) 
            local amountLSDS = getAccountData ( playeraccount, "amountLSDS" ) 
            local amountEcstasy = getAccountData ( playeraccount, "amountEcstasy" ) 
            local amountOpium = getAccountData ( playeraccount, "amountOpium" ) 
            outputChatBox ( "Cannabis: ".. tostring ( amountCannabis ), thePlayer ) 
            outputChatBox ( "Heroin: ".. tostring ( amountHeroin ), thePlayer ) 
            outputChatBox ( "Cocaine: ".. tostring ( amountCocaine ), thePlayer ) 
            outputChatBox ( "LSD: ".. tostring ( amountLSDS ), thePlayer ) 
            outputChatBox ( "Ecstasy: ".. tostring ( amountEcstasy ), thePlayer ) 
            outputChatBox ( "Opium: ".. tostring ( amountOpium ), thePlayer ) 
        end 
    end 
) 

Tell me what does it output.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
Here is 100% fixed..

Client:

  
function trolo() 
x,y = guiGetScreenSize() 
guiDrugs = guiCreateWindow(x-285-20,y-253-20,285,253,"F3 - Drug Manager",false) 
lblDrug = guiCreateLabel(17,31,32,16,"Drug:",false,guiDrugs) 
lblAmount = guiCreateLabel(203,31,50,15,"Amount:",false,guiDrugs) 
rdoCannabis = guiCreateRadioButton(15,55,135,17,"Cannabis",false,guiDrugs) 
guiRadioButtonSetSelected(rdoCannabis,true) 
rdoHeroin = guiCreateRadioButton(15,79,135,17,"Heroin",false,guiDrugs) 
rdoCocaine = guiCreateRadioButton(15,104,135,17,"Cocaine",false,guiDrugs) 
rdoLSD = guiCreateRadioButton(15,129,135,17,"LSD",false,guiDrugs) 
rdoEcstasy = guiCreateRadioButton(15,154,135,17,"Ecstasy",false,guiDrugs) 
rdoOpium = guiCreateRadioButton(15,180,135,17,"Opium",false,guiDrugs) 
btnTakeHit = guiCreateButton(39,208,96,30,"Take a Hit",false,guiDrugs) 
btnSell = guiCreateButton(145,208,96,30,"Sell",false,guiDrugs) 
lblCannabis = guiCreateLabel(200,54,54,14,"0",false,guiDrugs) 
guiLabelSetVerticalAlign(lblCannabis,"center") 
guiLabelSetHorizontalAlign(lblCannabis,"center",false) 
lblHeroin = guiCreateLabel(200,76,54,14,"0",false,guiDrugs) 
guiLabelSetVerticalAlign(lblHeroin,"center") 
guiLabelSetHorizontalAlign(lblHeroin,"center",false) 
lblCocaine = guiCreateLabel(200,102,54,14,"0",false,guiDrugs) 
guiLabelSetVerticalAlign(lblCocaine,"center") 
guiLabelSetHorizontalAlign(lblCocaine,"center",false) 
lblLSD = guiCreateLabel(200,127,54,14,"0",false,guiDrugs) 
guiLabelSetVerticalAlign(lblLSD,"center") 
guiLabelSetHorizontalAlign(lblLSD,"center",false) 
lblEcstasy = guiCreateLabel(200,153,54,14,"0",false,guiDrugs) 
guiLabelSetVerticalAlign(lblEcstasy,"center") 
guiLabelSetHorizontalAlign(lblEcstasy,"center",false) 
lblOpium = guiCreateLabel(200,179,54,14,"0",false,guiDrugs) 
guiLabelSetVerticalAlign(lblOpium,"center") 
guiLabelSetHorizontalAlign(lblOpium,"center",false) 
guiSetVisible(guiDrugs,false) 
end 
addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),trolo) 
  
function drugShowHide () 
  if (guiGetVisible(guiDrugs)==false) then 
    guiSetVisible(guiDrugs,true) 
    showCursor(true) 
  else 
    guiSetVisible(guiDrugs,false) 
    showCursor(false) 
  end 
end 
bindKey("F3","down",drugShowHide) 
  
  
  
function oncQuit() 
    amountCannabis = guiGetText(lblCannabis) 
    amountHeroin = guiGetText(lblHeroin) 
    amountCocaine = guiGetText(lblCocaine) 
    amountLSD = guiGetText(lblLSD) 
    amountEcstasy = guiGetText(lblEcstasy) 
    amountOpium = guiGetText(lblOpium) 
    triggerServerEvent("saveDrugAmount",getLocalPlayer(),getLocalPlayer(),amountCannabis,amountHeroin,amountCocaine,amountLSD,amountEcstasy,amountOpium) 
end 
addEventHandler("onClientPlayerQuit",getRootElement(),oncQuit) 
  
  
  
function outputDrug (var1, var2, var3, var4, var5, var6) 
    guiSetText ( lblCannabis,var1) 
    guiSetText ( lblHeroin,var2) 
    guiSetText ( lblCocaine,var3) 
    guiSetText ( lblLSD,var4) 
    guiSetText ( lblEcstasy,var5) 
    guiSetText ( lblOpium,var6) 
end 
addEvent( "outputDrug2", true ) 
addEventHandler( "outputDrug2", getRootElement(), outputDrug ) 
  
  
addEvent("firstTime",true) 
addEventHandler("firstTime",getRootElement(), 
function() 
    outputChatBox ("Test Measage") 
    guiSetText(lblCannabis,"2") 
    guiSetText(lblHeroin,"2") 
    guiSetText(lblCocaine,"0") 
    guiSetText(lblLSD,"0") 
    guiSetText(lblEcstasy,"0") 
    guiSetText(lblOpium,"0") 
end) 
  

Server:

  
addEvent("saveDrugAmount",true) 
addEventHandler("saveDrugAmount",getRootElement(), 
function(player,amountCannabisS,amountHeroinS,amountCocaineS,amountLSDS,amountEcstasyS,amountOpiumS) 
    playeraccount = getPlayerAccount(player) 
    if (playeraccount) then 
        setAccountData(playeraccount,"amountCannabis",tonumber(amountCannabisS)) 
        setAccountData(playeraccount,"amountHeroin",tonumber(amountHeroinS)) 
        setAccountData(playeraccount,"amountCocaine",tonumber(amountCocaineS)) 
        setAccountData(playeraccount,"amountLSDS",tonumber(amountLSDS)) 
        setAccountData(playeraccount,"amountEcstasy",tonumber(amountEcstasyS)) 
        setAccountData(playeraccount,"amountOpium",tonumber(amountOpiumS)) 
    end 
end) 
  
  
function loadDrugAmount() 
    playeraccount = getPlayerAccount(source) 
    if (playeraccount) then 
        amountCannabis2 = getAccountData(playeraccount,"amountCannabis") 
        amountHeroin2 = getAccountData(playeraccount,"amountHeroin") 
        amountCocaine2 = getAccountData(playeraccount,"amountCocaine") 
        amountLSD2 = getAccountData(playeraccount,"amountLSDS") 
        amountEcstasy2 = getAccountData(playeraccount,"amountEcstasy") 
        amountOpium2 = getAccountData(playeraccount,"amountOpium") 
        if (amountCannabis2) then 
        triggerClientEvent (source, "outputDrug2", getRootElement(), amountCannabis2, amountHeroin2, amountCocaine2, amountLSD2, amountEcstasy2, amountOpium2 ) 
        else 
        triggerClientEvent(source,"firstTime",getRootElement()) 
        end 
    end 
end 
addEventHandler("onPlayerLogin",getRootElement(),loadDrugAmount) 
  

thankyou it works, also i have a small question: is it possible to edit this database where (drug is saved) outside mta,

Posted

As I told you, it was not saving the drugs at all.

To edit the database where this is saved, you must download "SQLitebrowser" ( google it ), and open "internal.db" at your server folder.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
As I told you, it was not saving the drugs at all.

To edit the database where this is saved, you must download "SQLitebrowser" ( google it ), and open "internal.db" at your server folder.

and then what

Posted

Select the table and edit it.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...