• Print

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

0 Members and 1 Guest are viewing this topic.

Offline DarkIce

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
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

  • Full Member
  • ***
  • Posts: 104
  • Karma: 6
  • Quality is our standard
    • Aperture Development - Quality is our standard
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 Development
Quality is our standard

Website - GitHub  - Forum  - Steam  - Discord

Offline DarkIce

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
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: 4
  • Karma: 0
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

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
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 PM.

  • Print