Jump to content
Heisen99

Scripters Question & Answer Thread

Recommended Posts

Hey, 

i just started trying to mod dayz a lil bit and already ran into my first problem, i cant wrap my head around why it wont work. 

Its about the OnKeyPress() function that just doesnt seem to get called properly.

First i thought it might be a problem with getting the right player. So i tried just setting the WorldDate. Then i tried with "key != KC_K" so it should be called with every key press. Then i tried putting my functions right behind super.OnKeyPress(), so it should not matter which key i press at all but it doesnt run either.

It is getting compiled without error.

The Function: 

Quote

override void OnKeyPress(int key)

{

super.OnKeyPress(key);

PlayerBase player = GetGame().GetPlayer();

if( key == KeyCode.KC_K)

{

//ALL THESE DONT WORK

GetGame().ChatPlayer("KEY TEST");

giveM4(player);

GetGame().GetWorld().SetDate(2000,1,1,12,0);

}

}

Full Code

Quote

class CustomMission: MissionServer

{

override PlayerBase CreateCharacter(PlayerIdentity identity, vector pos, ParamsReadContext ctx, string characterName)

{

Entity playerEnt;

playerEnt = GetGame().CreatePlayer(identity, characterName, pos, 0, "NONE");//Creates random player

Class.CastTo(m_player, playerEnt);

GetGame().SelectPlayer(identity, m_player);

return m_player;

}

override void TickScheduler(float timeslice)

{

int year, month, day, hour, minute;

GetGame().GetWorld().GetDate(year, month, day, hour, minute);

static int i = 0;

if(i%100000 == 0){

GetGame().ChatPlayer("TICK" + hour.ToString());

}

i++;

}

override void StartingEquipSetup(PlayerBase player, bool clothesChosen)

{

EntityAI knife;

knife = player.GetInventory().CreateInInventory("HuntingKnife");

giveM4(player);

}

override void OnKeyPress(int key)

{

super.OnKeyPress(key);

PlayerBase player = GetGame().GetPlayer();

if( key == KeyCode.KC_K)

{

//ALL THESE DONT WORK

GetGame().ChatPlayer("KEY TEST");

giveM4(player);

GetGame().GetWorld().SetDate(2000,1,1,12,0);

}

}

};

void giveM4(PlayerBase player){

EntityAI weapon;

weapon = player.GetHumanInventory().CreateInHands("M249");

}

 

Edited by chickiexd

Share this post


Link to post
Share on other sites

So my question is how to spawn additional cars on the map without clogging up the init. Currently i am calling a scrip file in the init.c

class CreateVehicle
{
    private Car vehicle;
    void CreateVehicle(string vehName, vector pos)
    {
        vehicle = GetGame().CreateObject(vehName, pos);
    }
    void addVehicleFuel(float fuelAmount)
    {
        vehicle.Fill(CarFluid.FUEL, fuelAmount);
    }
    
    void addVehicleCoolant(float coolantAmount)
    {
        vehicle.Fill(CarFluid.COOLANT, coolantAmount);
    }
    
    void addVehicleComponents()
    {
        vehicle.GetInventory().CreateAttachment("Hatchback_02_Wheel");
        vehicle.GetInventory().CreateAttachment("Hatchback_02_Wheel");
        vehicle.GetInventory().CreateAttachment("Hatchback_02_Wheel");
        vehicle.GetInventory().CreateAttachment("Hatchback_02_Wheel");
        vehicle.GetInventory().CreateAttachment("CarBattery");
        vehicle.GetInventory().CreateAttachment("CarRadiator");
        vehicle.GetInventory().CreateAttachment("SparkPlug");
        vehicle.GetInventory().CreateAttachment("Hatchback_02_Door_1_1");
        vehicle.GetInventory().CreateAttachment("Hatchback_02_Door_1_2");
        vehicle.GetInventory().CreateAttachment("Hatchback_02_Door_2_1");
        vehicle.GetInventory().CreateAttachment("Hatchback_02_Door_2_2");
        vehicle.GetInventory().CreateAttachment("Hatchback_02_Hood");
        vehicle.GetInventory().CreateAttachment("Hatchback_02_Trunk");    
        
    }
    
    
}

init.c

CreateVehicle myHatchback = new CreateVehicle("Hatchback_02","575.151001 5.839860 1735.019287");

CreateVehicle myHatchback2 = new CreateVehicle("Hatchback_02","575.151001 5.839860 1735.019287");

This creates the car but for every car i make, i have to name it car1,car2, car3 etc however many times i want them to spawn. So im looking for a way to spawn 3 different vehicle types and just assign whichever type to a certain spawn point. Obviously i still want to be able to spawn them full of parts like the above code.

Share this post


Link to post
Share on other sites

Is there a way to tie one charachter to three servers running three maps. Like I have a deerisle a charnarus and a livonia I want to play one character across all three is that possible

Share this post


Link to post
Share on other sites

Hello survivors!

I have three positions, one - car, second - door, third - door on the car

How I calculate third position and orientation if I have one and two positions and orientations and result:

Position1 - <4769.067871, 475.491882, 15035.115234>

Orientation1 - <49.184288, -1.635105, -2.592932>

 

Position2 - <0.125 -0.129 -0.870>

Orientation2 - <0.0 200.0 0.0>

 

Position3 - <4769.730957, 475.398682, 15034.538086>

Orientation3 - <-110.815697, -0.000000, 0.000000>

Share this post


Link to post
Share on other sites

I have a quick question regarding the settings of my private server. If players are hoarding packaged nails or ammo. Does it still spawn, does it have to be unpacked to continue spawning or does it no longer count towards the loot pool when hoarded? 

Would appreciate an answer very much 

Best regards from Germany

Share this post


Link to post
Share on other sites

Hello, I'm trying to find a way to connect to a DayZ server using your web browser. I know it's possible using Steam server and FiveM server, but everything I've tried from resources online isn't working.

Share this post


Link to post
Share on other sites
On 1/13/2023 at 3:22 AM, TheUnknown707 said:

Hello, I'm trying to find a way to connect to a DayZ server using your web browser. I know it's possible using Steam server and FiveM server, but everything I've tried from resources online isn't working.

Use Steam Web API protocol. I don't have protocol specifications near by me but you may find how connect for css servers. DayZ uses same trick.

Here the example:

steam://startgame/221100/xxx.xxx.xxx.xxx:zzz

You need to find how to start the game and then just submit ip:port. Description startgame is as example i have no steam api cmd for start the game right now but that's working since 0.32 path of DayZ and still working. But you may met a problem that the game has no idea wotchods your server using but on client side if you has app you may fix that coz Bohemian launcher using bohemian's server list woth mods in that so you may parce it and start the game.

 

Here for you an update:

https://developer.valvesoftware.com/wiki/Steam_browser_protocol

steam://connect/<IP or DNS name>[:<port>][/<password>]

steam://rungameid/<id>

Same as run, but with support for mods and non-Steam shortcuts

 

So it should be:

steam://run/221100/IP:Port

Also if you has any questions about implementation at client side code of connection to game server I'll be glad to help you if i could my discord is Sod_Debian#2110 please type to me in 10am - 9pm of UTC/GMT +3 (Moscow time aka -12 PT).

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×