Add item to inventory from website (PHP)
Discussion in 'Rust Discussion' started by hannn, Sep 15, 2015.
-
if you want to do a webshop, its possible. You will need to send a message to a plugin on the server which gives the item to the player
-
But will I need to do this plugin or it exists?
And if I use this plugin, the server will be in Community or Modded?
Thanks -
you can make it as community without any plugins also
-
Can you help me?
-
By using the RCOn and console commands?
-
yes ^^
-
I've tried
$server1 = new RustRcon('ipadress', '28017', 'password');
if ($server1->Auth()) {
$return = $server1->rconCommand("inv.giveplayer nick Metal Fragments 100");
}
But show me that command not found.
Others like 'kick' work -
inventory.giveto
and you need to use quotes for items with
spaces -
Thanks, but I'm getting "Invalid Item!"
Can you look if it's correct?
Sorry, it's necessary to use Item shortname.Code:$nick = "nick"; $item = "Wood"; $ammount = 100; if ($server1->Auth()) { $return = $server1->rconCommand('inventory.giveto '.$nick.' '.$item.' '.$ammount.''); echo "<pre>$return</pre>"; }
Thanks allLast edited by a moderator: Sep 15, 2015 -
Where you get rust rcon php api? Private?
-
No, get here [PHP] RCON CLASS PHP - Pastebin.com
-
Use this: xPaw/PHP-Source-Query · GitHub
Some code from me for you: [PHP] Give Items to player á web [RUST] - Pastebin.com ( not tested, but you can fix some issues )
Now you just have to make a simple form.
Your input fields should be: token, items, amounts, name
Make a password input for the token field, don't use hidden input and write the token in the code! NEVER EVER!!! It's like a password for this function.
The items input should look like this: > ammo.rocket.basic,ammo.rocket.hv < if you just want to send one item with x amount, don't enter any comma. If you wanna send multiple items than just make a comma between the items WITHOUT whitespace.
The amounts input should be the same like items: > 1,2 < no whitespace between the amount, only a comma.
Can't garantuee that this will work, because I just downgraded my version of this file. ( I'm using a itemshop with items in a database )
The name input it's like a normal input. You can use steamid64 or playername. No multiple names possible for this right now, easy to get this feature inside. -
If you want to do it without rcon, alternatively you can use webrequests
-
Webrequest from site to server? Without rcon? You're fun
-
Thats what i meant. But he will need plugins for that
-
Plugin can receive webrequest without rcon from website?
-
should be able to. In some way. Just play around with it.
-
You can do many things using web requests

[TUTORIAL] Execute Actions from WebRequest [LUA/PHP] | Oxide
