Pointshop GivePoints Help

Well I have an auto donation system going for ranks but not points i have tried when donation happens it does PS_GivePoints(500) then player name and more stuff like that but nothing will working. Can some one please help. (It has to work in rcon)

Player:PS_GivePoints( integer ) ???

Nope would come up as the players name not being a command

Um, can you give us some context to as what you’re trying to do to achieve this. You’ve mentioned no technical specifications of how you define the rewards per donation.

Ok so all i wan’t is to know a way to give points through the server console the rcon.

The error would help. Here’s a pointshop I modified for a friend. It’s all irrelevant except for: https://dl.dropboxusercontent.com/u/26074909/pointshop-master2.rar

[lua]//
// Acecool
//
hook.Add( “PlayerDeath”, “PointShopPointThingyMaBobber”, function( victim, weapon, killer )
// In a round, otherwise don’t penalize
if ( GAMEMODE.round_state != ROUND_ACTIVE ) then return; end

// Valid?
if ( !IsValid( victim ) || !IsValid( killer ) ) then return; end

// Joining spectator shouldn't lose you points
if ( killer == victim ) then return; end

local _vT = victim:GetRole( );
local _kT = killer:GetRole( );

print( "victim team: ", _vT )
print( "killer team: ", _kT )

// Same team, punnish?
if ( _vT == _kT ) then 
	killer:PS_GivePoints( killer:PS_GetPointMultiplier( PS.Config.PointsForTeamKill ) )
	killer:PS_Notify( "You've lost ", math.abs( killer:PS_GetPointMultiplier( PS.Config.PointsForTeamKill ) ), " points for killing a friendly!" )
	return; 
end

//
if ( _kT == ROLE_TRAITOR && ( _vT == ROLE_DETECTIVE || _vT == ROLE_INNOCENT ) ) then -- killer is traitor and killed detective or innocent
	// Give points
	killer:PS_GivePoints( killer:PS_GetPointMultiplier( PS.Config.PointsForInnocentKill ) )
	killer:PS_Notify( "You've been given ", killer:PS_GetPointMultiplier( PS.Config.PointsForInnocentKill ), " points for killing a terrorist ( innocent )!" )
	return; 
end

//
if ( ( _kT == ROLE_DETECTIVE || _kT == ROLE_INNOCENT ) && _vT == ROLE_TRAITOR ) then -- Killer is innocent or detective and killed traitor
	// Give points
	killer:PS_GivePoints( killer:PS_GetPointMultiplier( PS.Config.PointsForTraitorKill ) )
	killer:PS_Notify( "You've been given ", killer:PS_GetPointMultiplier( PS.Config.PointsForTraitorKill ), " points for killing a traitor!" )
	return; 
end

end )[/lua]

[lua] // Acecool
if PS.Config.PointsOverTime then
timer.Create(‘PS_PointsOverTime_’ … self:UniqueID(), PS.Config.PointsOverTimeDelay * 60, 0, function()
self:PS_GivePoints( self:PS_GetPointMultiplier( PS.Config.PointsOverTimeAmount ) )
self:PS_Notify("You’ve been given “, self:PS_GetPointMultiplier( PS.Config.PointsOverTimeAmount ), " points for playing on the server!”)
end)
end[/lua]

// Bad Hack
[lua]//
// Acecool – I hate doing things this way.
//
function Player:PS_GetPointMultiplier( _points )
local _multi = 1;

// Multi = 1
if self:IsUserGroup("user") then
end

// 2?
if self:IsUserGroup("goldvip") then
	_multi = 2;
end

// 3?
if self:IsUserGroup("diamondvip") then
	_multi = 3;
end

// 4?
if self:IsUserGroup("admin") then
	_multi = 4;
end

// 5?
if self:IsUserGroup("superadmin") then
	_multi = 5;
end

// 6?
if self:IsUserGroup("owner") then
	_multi = 6;
end

return _points * _multi;

end[/lua]

So, what this tells you, hopefully, is that you need to call PLAYER_WHO_GETS_POINTS:PS_GivePointS( number_amount ); Make sure it’s a number by using tonumber if it’s data returned through a web-form.

