Method SetForcedSkins

Discuss everything about Xymph's Aseco flavoured server control scripts for TM Forever / classic TMN and for TM² Canyon.

Moderators: Xymph, TM-Patrol

Post Reply
expressman
happy cruiser
happy cruiser
Posts: 152
Joined: 26 Aug 2006 07:51

Method SetForcedSkins

Post by expressman » 28 Jan 2009 05:03

Hey I'm trying to write an easy SetForcedSkins Plugin.
But I get an error and I can't understand it. I also found no explanation on the web.
Maybe an expert can help me out :wink:

Code: Select all

<?php
   Aseco::registerEvent('onEndRace', 'forceSkins');

   function forceSkins($aseco, $command){

      $aseco->addCall('SetForcedSkins', array(array('Orig'=>'*','Name'=>'','Checksum'=>'','Url'=>'http://.../skin.zip')));
		
   }
?>
So that is what I get in the log:

Code: Select all

...
[RPC Error -501] Non-array type supplied for 'A' specifier Array
(
    [0] => SetForcedSkins
    [1] => Array
        (
            [0] => Array
                (
                    [Orig] => *
                    [Name] =>
                    [Checksum] =>
                    [Url] => http://.../skin.zip
                )

        )

)
Here is the server method description:

SetForcedSkins(array)
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 affects players connecting after the value is set. Only available to Admin.


Is it the list of structs that causes the problem? How does that work in php?
What is a specifier array?

corto-72
smooth traffic navigator
smooth traffic navigator
Posts: 284
Joined: 28 Jul 2008 16:12
Owned TM-games: TMUF
Location: Toulouse
Contact:

Re: Method SetForcedSkins

Post by corto-72 » 28 Jan 2009 09:20

Not sure since I am not using XASECO, but why are you passing an array of array??

$aseco->addCall('SetForcedSkins', array(array('Orig'=>'*','Name'=>'','Checksum'=>'','Url'=>'http://.../skin.zip')));

shouldn't it be
$aseco->addCall('SetForcedSkins', array('Orig'=>'*','Name'=>'','Checksum'=>'','Url'=>'http://.../skin.zip'));

Note that looking at the method descritpion I believe you don't need to call for this at every end of race, since, it seems to be enforced automatically to all player joining after this has been requested.

expressman
happy cruiser
happy cruiser
Posts: 152
Joined: 26 Aug 2006 07:51

Re: Method SetForcedSkins

Post by expressman » 28 Jan 2009 09:34

It's the same error when I use a single array like this

$aseco->addCall('SetForcedSkins', array('Orig'=>'*','Name'=>'','Checksum'=>'','Url'=>'http://.../skin.zip'));

I thought sending an array of an array might be the same in php as a list of structs.
It seems not. I don't know how to handle it.


You are right with the OnEndRace call. One time on Xaseco start up is enough.

Xymph
Pit Crew
Pit Crew
Posts: 5724
Joined: 19 Aug 2007 12:58
Owned TM-games: TMN, TMU, TMF, TM²
Contact:

Re: Method SetForcedSkins

Post by Xymph » 28 Jan 2009 10:59

corto-72 wrote:Not sure since I am not using XASECO, but why are you passing an array of array??

$aseco->addCall('SetForcedSkins', array(array('Orig'=>'*','Name'=>'','Checksum'=>'','Url'=>'http://.../skin.zip')));

shouldn't it be
$aseco->addCall('SetForcedSkins', array('Orig'=>'*','Name'=>'','Checksum'=>'','Url'=>'http://.../skin.zip'));
No, addCall needs to receive its parameters bundled inside an array. So if the method parameter is a list of structs, that translates to an array of arrays in PHP, and you need another array around that, not one less. See the ForcedMods plugin for example.

If you use $aseco->client->query, the method is sent directly to the server instead of being queued like with addCall, and the parameters can be specified individually without bundling them inside an array().
Developer of XASECO for TMF/TMN ESWC & XASECO2 for TM²: see XAseco.org
Find your way around the Mania community from the TMN ESWC hub, TMF hub, TM² hub, and SM hub

corto-72
smooth traffic navigator
smooth traffic navigator
Posts: 284
Joined: 28 Jul 2008 16:12
Owned TM-games: TMUF
Location: Toulouse
Contact:

Re: Method SetForcedSkins

Post by corto-72 » 28 Jan 2009 11:45

fair enough... sorry for the mistake

expressman
happy cruiser
happy cruiser
Posts: 152
Joined: 26 Aug 2006 07:51

Re: Method SetForcedSkins

Post by expressman » 29 Jan 2009 04:20

Thanks a lot. At least the plugin is running now.
The 3rd array did the trick.

But it has no effect. It does not replace and force any skin. No matter what I give as arguments.
I can also check the settings with GetForcedSkins(). It's all set on the server like I pass it.

The skin is directly downloadable.
P2P port is also forwarded. And P2P is allowed in server config. (Anyway, it should not matter imo)
I even used GetSkinsDirectory() and placed the skin in that directory. No luck either.


Any suggestions for this?

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

Re: Method SetForcedSkins

Post by Slig » 29 Jan 2009 17:04

Here is the array that i use as SetForcedSkins argument for GPcoast : http://slig.info/maps/forcedskins.php.txt
Also, i have a copy of all those skins and their .loc in the dedicated dir GameData/Skins/Vehicles/CarCommon/ , and i enable server p2p upload. I also give to players a skin pack with all default skins, so those who install it see them immediatly without downloading in game cache.

As you can notice, for skins replacement i consider that the player can have put in both in CarCommon or envir specific skin dir (note that you have to use '\' for Orig !), and also i did not succeed to just set the Orig to allow them (but pehaps i should have tested a little more), so i do explicit replacement.... Last lines are for default skins.

I am note 100% sure but i think the you have to restart/next the map. And, that is sure, only players who connect after doing the SetForcedSkins will be concerned by the forced skins.

If you want to compute the checksum, you can use that :

Code: Select all

function mkChecksum($data){
        return trim(implode('',array_reverse(explode(',',chunk_split(strtoupper(md5($data)),2,',')))));
}
where $data if the skin file contents.

expressman
happy cruiser
happy cruiser
Posts: 152
Joined: 26 Aug 2006 07:51

Re: Method SetForcedSkins

Post by expressman » 30 Jan 2009 14:06

That helps a lot. Thank you :gobananas:

Post Reply