Help with the "SetForcedSkins" XML-RCP method?

This is the place where you can find everything related to the dedicated server, control scripts and community tools.

Moderators: Pit Crew, TM-Patrol

Post Reply
User avatar
kristjan
speedy pilot
speedy pilot
Posts: 427
Joined: 18 Aug 2005 13:17
Location: Norway

Help with the "SetForcedSkins" XML-RCP method?

Post by kristjan » 06 Jul 2010 01:45

I have tried to figure out how to use the "SetForcedSkins" XML-RPC method. But i just can't get it working!

SetForcedSkins returns true, and GetForcedSkins returns what i sent with SetForcedSkins, so the server did successfully receive the request.
Although everything looks like it works, i see no change.

Unless i misunderstood the use of this function?
In the changelog, it says:
changelog wrote:SetForcedSkins()/GetForcedSkins(): new method to help people doing F1 or Monster trucks, ... competitions have everybody use a "good" skin. It allows to have an explicit list of allowed skins and replacement skins.)
So, if i understand it correctly, it's for allowing only a selected list of vehicles to be used, right?

Looking at the method help, i didn't understand much:
Defines a list of remappings for player skins. It expects a list of structs Orig, Name, Checksum, Url. Orig is the name of the skin to remap, or '*' for any other. Name, Checksum, Url define the skin to use. (They are optional, you may set value '' for any of those. All 3 null means same as Orig). Will only affect players connecting after the value is set. Only available to Admin.
As I said, I didn't understand much, so i found this post by slig which helped me out a lot! (thanks slig)
He linked to a file where he showed a list he was using. I tried with one of his.
This is what i got:

Code: Select all

<?php
require 'GbxRemote.inc.php';

$client = new IXR_Client_Gbx();

if (!$client->Init(5000))
	die('"offline"');

if (!$client->query('Authenticate', 'SuperAdmin', 'SuperAdmin'))
	die('"Auth failed..."');

echo '<h2>Current settings:</h2><pre>';
$client->query('GetForcedSkins');
$res = $client->getResponse();
var_dump($res);
echo '</pre>';


$req = $client->query('SetForcedSkins', array(
	array(
		'Orig'=>'*',
		'Name'=>'Skins/Vehicles/CarCommon/GPF1A_Black.zip',
		'Checksum'=>'DD7FB67FCE93FD2D0BC8F55DD6C5A6AE',
		'Url'=>'http://deditm.com/skin/gpf1/GPF1A_Black.zip'
	)
));

$res = $client->getResponse();

var_dump($req, $res);
?>
What i expect this code to do: Force every player to use the skin on the given url.

I have ,of course, rejoined the server.
I have tried putting the file in the skins folder on the server together with a .loc file.
I have also tried to restart, and skip challenge.
P2P is enabled.

Could someone explain to me what i am doing wrong. Or if i misunderstood the function of the method, please explain!
I hope someone will reply! :roll:
kristjan aka MiniGod

ganply
highway camper
highway camper
Posts: 2
Joined: 29 Oct 2009 13:37
Owned TM-games: tmu

Re: Help with the "SetForcedSkins" XML-RCP method?

Post by ganply » 10 Jul 2010 09:49

Maybe only other players see the skin, but not the player himself (I don't know, it's just a supposition).

User avatar
Slig
Pit Crew
Pit Crew
Posts: 2124
Joined: 05 Sep 2005 17:51
Owned TM-games: ALL
Location: TraxicoLand (Fr)
Contact:

Re: Help with the "SetForcedSkins" XML-RCP method?

Post by Slig » 12 Jul 2010 10:59

Yes, the player itself see his own skin, and see the replacement skins for other cars.

For default skins, look the last entries of http://slig.info/maps/forcedskins.php.txt for a working example.
For replacement skins, be sure to have exact (windows type) path in 'Orig'

For both cases, 'Name' have to be possible (existing folder in clients), 'Url' valid with same file name, and perhaps a valid .loc at the same place, 'Checksum' have to be correct for the default/replacement skin.

