Jump to content
Sign in to follow this  
Acecool

Little issue - Duplicate cars, scripts not attaching if createVehicle done server...

Recommended Posts

Should I be createVehicle-ing on the client, or the server side?

I currently have it set on the server only, it creates the vehicle/house and positions it perfectly. But, it is not attaching the script to the car, or at least it might be on the server, but not on the player side.

If I run the same script on client side, if another player joins, another car is created. Scripts work, but hints show up for everyone :-/

Any ideas? If code is needed I can provide.

---------- Post added at 08:46 AM ---------- Previous post was at 08:43 AM ----------

If anyone wants to look, connect to the RPG Crime City Alpha server!

The map is [RPG] CrimeCity_Alpha_1_8 for the client side, and 2_0 for serverside...

Share this post


Link to post
Share on other sites
If code is needed I can provide.

You should do that automatically when asking for help.

Share this post


Link to post
Share on other sites

This is server only execvm this script:

_temp = "VWGolf" createVehicle _markerPosition;
removeAllWeapons _temp; 
nil = [_temp, 55] execVM "Server\f_vehicleHindered.sqf";
nil = [_temp] execVM "Server\f_pointToNearestRoad.sqf";

It points to the nearest road, but it doesnt get hindered...

This is the main portion of the turbo script which is used with vehicle hindered except with - boost.

_car setVelocity [ ( _xvel ) + ( (sin _dir) * _boostLevel ),
				    ( _yvel ) + ( (cos _dir) * _boostLevel ),
				    ( _zvel ) - ( 0.00009 )
		];

But the entire script should be attached to the car...

Edit: I also tried running the script by using a trigger, on not preset. But it created 2 cars even though the trigger was only supposed to activate 1 time.

---------- Post added at 12:45 PM ---------- Previous post was at 11:08 AM ----------

Solved! I need someone to connect to test if claiming ownership works properly.

But, it seems to work perfectly.

Created a toggle lock system, etc...

The way I got around it was by adding an action for a script to claim ownership - that script unlocks the car, puts the person in driver seat, and locks the car - then the player has access to the lock/unlock script, and the script gets added at the claim ownership level :-)

I had to use

_temp setvehicleinit "removeAllWeapons this; this lock true; this addAction ['Claim Ownership', 'Client\f_claimOwnership.sqf']; player reveal this";

processInitCommands;

Edited by Acecool

Share this post


Link to post
Share on other sites

I am going to bump this real quick...

I added a script via addaction, then player reveal this for the claiming ownership. The script works, and then lets that person lock and unlock the car which I think shows up for everyone - not sure... about to go test so I need testers!!!

But anyways, when someone claims ownership, it only removes the action for the person that executed the script instead of it removing the action for EVERYONE so the car can only have 1 owner.

Any ideas?

f_claimOwnership.sqf

_vehicle = _this select 0;
_player = _this select 1;
_myAction = _this select 2;
_isLocked = locked _vehicle;

_vehicle removeAction _myAction;
_vehicle lock false;
_player action ["getInDriver", _vehicle];
_vehicle lock true;
if ( Player == _player ) then { _myAction = _vehicle addAction ["Unlock", "Client\f_toggleCarLock.sqf"]; nil = [_temp, 55] execVM "Server\f_vehicleHindered.sqf"; };

f_toggleCarLock.sqf

//
// Toggles the car lock
//
_vehicle = _this select 0;
_player = _this select 1;
_myAction = _this select 2;
_isLocked = locked _vehicle;

_vehicle removeAction _myAction;

//if (driver _vehicle != _player) then { _player Sidechat "* Jingle Jingle *"; Sleep 0.5; };


// Locked
if ( _isLocked ) then
{
_player sideChat "Unlocked!";
_vehicle lock false;
_myAction = _vehicle addAction ["Lock", "Client\f_toggleCarLock.sqf"];
}
else
{
_player sideChat "Locked!";
_vehicle lock true;
_myAction = _vehicle addAction ["Unlock", "Client\f_toggleCarLock.sqf"];
};

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
Sign in to follow this  

×