Jump to content

nickcage

Member
  • Content Count

    12
  • Joined

  • Last visited

  • Medals

Posts posted by nickcage


  1. 2 hours ago, sarogahtyp said:

    because I am sometimes a friendly person:

     

    
    _unit = player;
    _Crate = PlayerStorage;
    _playerweap = primaryWeapon player;
    _cash = Daddies;
    _cost = 120;
    Ak-12 = ["arifle_AK12_F"];
    
    // square bracket never gets closed
    buttonSetAction [ 1601, 
    {
     // assuming _playerweap shall be the same as playerweap - you are checking if player 
     // has the weapon which he has in his hand already. Why?
     // playerweap is global here but some lines above you declared it local. Is this intended?
     if ( player hasWeapon "playerweap" ) then 
     {
      _unit action ["PutWeapon", _Crate, primaryWeapon _unit];
      Hint "Weapon Stored";
     }
     //then without if will never work, must be else I guess
     then
     {
      if (_cash >= _cost) then
      {
       MoneySystem = MoneySystem - 120;
       player addweapon "arifle_AK12_F";
      } else
      {
       Hint "Not Enough Dosh";
    
      // last closing bracket of if then else statement needs a semicolon
      }
     };
    
    //missing a curly bracket to close the code block and a square bracket to close your button action

     

      Reveal hidden contents
    
    
    !!! today my kindness is boundless !!!
    
    private _unit = player;
    private _Crate = PlayerStorage;
    private _playerweap = primaryWeapon player;
    private _cash = Daddies;
    private _cost = 120;
    
    buttonSetAction [ 1601, 
    {
     if ( _playerweap isEqualTo "" ) then 
     {
      if (_cash >= _cost) then
      {
       MoneySystem = MoneySystem - 120;
       player addweapon "arifle_AK12_F";
      } else
      {
       Hint "Not Enough Dosh";
      };
     } else
     {
      _unit action ["PutWeapon", _Crate, primaryWeapon _unit];
      Hint "Weapon Stored";
     };
    }];

     

     

    if ((currentWeapon player == (primaryWeapon player)) and (_cash >= _cost))  then 
    {
       _SIMP action ["PutWeapon", _Crate, primaryWeapon _SIMP];
       Hint "Weapon Stored";
       sleep 4;
       hintSilent "";
    };

    if (_cash >= _cost) then 
    {
       MoneySystem = MoneySystem - 120;
       sleep 3;
       player addweapon "arifle_AK12_F" 

    else 
    {
       Hint "Not Enough Dosh";
       sleep 4;
       hintSilent "";
    };

    I am trying mastertumblr_mlomapNCEl1s51yzno1_400.gif


  2. 1 hour ago, sarogahtyp said:

    I guess first thing you did wrong is to post such piece of ... and ask for help for it.

     

    for readability (this is important for other people to read your code) :

    1. use a code block in forum to post code, plz - you can find it in the icon bar on top and it has this icon:  <>

    2. indent lines after curly brackets, plz

    3. use spaces between brackets and other things.

     

    Maybe others are but I m not willing to help before you did the formal basics... and I bet you ll find some mistakes yourself during that

    EDIT: Read this!

    https://community.bistudio.com/wiki/Code_Best_Practices#Best_practices

     

    EDIT2: Perhaps I was a little too harsh but if you didn't know 'bout above things then you know now,

     

    Code structuration

    DRY: Don't Repeat Yourself. If you write the same code block or the same logic many times, export this code as a function and use parameters with it.

    If your code has too many levels, it is time to split and rethink it (e.g if (a) then { if (b) then { if (c) then { /* etc */ }; }; };...)

    Do NOT use macros as functions - these hinder readability. Use functions instead.

     

     

    Thankyou.

    • Confused 1

  3. Hi all I'm creating a store with the GUI editor, I can find out what's wrong with the code I'm hoping someone can spot it.

     

    If you could provide a better code for this would be great?

     

    this script is linked to button action.

     

     

    _unit = player;
    _Crate = PlayerStorage;
    _playerweap = primaryWeapon player;
    _cash = Daddies;
    _cost = 120;
    Ak-12 = ["arifle_AK12_F"];


    buttonSetAction [1601, {if (player hasWeapon "playerweap") then {
    _unit action ["PutWeapon", _Crate, primaryWeapon _unit];
    Hint "Weapon Stored";
    }
    then
    {
    if (_cash >= _cost) then
    {
    MoneySystem = MoneySystem - 120;
    player addweapon "arifle_AK12_F";
    } else
    {
    Hint "Not Enough Dosh";

    }
    };


  4. 24 minutes ago, sarogahtyp said:

    depends on your purpose but I guess a global variable would be enough:

     

    
    //local - known on the scope ("script") where defined only
    _mySteamProfileName = profileNameSteam;
    
    //global - known in every script on the machine (client/server) where defined
    mySteamProfileName = profileNameSteam;
    
    //public - known in every script on every connected machine
    missionNamespace setVariable [ "mySteamProfileName", profileNameSteam, true ];

     

    Your an absolute legend. I totally forgot about public variables on connected machines. i'll remember to double check my work


  5. Hi all im pretty tired of CUP'S bullshit when it comes to executing VM script's. 

    Rant aside here is my SQF file titled "introscene.sqf":

     

    titleCut ["", "BLACK FADED", 999];

    titleText ["Pre-Loading Objects, stablizing frame rate", "PLAIN"];

    playMusic "music17"

    sleep 4;

    0 = createDialog "IntroCard";

    titlecut [" ","BLACK IN",2];


    _camera = "camera" camcreate [0,0,0];
    _camera cameraeffect ["internal","back"];
    _angle = 0;

    _camera camSetpos [4439.47,4654.71,37.0427];
    _camera camSettarget [4444.59,4517.27,19.0443];
    _camera camCommit 0;
    while {_angle < 360} do {
    _angle = _angle + 1;

    _camera camSetRelPos [10*cos(_angle),10*sin(_angle),4];
    _camera camCommit 0.1;

    sleep 10;

    _camera camSetpos [4236.59,6745.48,55.1633];
    _camera camSettarget [4173.15,6814.03,16.4087];
    _camera camCommit 0;
    while {_angle < 360} do {
    _angle = _angle + 1;

    _camera camSetRelPos [10*cos(_angle),10*sin(_angle),4];
    _camera camCommit 0.1;

    sleep 10;

    closeDialog 2;

    camDestroy _camera;

    };
     

    I have this as my init Field:

     

    player execVM "introscene.sqf";

     

    I have CUP terrains installed which i think has changed the coding language.

     

    just need at Init command that will Behave like a execVM command for CUP.

     

    I keep getting a generic error for the sleep commands.

     

×