Author Topic: How do i use RunConsoleCommand proparly?  (Read 45 times)

0 Members and 1 Guest are viewing this topic.

Offline DarkIce

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
    • View Profile
How do i use RunConsoleCommand proparly?
« on: February 17, 2017, 10:47:39 AM »
Hello,
i have problems with my small code here:
Code: [Select]

local CATEGORY_NAME = "DarkCMDs"

ulx.moneycount = {}
function updateMoney()
table.Empty(ulx.moneycount)
    table.insert(ulx.moneycount,"10")
    table.insert(ulx.moneycount,"20")
    table.insert(ulx.moneycount,"30")
table.insert(ulx.moneycount,"40")
end
hook.Add( ULib.HOOK_UCLCHANGED, "ULXDonatedMoneyUpdate", updateMoney )
updateMoney()

function ulx.donated(target_ply, moneycount)
if moneycount == "10" then
RunConsoleCommand("ulx", "adduser" target_ply "donator")
RunConsoleCommand("ps2_addpoints", target_ply:SteamID "points" "10000000")
RunConsoleCommand("ps2_addpoints", target_ply:SteamID "premiumPoints" "350000")
end
if moneycount == "20" then
RunConsoleCommand("ulx", "adduser" target_ply "donator")
RunConsoleCommand("ps2_addpoints", target_ply:SteamID "points" "30000000")
RunConsoleCommand("ps2_addpoints", target_ply:SteamID "premiumPoints" "1000000")
end
if moneycount == "30" then
RunConsoleCommand("ulx", "adduser" target_ply "donator")
RunConsoleCommand("ps2_addpoints", target_ply:SteamID "points" "60000000")
RunConsoleCommand("ps2_addpoints", target_ply:SteamID "premiumPoints" "3000000")
end
if moneycount == "40" then
RunConsoleCommand("ulx", "adduser" target_ply "donator")
RunConsoleCommand("ps2_addpoints", target_ply:SteamID "points" "100000000")
RunConsoleCommand("ps2_addpoints", target_ply:SteamID "premiumPoints" "6000000")
end
end
local donated = ulx.command(CATEGORY_NAME, "ulx donated", ulx.donated, "!donated", true)
donated:addParam{ type=ULib.cmds.PlayerArg }
force:addParam{ type=ULib.cmds.StringArg, completes=ulx.moneycount, hint="Donated Money" }
donated:defaultAccess( ULib.ACCESS_SUPERADMIN )
donated:help( "Donator add" )

It says:
Code: [Select]
[ERROR] addons/darkaddon/lua/ulx/modules/sh/darkcmds.lua:113: ')' expected near 'target_ply'
  1. unknown - addons/darkaddon/lua/ulx/modules/sh/darkcmds.lua:0

Can you help me with that pls?

Greetings
« Last Edit: February 17, 2017, 10:50:46 AM by DarkIce »

Offline captain1342

  • Jr. Member
  • **
  • Posts: 53
  • Karma: 1
    • View Profile
    • Aperture-Hosting
Re: How do i use RunConsoleCommand proparly?
« Reply #1 on: February 17, 2017, 10:55:09 AM »
You forgot the "," you added that all as 1 Argument but that doesen't work. It should look like this:

Code: Lua
  1. RunConsoleCommand("ulx", "adduser", target_ply, "donator")
Aperture-Hosting Manager

Web: https://Aperture-Hosting.de
Mail: Webmaster@Aperture-Hosting.de
Github: https://github.com/captain1242
Discord: https://discord.gg/wxpbtYk
Teamspeak: ts3.Aperture-Hosting.de
Support: https://support.Aperture-Hosting.de
"Hosting with Vision"

Offline DarkIce

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
    • View Profile
Re: How do i use RunConsoleCommand proparly?
« Reply #2 on: February 17, 2017, 11:10:18 AM »
You forgot the "," you added that all as 1 Argument but that doesen't work. It should look like this:

Code: Lua
  1. RunConsoleCommand("ulx", "adduser", target_ply, "donator")
i changed it to:
Code: Lua
  1. function ulx.donated(target_ply, moneycount)
  2.         RunConsoleCommand("ulx", "adduser", target_ply, "donator")
  3.         if moneycount == "10" then
  4.                 RunConsoleCommand("ps2_addpoints", target_ply:SteamID, "points", "10000000")
  5.                 RunConsoleCommand("ps2_addpoints", target_ply:SteamID, "premiumPoints", "350000")
  6.         end
  7.         if moneycount == "20" then
  8.                 RunConsoleCommand("ps2_addpoints", target_ply:SteamID, "points", "30000000")
  9.                 RunConsoleCommand("ps2_addpoints", target_ply:SteamID, "premiumPoints", "1000000")
  10.         end
  11.         if moneycount == "30" then
  12.                 RunConsoleCommand("ps2_addpoints", target_ply:SteamID, "points", "60000000")
  13.                 RunConsoleCommand("ps2_addpoints", target_ply:SteamID, "premiumPoints", "3000000")
  14.         end
  15.         if moneycount == "40" then
  16.                 RunConsoleCommand("ps2_addpoints", target_ply:SteamID, "points", "100000000")
  17.                 RunConsoleCommand("ps2_addpoints", target_ply:SteamID, "premiumPoints", "6000000")
  18.         end
  19. end
  20. local donated = ulx.command(CATEGORY_NAME, "ulx donated", ulx.donated, "!donated", true)
  21. donated:addParam{ type=ULib.cmds.PlayerArg }
  22. donated:addParam{ type=ULib.cmds.StringArg, completes=ulx.moneycount, hint="Donated Money" }
  23. donated:defaultAccess( ULib.ACCESS_SUPERADMIN )
  24. donated:help( "Donator add" )
still it says:

Code: [Select]
[ERROR] addons/darkaddon/lua/ulx/modules/sh/darkcmds.lua:114: function arguments expected near ','
  1. unknown - addons/darkaddon/lua/ulx/modules/sh/darkcmds.lua:0
« Last Edit: February 17, 2017, 11:18:10 AM by DarkIce »

Offline DarkIce

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
    • View Profile
Re: How do i use RunConsoleCommand proparly?
« Reply #3 on: February 17, 2017, 11:35:48 AM »
OK i fixed it by myself i forgot target_ply:GetName() very stupid. thanks for help

Offline iViscosity

  • Hero Member
  • *****
  • Posts: 518
  • Karma: 21
    • View Profile
    • iViscosity Gaming
Re: How do i use RunConsoleCommand proparly?
« Reply #4 on: February 17, 2017, 12:21:08 PM »
I would just like to point out that, if I'm remembering correctly, ULX automatically determines the first variable in a function as the calling_ply, so even if it's not in use you'd need to have something there as a placeholder.
I'm iViscosity. I like gaming and programming. Need some help? Shoot me a PM or Join my Discord!.
--==[ Links ]==--
Steam
YouTube
Steam Group (feel free to join!)
Forums
Public Discord
Teamspeak

Quote from: Steve Jobs
Your work is going to fill a large part of your life, and the only way to be truly satisfied is to do what you believe is great work. And the only way to do great work is to love what you do. If you haven't found it yet, keep looking. Don't settle. As with all matters of the heart, you'll know when you find it. And, like any great relationship, it just gets better and better as the years roll on. So keep looking until you find it. Don't settle.