Hello to whomever it may concern,
I have here an addon for an F3 menu, and i'm hoping to make it so that SDonate can be used to add a certain amount of credits to the user's credit amount. The only way I can see to do that, is by using a cvar. Now, I used the ulx addcredits command, but this would only work with the player's nickname in that server, and SDonate can only output steam names and Steam IDs.
So, what I planned to do was either make a new command just for doing the same thing with the ID, or to make the current one there compatible with Steam IDs.
If anybody could help me out, it'd be much much appreciated. I'm brand new to Ulysses, and still fairly new to Lua coding with only having a few addons i've made.
Current AddCredits command code:
function ulx.addCredits( calling_ply, target_ply, amount )
if( type( amount ) != "number" ) then
calling_ply:ChatPrint( "Invalid amount! Only a number." );
return;
end
ML:AddCredits( target_ply, amount );
ulx.fancyLogAdmin( calling_ply, "#A gave #T #i credits", target_ply, amount );
end
local addCredits = ulx.command( CATEGORY_NAME, "ulx addcredits", ulx.addCredits, "!addcredits" )
addCredits:addParam{ type=ULib.cmds.PlayerArg };
addCredits:addParam{ type=ULib.cmds.NumArg, hint="credits" };
addCredits:defaultAccess( ULib.ACCESS_ADMIN );
addCredits:help( "Add to the F3 credits of a user(you can use negative amounts like -100)." );
ULX's player arguments use target strings to select a player. It defaults to look for partial name matching, but there are a number of special operators you can use as well. I think this is more or less a complete list:
%superadmin (group+inheritance)
#superadmin (single group only)
@ (the player you're looking at)
! (inverse of next operator)
$id (Any form of ID such as SteamID, IP, UniqueID, etc.)
That last one should be able to do exactly what you need it to. I found an old post on our forums that gives an example of the best way to utilize it:
https://forums.ulyssesmod.net/index.php?topic=9644.0
Ok, so... Complete shot in the dark here, and I know this won't work... But what can I change about this to make it work then? I'm also not sure i've fully grasped the idea of what you've told me.
I do apologise for being a little slow today
function ulx.addCreditsID( calling_ply, sid, amount )
if( type( amount ) != "number" ) then
calling_ply:ChatPrint( "Invalid amount! Only a number." );
return;
end
ML:AddCredits( sid, amount );
ulx.fancyLogAdmin( calling_ply, "#A gave #T #i credits", sid, amount );
end
local addCreditsID = ulx.command( CATEGORY_NAME, "ulx addcreditsid", ulx.addCreditsID, "!addcreditsid" )
addCreditsID:addParam{ type=ULib.cmds.PlayerArg };
addCreditsID:addParam{ type=ULib.cmds.NumArg, hint="credits" };
addCreditsID:defaultAccess( ULib.ACCESS_ADMIN );
addCreditsID:help( "Add to the F3 credits of a user using their Steam ID (you can use negative amounts like -100)." );
Why are you doing it this way instead of running a custom Lua script within SDonate?
Because I have no idea how the actual credit system works, and how i'd add credits like that.
Basically I'm saying that you shouldn't have to create a new command- you can just invoke the existing command directly. Probably something like this:
RunConsoleCommand("ulx", "addcredits", "$" .. ULib.getUniqueIDForPlayer(LocalPlayer()), "1000")
And I assume that would work if I was to use SDonate's {{VAR=STEAMID}} in replace of the get unique ID for player, like so...
RunConsoleCommand("ulx", "addcredits", "$" .. {{VAR=STEAMID}}, "10000")
ML:AddCredits( "{{VAR=STEAMID}}", "10000" );
That's all you would have to add as a custom Lua script to SDonate, assuming ML isn't localized.
I'm guessing SDonate doesn't add quotes automatically when replacing {{VAR=STEAMID}}
Nope, for some reason it does quite literally nothing.
Sorry, you need to Log In to post a reply to this thread.