EDIT: Ninja’ed. To give points by searching for a name you can use this, I just wrote it:

[lua]concommand.Add( “pointsgiver”, function( ply, cmd, args )
if ( ply != NULL && !ply:IsSuperAdmin( ) ) then return; end
local _match = NULL;
for k, v in pairs( player.GetAll( ) ) do
local _find = string.find( string.lower( v:Nick( ) ), string.lower( args[ 1 ] ) ); – Returns nil if pattern not found, otherwise it returns index or so: http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index15fa.html
if ( !_find ) then
continue;
else
_match = v;
break;
end
end

if ( IsValid( _match ) && _match:IsPlayer( ) ) then
	print( "We found the player you were looking for, their steamid is : " .. _match:SteamID( ) );
	_match:PS_GivePoints( 500 );
else
	print( "The force was not with you on this one young grasshopper." )
end

end ) [/lua]

well there is no way without a player object. Grabbing a player by name isn’t a viable solution either, because what if the player is offline? Their player object simply doesn’t exist.

[editline]15th December 2013[/editline]

Acecool what have you done to my glorious Pointshop code, have you never heard of elseif, also that has nothing todo with giving a player points.

[lua]concommand.Add( “pointsgiver”, function( ply, cmd, args )
if ( ply != NULL && !ply:IsSuperAdmin( ) ) then return; end
local _match = NULL;
for k, v in pairs( player.GetAll( ) ) do
local _find = string.find( string.lower( v:Nick( ) ), string.lower( args[ 1 ] ) ); – Returns nil if pattern not found, otherwise it returns index or so: http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index15fa.html
if ( !_find ) then
continue;
else
_match = v;
break;
end
end

if ( IsValid( _match ) && _match:IsPlayer( ) ) then
	print( "We found the player you were looking for, their steamid is : " .. _match:SteamID( ) );
	_match:PS_GivePoints( 500 );
else
	print( "The force was not with you on this one young grasshopper." )
end

end ) [/lua]

Here’s what I just wrote for you to give points through rcon.

pointsgiver Ace will detect anyone with ace in their name.

Matt: It was a quick and ugly hack for a friend. They wanted to make the system slightly more unique so based on level of vip it’ll multiply the number of points. if/elseif wouldn’t be my first choice for doing it “right”. I would’ve set up a table, with the key as the groupname in lowercase, then grabbed it using O( 1 ) instead of all the if/elseif but instead I just did that and wrote that for a quick test / copy/paste to just get it done.

would this go in the servers autorun?

Yeah; or you can put it in one of the pointshop server-files. Either way works.

Okay so how would this command work? lke “pointsgiver STEAM_0:0:42626752” ?

Basically, you type pointsgiver and then a search string for a name.

So you can type a full name, or a partial name. The output will tell you if it found who got it as SteamID for additional confirmation.

And how does this help?

You guys realize this is suppose to be when they donate, it automatically gives them 500 points the next time they join the server, or if they are already on the server, it gives them 500 points. Not when someone uses a console command.

It should work as a con command any way because to set up you need to put it as an rcon command so on donation it will run for the steam:id and give the points auto through console

But it shouldn’t work like that! What happens when a player donates and they’re not on the server? This automatic donation system you brought sounds pretty bad, it should be able to provide a hook when a player joins to call a hook for a specific donation.

[editline]16th December 2013[/editline]

You can’t do STEAMID:PS_GivePoints, you require a player object. Depending on the data provider you’re using for Pointshop you can work around this, but it’s a very poor way to do it.

He asked for a concommand so I provided one which I wrote a long time ago ( search method for name ) and added the rest.

These guys are correct though; if you want an automated system you really can’t use the concommand.

You should have a database set up with users, and give points to their record. I believe the pointshop uses a form of databasing, either the built in, or it can use MySQL. Add the data to those tables so that regardless of whether or not they’re in the server, they’ll get the points.

Set it up so there are NO console commands to give points, and automate it.

Sorry for the bump but I need this script, how would I use it? Would it go in the pointshop autorun?