Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Struggling to get Admin Logs #77

Closed
ChrisYatesUK opened this issue Feb 15, 2022 · 19 comments
Closed

Struggling to get Admin Logs #77

ChrisYatesUK opened this issue Feb 15, 2022 · 19 comments

Comments

@ChrisYatesUK
Copy link

ChrisYatesUK commented Feb 15, 2022

Hi Guys..
I cant seem to access the ADM files ...
Can anyone please provide some sample code as its only this that i now preventing me from putting this app live

Thanks

@NitradoTimo
Copy link
Contributor

What files are you trying to get?
Which game is affected?

@ChrisYatesUK
Copy link
Author

ChrisYatesUK commented Mar 22, 2022 via email

@ChrisYatesUK
Copy link
Author

ChrisYatesUK commented Mar 22, 2022 via email

@NitradoTimo
Copy link
Contributor

Sure. Please check if that helps.

<?php

require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../token.php';

$searchedId = 10724662;

try {
    $api = new \Nitrapi\Nitrapi(ACCESS_TOKEN);

    foreach ($api->getServices() as $service) {
        if (!$service instanceof Nitrapi\Services\Gameservers\Gameserver) {
            continue;
        }

        if ($service->getId() == $searchedId) {
            $banlist = new Nitrapi\Services\Gameservers\Banlist($service);
            var_dump($banlist->getBanlist());
            break;
        }
    }

} catch(\Exception $e) {
    var_dump("API Error: " . $e->getMessage());
}

@ChrisYatesUK
Copy link
Author

ChrisYatesUK commented Mar 23, 2022 via email

@ChrisYatesUK
Copy link
Author

ChrisYatesUK commented Mar 23, 2022 via email

@ChrisYatesUK
Copy link
Author

ChrisYatesUK commented Mar 23, 2022 via email

@NitradoTimo
Copy link
Contributor

the errors 2dc99ce353a9492cb07d401cf29c5e5c + f849325c76444f3d85cf3ab137ca6a28 mean "banlist not available for this game".
This comes because of the different implementations of "banlist" within the games itself.

DayZ seems to be one of those games which have a banlist which is not implemented in the Nitrapi management.
If you even use DayZ on a console platform (like XBox) then file uploads (directly into the gameserver) are difficult.
So the "banlist" feature is not applicable for your requirements.

If you use DayZ for PC then you are looking for the "files" feature.

https://webinterface.nitrado.net/$yourServiceIdHere/wi/filebrowser/edit?filepath=dayzstandalone%2Fban.txt

Here an example

<?php

require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../token.php';

try {
    $api = new \Nitrapi\Nitrapi(ACCESS_TOKEN);

    foreach ($api->getServices() as $service) {
        if (!$service instanceof Nitrapi\Services\Gameservers\Gameserver) {
            continue;
        }

        if ($service->getId() == $serviceId) {
            $fs = new \Nitrapi\Services\Gameservers\FileServer\FileServer($service);
            var_dump($fs->getFileList('/games/' . $cid . '/ftproot/dayzstandalone'));
            var_dump($fs->downloadToken('/games/' . $cid . '/ftproot/dayzstandalone/ban.txt'));
            break;
        }
    }

} catch(\Exception $e) {
    var_dump("API Error: " . $e->getMessage());
}

@ChrisYatesUK
Copy link
Author

ChrisYatesUK commented Mar 23, 2022 via email

@NitradoTimo
Copy link
Contributor

"is not working" is not a very good error description ;)

Any error message?

This works for me

var_dump($fs->uploadFile('/_tmp/ban.txt', '/games/' . $cid . '/ftproot/dayzstandalone/', 'ban.txt', ));

@ChrisYatesUK
Copy link
Author

ChrisYatesUK commented Mar 23, 2022 via email

@ChrisYatesUK
Copy link
Author

ChrisYatesUK commented Mar 23, 2022 via email

@NitradoTimo
Copy link
Contributor

My code works and I can see the changes in the Webinterface.
Maybe a server restart is needed for you.

var_dump($fs->downloadToken('/games/' . $cid . '/noftp/dayzxb/ban.txt'));
var_dump($fs->uploadFile('/_tmp/ban.txt', '/games/' . $cid . '/noftp/dayzxb/', 'ban.txt', ));

@ChrisYatesUK
Copy link
Author

ChrisYatesUK commented Mar 23, 2022 via email

@ChrisYatesUK
Copy link
Author

ChrisYatesUK commented Mar 23, 2022 via email

@NitradoTimo
Copy link
Contributor

DayZ XB special case ;)

Please try this

$bans = $service->getCustomerSettings()->readSetting('general', 'bans');
var_dump($bans);
$service->getCustomerSettings()->writeSetting('general', 'bans', $bans . PHP_EOL . 'newusername');

@NitradoTimo
Copy link
Contributor

@ChrisYatesUK did it work?

@ChrisYatesUK
Copy link
Author

ChrisYatesUK commented May 2, 2022 via email

@NitradoTimo
Copy link
Contributor

Hey Chris

Please try this

<?php

require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../token.php';


try {
    $api = new \Nitrapi\Nitrapi(ACCESS_TOKEN);

    /* @var $service Nitrapi\Services\Gameservers\Gameserver */
    $service = $api->getService(['id' => $serviceId]);
    $playerData = $service->getDetails()->getQuery();
    echo $playerData['player_current'], ' of ', $playerData['player_max'], ' are online' . PHP_EOL;

} catch (\Exception $e) {
    var_dump("API Error: " . $e->getMessage());
}

'Closing this thread since it the base issue is solved and it is getting more-and-more into a support thread ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants