Jump to content
Sign in to follow this  
tobmic

Problem with a Script

Recommended Posts

Bon helped me to make a script to lock sniper rifles for non Sniper classes

I added this script into TVT domi.

The script works fine but on the server when you disconnect or reconnect the script doesnt run anymore

This i added to init.sqf:

execVM "x_scripts\x_checkweapon.sqf";

and this is the script

if (!isServer) exitWith {};

#include "x_setup.sqf"

While{true} do

{

WaitUntil{player hasWeapon "Huntingrifle" || player hasWeapon "MetisLauncher" || player hasweapon "AKS_74_pso" || player hasWeapon "DMR" || player hasWeapon "KSVK" || player hasWeapon "M107" || player hasWeapon "M24" || player hasWeapon "M40A3" || player hasweapon "VSS_vintorez" || player hasWeapon "SVD" || player hasWeapon "SVD_CAMO"};

if(typeOf player != "CDF_Soldier_RPG" && typeOf player != "Ins_Soldier_AT") then

{

player removeWeapon "MetisLauncher";

};

if(typeOf player != "CDF_Soldier_Sniper" && typeOf player != "Ins_Soldier_Sniper") then

{

player removeWeapon "KSVK";

player removeWeapon "M107";

player removeWeapon "M40A3";

player removeWeapon "SVD";

player removeWeapon "SVD_CAMO";

player removeWeapon "VSS_vintorez";

};

if(typeOf player != "CDF_Soldier_Officer" && typeOf player != "Ins_Soldier_CO") then

{

player removeWeapon "AKS_74_pso";

};

if(typeOf player != "Ins_Bardak" && typeOf player != "CDF_Soldier_Spotter") then

{

player removeWeapon "Huntingrifle";

player removeWeapon "M24";

};

};

if(true) exitWith{};

What have i done wrong ?

Share this post


Link to post
Share on other sites

place your exitWith-command inside the while-loop... but really, get rid of such constructs like while(true) or if(true) exitWith etc... that's just nonsense. You wanna execute that code once (everytime the script is called) and not multiple times..

I suggest to learn the basics first, because copy-and-paste scripting won't get you far.

Share this post


Link to post
Share on other sites

better to run the script from init.sqf for players, not for the server.

use a For loop and add a sleep command to make it pause before looping round again.

make sure x_setup runs int he right place if you make this change.

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  

×