Hi, i have a odd Problem.... Its a bit more to read to explain it properly, and so i hope some of you talented scripting-people might help me.
Situation (4 Scripts):
- A "Drugdealer" (a basic car with a SLA soldier) is driving around some 20 marker-points on the map, halts at each marker-point for a random time between 5 and 25 minutes and then continues to a next point. Once the Dealer is dead or the vehicle destroyed it gets respawned at the next random marker point and continues with the way.
It gets called by the init.sqf and only run on the server (aka. if (!isServer) exitWith {}; )- A huge script (only run LOCAL on client machines) checks if you are near the Drugdealer Vehicle and if you are nearer than 5m to it, a actionmenu entry appears for buying "drugs" at the vehicles which then opens a other script of course. If you are more than 5m away the action is gone.
Get called by a sub-file from the init.sqf and only runs on client machines to save ressources, as it cointains a big while-loop which fires every second and checks 50 different shop-actionmenus!- Another script(check) to "arrest" or in other word to delete the Drugdealer (is working also after drugdealer killed and respawned)
This check gets called from the init.sqf from a if-clause if ( ((not(dedicatedServer)) and (isServer)) or (not(isServer)) ) then {
. It is the only script which still works when the Drugdealer was dead and respawned!- A fourth script which has a while-loop and checks if the Drugdealer is alive. Once hes not alive anymore, a hint gets broadcasted telling the Drugdealer is dead/or busted.
this script gets called from the init.sqf and runs only on the serverProblems:
1. As soon as the Drugdealer is dead and respawned, no actionmenu-entry is appearing anymore for buying of drugs.
2. Script Number 4 (the one which checks if the dealer is alive, and as soon as he is not, gives a hint) is only working ONCE.Now the Scripts used:
1. Drugdealerscript (Version to only randomize at 3 markers to test better):
// Drugdealer on Wheels Script
if (!isServer) exitWith {};
while {true} do {
_spawn_pos = call compile format ["markerPos 'drugstop%1';", ceil random 3];
drugvehicle = createVehicle ["vil_nysa", _spawn_pos, [] , 0, "NONE"];
drugvehicle setVehicleInit
"drugvehicle = this;
this setVehicleVarName ""drugvehicle"";
this setVehicleLock ""LOCKED"";
this setAmmoCargo 0;
";
publicvariable "drugvehicle";
drggrp = createGroup east;
drug_einheit = drggrp createUnit ["SoldierEB", _spawn_pos, [], 1, "NONE"];
[drug_einheit] join drggrp;
removeallweapons drug_einheit;
drug_einheit assignAsDriver drugvehicle;
drug_einheit moveindriver drugvehicle;
publicvariable "drug_einheit";
processInitCommands;
_old_random_val = -1;
while {alive drug_einheit && alive drugvehicle} do {
_random_val = ceil random 3;
while {_random_val == _old_random_val} do {
_random_val = ceil random 3;
};
_old_random_val = _random_val;
call compile format ["
drug_einheit doMove markerPos 'drugstop%1';
while {drug_einheit distance markerPos 'drugstop%1' > 20 && alive drug_einheit && alive drugvehicle} do {
sleep 5;
};
", _random_val];
if (!alive drugvehicle || !alive drug_einheit) exitWith {};
sleep 200 + random 5;
};
deleteVehicle drug_einheit;
deleteVehicle drugvehicle;
deleteGroup drggrp;
};
2. Script to check if Drugdealer is alive and gives hint if not anymore:
// Check if Drugvehicle is alive or not and gives a hint if its not alive anymore
if (!isServer) exitWith {};
while {true} do
{
if (!alive drugvehicle || !alive drug_einheit) exitWith {
"hint localize ""STRS_drugdealer_destroyedorbusted"";"
drugvehicle setdamage 1;
drug_einheit setdamage 1;
sleep 5;
deleteVehicle drug_einheit;
deleteVehicle drugvehicle;
};
sleep 2;
};
Please help me with this... its totally overloading for me.