kieran

Members
  • Content count

    203
  • Joined

  • Last visited

Community Reputation

19 Decent

About kieran

  • Rank
    Chump
  • Birthday August 21

Details

  • Gang
    n/a, I am a cat!
  • Location
    United Rainy Kingdom.
  • Occupation
    Newb scripter.
  • Interests
    I love GUI's and MTA, but I am lazy so don't ask for any help. (I also have a peanut brain haha)

Recent Profile Visitors

927 profile views
  1. [Question] Getting player on login

    It says it gets the account when the player logs in, so clearly not the player..... Here is the script that gets and saves a players team. --Team save function onPlayQuit ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then -- if the player is logged in local myTeam = getPlayerTeam ( source ) if (myTeam) then local currentTeam = getTeamName ( myTeam ) setAccountData ( playeraccount, "TeamLog", currentTeam ) -- save it in his account end end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayQuit ) --Team load function onPlayLogin (_, playeraccount ) if ( playeraccount ) then local LoadTeam = getAccountData ( playeraccount, "TeamLog" ) if ( LoadTeam ) then teamLoad = getTeamFromName ( LoadTeam ) setPlayerTeam ( source, teamLoad ) end end end addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayLogin ) It says: [2017-09-05 16:33:00] WARNING: IronMiner\Iron_Miner_S.lua:95: Bad argument @ 'getPlayerTeam' [Expected player at argument 1, got account] [2017-09-05 16:33:00] WARNING: IronMiner\Iron_Miner_S.lua:96: Bad argument @ 'getTeamName' [Expected team at argument 1, got boolean] So it is getting account, NOT player, I am wanting to know how to get the player only... remember what I said originally, I tried player, source, etc... But same result, source does notihng and player gets account. Same thing happens when I assign "thePlayer" to the function, as you shown me with player, it does the exact same.... At a wall here haha, all I need is to get the players team and trigger an event if that player is in the specified team when they log in.
  2. I'm trying to get the player when he joins and trigger an event tied to a function, it originally has a marker, you hit marker then you start the script, it works with adding a command handler to the function, but I can't just add an onPlayerLogin event as I want it to check team. Here's all you should need to save confusion. Function to trigger client side event (works 100%) IronMarker = createMarker (327.93359375, 865.84765625, 19.0625, "cylinder", 2, 0, 200, 55, 255) local IronMinerTeam = createTeam("Iron_Miner", 20, 100, 150) IronJobBlip = createBlipAttachedTo ( IronMarker, 56 ) function IronMiner ( hitElement, matchingDimension ) if isElement(hitElement) and getElementType(hitElement) == "player" and matchingDimension then if getElementData( hitElement, "Iron.pres" ) == nil then setElementData (hitElement, "Iron.pres", 0) --outputChatBox("You have successfully registered as an iron miner, please enter the marker again to start working!", hitElement, 255, 0, 0) end if ( IronMinerTeam ) then if isPedOnGround ( hitElement ) then setPlayerTeam(hitElement, IronMinerTeam) --triggerClientEvent ( hitElement, "ShowIron", hitElement ) local TheIron = getElementData( hitElement, "Iron.pres" ) if (TheIron) then if ( tonumber (TheIron) >= tonumber (9999999)) then outputChatBox ("You may only mine iron if your iron is below 99999999, please sell some at the T icon on F11 or by typing: /selliron amount", hitElement, 255, 0, 0) elseif ( tonumber (TheIron) <= tonumber (9999999) or nil) then triggerClientEvent ( hitElement, "IronMinerStuff", hitElement ) else outputChatBox("You must be on foot to change team!", hitElement, 255, 0, 0) end end end end end end addEvent("IronLoginEvent", true) addEventHandler("IronLoginEvent", getRootElement(), IronMiner) addEventHandler("onMarkerHit", IronMarker, IronMiner) Function that is not working (Meant to trigger the event above) function LoginHandler () local checkTeam = getTeamFromName("Iron_Miner") if ( checkTeam ) then local playerTeam = getPlayerTeam(player) if ( playerTeam == checkTeam ) then triggerEvent ( "IronLoginEvent", player ) end end end addEventHandler("onPlayerLogin", root, LoginHandler) So it keeps showing up with error on line 5 (on second code snippet) saying that it expected a player at argument one where getPlayerTeam is, I tried localPlayer and source.... How do I get the player? This is meant to trigger client event to make a marker and a blip, that's all. Thanks for help.
  3. [Question] Custom events

    Got it working, turns out that it was working... Must of forgot to restart the resource last time thanks anyways!
  4. [Question] Custom events

    function registerPlayer(username,password) if not (username == "") then if not (password == "") then local account = getAccount (username,password) if (account == false) then local accountAdded = addAccount(tostring(username),tostring(password)) if (accountAdded) then outputChatBox ("#FF0000* #00FF00You have sucessfuly registered! [Username: #FFFFFF" .. username .. " #00FF00| Password: #FFFFFF" .. password .. "#00FF00 ]",source,255,255,255,true ) triggerClientEvent (source,"hideLoginWindow",getRootElement()) end end end end end addEvent("onRequestRegister",true) addEventHandler("onRequestRegister",getRootElement(),registerPlayer) THIS is onRequestRegister, what it does is checks the 2 edits "username" and "password", if the account isn't there it then adds the account and outputs a message. In theory when a player registers, if I do: Everyone = createTeam ( "Everyone", 0, 255, 0 ) function regteam () setPlayerTeam ( source, Everyone ) outputChatBox ("Please press F1 for information and rules", source, 255, 50, 100) end addEventHandler("onRequestRegister",getRootElement(),regteam) The players team should be set.... But I don't know if I should just use localPlayer or onPlayerLogin.... I am slightly confusing myself basically I am going to make it to set the new registered players team and since there is no native event to check if an account is added for the first time, I am just trying to use the one on login panel.
  5. [Question] Custom events

    Hey, so I made a custom event with my login script, basically when a player registers an account it sets team to "Everyone" it was working, but my MTA messed up and I forget how I done it, scripts are below, any help would be great! Team Change Everyone = createTeam ( "Everyone", 0, 255, 0 ) function regteam () setPlayerTeam ( source, Everyone ) outputChatBox ("Please press F1 for information and rules", source, 255, 50, 100) end addEventHandler("onRequestRegister",getRootElement(),regteam) As you can see, this has a custom event to change team. Custom Event function registerPlayer(username,password) if not (username == "") then if not (password == "") then local account = getAccount (username,password) if (account == false) then local accountAdded = addAccount(tostring(username),tostring(password)) if (accountAdded) then outputChatBox ("#FF0000* #00FF00You have sucessfuly registered! [Username: #FFFFFF" .. username .. " #00FF00| Password: #FFFFFF" .. password .. "#00FF00 ]",source,255,255,255,true ) triggerClientEvent (source,"hideLoginWindow",getRootElement()) end end end end end addEvent("onRequestRegister",true) addEventHandler("onRequestRegister",getRootElement(),registerPlayer) Here is the event I have. When a player clicks "register" this event is triggered, all scripts are server side... Apart from the GUI of course It all works, but won't set team someone know where I gone wrong?
  6. [Question] Getting player that clicked button

    Thanks so much for all your help guys, works amazingly now, learned a lot!
  7. [Question] Getting player that clicked button

    How do I get the amount? Would I just change money_for_iron = givePlayerMoney ( selling_iron*100 ) to ironMoney = ( selling_iron*100 ) and then use your event?
  8. [Question] Getting player that clicked button

    To be honest that's making me a little more confused.... How would I make the argument?
  9. [Question] Getting player that clicked button

    Then how could I save it? The whole GUI system is meant to take x amount away from the players "iron" and add the x amount of money to his account... Should I just try setting the money as data (save it as a number) then trigger an event server side to get the number and give the player that amount of money? There must be a way to set it client side, otherwise givePlayerMoney should just be server function, right?
  10. [Question] Getting player that clicked button

    Well I am pretty new to using element data to save to account data, my PC went down a few weeks ago and only got back to scripting last week... So forgot a lot. I am trying to get the data and then setAccountData to be the element data, which will be the players money in this case, I am trying to force the server to update cash from client. Without it updating from client to server it won't save, so this is only way I can think of as my GUI is client side. If this doesn't make sense try read it over a few times haha, I am bad at explaining it.
  11. [Question] Getting player that clicked button

    Thanks, works great.... But now there's the small problem of keeping clients cash when server goes off... Here is what I tried. Server Client It shows "attempt to call 'MyIronMoneyz' (a number value)" Basically I am trying to set element data after getting money client side so I can get it server side and set the account data. I tried using toString but no joy, same with tonumber. MyIronMoney = getPlayerMoney (tonumber( localPlayer )) setElementData (localPlayer, "moneyz.set", MyIronMoney) It says that problem is server side on line 7... After I get this working that's it pretty much done, rest is just designing GUI etc, which is easy.
  12. [Question] Getting player that clicked button

    It just returns true, how can I get it to return amount? money_for_iron = givePlayerMoney ( selling_iron*100 ) recieved_money_for_iron = (tostring (money_for_iron)) guiSetText ( you_recieve_iron, "You recieved: $" ..recieved_money_for_iron )
  13. [Question] Getting player that clicked button

    Thanks, works a treat... But I have one final issue it is now saying "attempt to concatenate global 'money_for_iron' (a boolean value) function SellMyIron(button,state) if(button == "left" and state == "up") then if (source == button_sell_iron) then setElementData (localPlayer, "Iron.pres",(getElementData (localPlayer, "Iron.pres"))) TheIron = getElementData( localPlayer, "Iron.pres" ) if (TheIron) then selling_iron = guiGetText(AmountIronSelling) if (tonumber( TheIron ) >= tonumber( selling_iron )) then setElementData (localPlayer, "Iron.pres",(getElementData (localPlayer, "Iron.pres")or 0 ) - selling_iron) money_for_iron = givePlayerMoney ( selling_iron*100 ) guiSetText ( you_recieve_iron, "Your recieved: " ..money_for_iron ) --outputChatBox (""..selling_iron) end end end end end Not really an important part, but would be nice to have in it. says problem is on line 11 (on above snippet)
  14. [Question] Getting player that clicked button

    It sort of works, but now it says "attempt to compare string with number" setElementData (localPlayer, "Iron.pres",(getElementData (localPlayer, "Iron.pres"))) TheIron = getElementData( localPlayer, "Iron.pres" ) if (TheIron) then selling_iron = guiGetText(AmountIronSelling) if ( TheIron ) >= ( selling_iron ) then Do I need to convert string into number? How can I do that?
  15. I am in the middle of making a job script, it sets element data and I know how to get the data as there is a label that displays the players "iron". But I am trying to make a shop to sell the iron and I don't know how to get element data from a player that clicks a button. Client Server Basically I want to get element data, then if it's greater or equal to the number in the edit box it will give the player money, the money will be the amount in edit box * 100 and then it will take the amount from edit box away from element data.