Hi guys,
I am coding a web application and the app can give points to players. I use the xPaw class for this. I tested the RCON connection with Rusty(connection works) and I don't know how I can add points. I use the pointshop from Undefinied.
Greets
miny
Look through the files next time; you'll be able to find the answer quicker than we can answer
ply:PS_GivePoints(NUMBER)
That's that I don't need! I need the CONSOLE command and not the Lua method.
[QUOTE=miny1997;46141565]That's that I don't need! I need the CONSOLE command and not the Lua method.[/QUOTE]
Don't get aggressive with people who are trying to help you.
Pointshop doesn't have console commands for giving points. You'll have to make one I saw this posted in another thread but you'll have to modify to accept steamids.
[code]
concommand.Add("ps_give_points", function(ply, cmd, args)
if #args != 2 then
ply:ChatPrint("Missing arguments! ps_give_points <player-id> <points>")
return
end
other = player.GetByID(args[1])
points = tonumber(args[2])
if points < 0 then
ply:ChatPrint("You can't give a negative amount of points")
return
end
if (ply:IsAdmin()) and other and points and IsValid(other) and other:IsPlayer() then
other:PS_GivePoints(points)
other:PS_Notify(ply:Nick(), ' gave you ', points, ' points.')
ply:PS_Notify('You gave "', other:Nick(), '" ', points, ' points.')
end
end)
[/code]
Re-did the code above, untested, but should work.
[lua]
concommand.Add("ps_give_points", function(ply, args, cmd)
local target
for k,v in pairs(player.GetAll()) do
if string.find(string.lower(v:Nick()), string.lower(tostring(args[1]))) or string.find(string.lower(tostring(v:SteamID())), string.lower(tostring(args[1]))) then
target = v
end
end
if (#args < 2) then
ply:ChatPrint("Missing arguments! Do ps_give_points <player> <amount of points>")
return
end
if tonumber(args[2]) < 0 then
ply:ChatPrint("You can not give negative amount of points!")
return
end
if (ply:IsAdmin()) and target and tonumber(args[2]) and IsValid(target) and target:IsPlayer() then
target:PS_GivePoints(points)
target:PS_Notify(ply:Nick(), ' gave you ', tonumber(args[2]), ' points.')
ply:PS_Notify('You gave "', target:Nick(), '" ', tonumber(args[2]), ' points.')
end
end)
[/lua]
Example: ps_give_points Author 100 ps_give_points STEAM_0:0:58068155 100
Both commands would give me 100 pointshop points.
[lua]for k,v in pairs(player.GetAll()) do
if string.find(string.lower(v:Nick()), string.lower(tostring(args[1]))) or string.find(string.lower(tostring(v:SteamID())), string.lower(tostring(args[1]))) then
local target = v
end
end[/lua]
Don't use local target inside the loop, just do
[lua]target = v[/lua]
since it's already defined above.
[QUOTE=Neddy;46141711]
[code]
concommand.Add("ps_give_points", function(ply, cmd, args)
if #args != 2 then
ply:ChatPrint("Missing arguments! ps_give_points <player-id> <points>")
return
end
other = player.GetByID(args[1])
points = tonumber(args[2])
if points < 0 then
ply:ChatPrint("You can't give a negative amount of points")
return
end
if (ply:IsAdmin()) and other and points and IsValid(other) and other:IsPlayer() then
other:PS_GivePoints(points)
other:PS_Notify(ply:Nick(), ' gave you ', points, ' points.')
ply:PS_Notify('You gave "', other:Nick(), '" ', points, ' points.')
end
end)
[/code]
[/QUOTE]I got this error using the command by RCON:
[code]08:42:39 [ERROR] lua/autorun/ps.lua:23: attempt to call method 'IsAdmin' (a nil value)
1. unknown - lua/autorun/ps.lua:23
2. unknown - lua/includes/modules/concommand.lua:69[/code]
[QUOTE=miny1997;46212581]I got this error using the command by RCON:
[code]08:42:39 [ERROR] lua/autorun/ps.lua:23: attempt to call method 'IsAdmin' (a nil value)
1. unknown - lua/autorun/ps.lua:23
2. unknown - lua/includes/modules/concommand.lua:69[/code][/QUOTE]
When you call a concommand from the server console the ply argument is no longer a player it's Entity( 0 ).
Ok, sounds logical. But I have a question. Are there other ways than the RCON to run console command where I must check for admin rights?
Sorry, you need to Log In to post a reply to this thread.