Also, it can help to activate the dedicated p2p upload (ie <enable_p2p_upload>True</enable_p2p_upload>), and put the skins and their .loc on the dedicated GameData/<'Name'> folder (for example for 'Name'=>'Skins/Vehicles/CarCommon/GPF1A_Black.zip', put in <dedicated>/GameData/Skins/Vehicles/CarCommon/GPF1A_Black.zip and <dedicated>/GameData/Skins/Vehicles/CarCommon/GPF1A_Black.zip.loc ; the .loc caontain is the exact valid 'Url' and nothing else)

Don't forget to do a next/restart, and disconnect/reconnect on the server, as it seems that the clients games get the replacements skins only when connecting.

User avatar
Slig
Pit Crew
Pit Crew
Posts: 2124
Joined: 05 Sep 2005 17:51
Owned TM-games: ALL
Location: TraxicoLand (Fr)
Contact:

Re: Help with the "SetForcedSkins" XML-RCP method?

Post by Slig » 19 Feb 2011 18:06

A little more explanations :


If you want to force all skins to a specific, you should make one or several default replacements.
For example one randomly of 2, you should use something looking like that (a part of the one i use for GPcoast) :

Code: Select all

$forcedskins = array(
 array('Orig'=>'*','Name'=>'Skins/Vehicles/CarCommon/GPF1A_Black.zip','Checksum'=>'DD7FB67FCE93FD2D0BC8F55DD6C5A6AE','Url'=>'http://deditm.com/skin/gpf1/GPF1A_Black.zip'),
 array('Orig'=>'*','Name'=>'Skins/Vehicles/CarCommon/GPF1A_Cyan.zip','Checksum'=>'0971A85C9BCB2A3EA58FDD059898B30A','Url'=>'http://deditm.com/skin/gpf1/GPF1A_Cyan.zip')
);

$aseco->client->query('SetForcedSkins',$forcedskins);
Don't forget that it won't have any effect until a next or restart come.


I am not sure if all are mandatory, but better also :
- allow server p2p upload, can be done at run time in plugin with $aseco->client->query('EnableP2PUpload',true);
- have the concerned skins in the right place in dedicated directories, ie in this example case : GameData/Skins/Vehicles/CarCommon/GPF1A_Black.zip and GameData/Skins/Vehicles/CarCommon/GPF1A_Cyan.zip , i also put there their locators files, ie GameData/Skins/Vehicles/CarCommon/GPF1A_Black.zip.loc and GameData/Skins/Vehicles/CarCommon/GPF1A_Cyan.zip.loc (each one is a simple text file containing only the skin url)
- have the Url links to the right skins and locator files working
- set a correct Checksum value for each

To make the checksum, you can use that :

Code: Select all

$skinchecksum =  mkChecksum(file_get_contents('skinfilename'));

function mkChecksum($data){
        return trim(implode('',array_reverse(explode(',',chunk_split(strtoupper(md5($data)),2,',')))));
}


If you want a specific player skin replacement, add it in main array before the default ('*') entries (if you use default one(s) ). All is the same as for default ones, just set 'Orig' to the value (ie skin path) that you want to replace.

Important: 'Orig' path have to use backslashes like for a windows path (for example: 'Skins\Vehicles\CoastCar\gTg-F1-Discovery.zip'), and it have to be the exact path used by the player (in my example, if the player have put it in Skins\Vehicles\CarCommon\ and not in Skins\Vehicles\CoastCar\ then it won't work !). Eventually add more entries for various possible directories.
For example this will work if the player have put gTg-F1-Discovery.zip in Skins\Vehicles\CarCommon\ or Skins\Vehicles\CoastCar\ :

Code: Select all

 array('Orig'=>'Skins\Vehicles\CarCommon\gTg-F1-Discovery.zip','Name'=>'Skins/Vehicles/CarCommon/GPF1A_Black.zip','Checksum'=>'DD7FB67FCE93FD2D0BC8F55DD6C5A6AE','Url'=>'http://deditm.com/skin/gpf1/GPF1A_Black.zip'),
 array('Orig'=>'Skins\Vehicles\CoastCar\gTg-F1-Discovery.zip','Name'=>'Skins/Vehicles/CarCommon/GPF1A_Cyan.zip','Checksum'=>'0971A85C9BCB2A3EA58FDD059898B30A','Url'=>'http://deditm.com/skin/gpf1/GPF1A_Cyan.zip')

Note: unsing the GetDetailedPlayerInfo method you can get the exact sking path and name used by a player, which is the value to set in 'Orig' to replace it.

Post Reply