Jump to content
Sign in to follow this  
shibdib

Why doesn't this script work?

Recommended Posts

The following is my init with the script in question bolded.

call compileFinal preprocessFileLineNumbers "FAR_revive\FAR_revive_init.sqf";
null = [2] execvm "tpwcas\tpwcas_script_init.sqf"

[b]execvm "spcheck.sqf";[/b]

That script is

{
if(!isDedicated and !isMultiplayer) then {
deleteVehicle _p2;
hint "Singleplayer Mode Activated";
}

But at some point it doesn't work. No errors show up in the log for it

Edited by shibdib

Share this post


Link to post
Share on other sites

[color="#FF0000"][b]{[/b][/color]
if(!isDedicated and !isMultiplayer) then {
deleteVehicle _p2;
hint "Singleplayer Mode Activated";
}

This one (in red) is too much.

This is how it should look like:

if (!isMultiplayer) then {
deleteVehicle _p2;
hint "Singleplayer Mode Activated";
};

Share this post


Link to post
Share on other sites

Doing that got it to show up in the error log so that's progress..

Now the error is

Error in expression <rike.Altis\spcheck.sqf"
if(!isDedicated _and !isMultiplayer) then {
deleteVehicl>
 Error position: <_and !isMultiplayer) then {
deleteVehicl>
 Error Missing )

So I put a ) next to !isDedicated

Get another error telling me to put a ; after the )

At this point doesn't that ruin the "and" statement? But once I have (!isDedicated); I get error

Error in expression <ke.Altis\spcheck.sqf"
if(!isDedicated); _and !isMultiplayer);
then {
deleteVehic>
 Error position: <_and !isMultiplayer);
then {
deleteVehic>
 [b]Error Undefined variable in expression: _and[/b]

Now I'm completely confused..........

BUT I GOT IT WORKING!!!

SO I tried something a bit different and went with

if (!isDedicated && !isMultiplayer) then {
deleteVehicle p2;
hint "Singleplayer Mode Activated";
}

Which works :D

Edited by shibdib

Share this post


Link to post
Share on other sites

You're taking these error messages a bit too literally. :)

The correct syntax would be:

if (!isDedicated and !isMultiplayer) then {
deleteVehicle _p2;
hint "Singleplayer Mode Activated";
};

or:

if (!isDedicated && !isMultiplayer) then {
deleteVehicle _p2;
hint "Singleplayer Mode Activated";
};

Both the same.

However !isDedicated is not needed here, for it can never be true if isMultiplayer is false.

Use what I posted above. :)

Share this post


Link to post
Share on other sites

I had to remove the _ infront of p2 to get it to work, musta editted while you were posting, it gave me undefined variable errors if it was there.

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  

×