Skip to content
MPGHThe Dark Arts
/
RegisterLog in
Forum
Community
What's NewLatest posts across the boardTrendingHottest threads right nowSubscribedThreads you follow
Discussion
GeneralIntroductionsEntertainmentDebate FortFlaming & Rage
Board
News & AnnouncementsMPGH TimesSuggestions & HelpGiveaways
More Sections
Art & Graphic DesignProgrammingHackingCryptocurrency
Hacks & Cheats
Games
ValorantCS2 / CS:GOCall of Duty / WarzoneFortniteApex LegendsEscape From Tarkov
+14 moreLeague of LegendsGTA VMinecraftRustROTMGBattlefieldTroveBattleOnCombat ArmsCrossFireBlackshotRuneScapeDayZDead by Daylight
Resources
Game Hacking TutorialsReverse EngineeringGeneral Game HackingAnti-CheatConsole Game Hacking
Tools
Game Hacking ToolsTrainers & CheatsHack/Release NewsNew
Submit a release →Share your cheat, tool, or config with the community.
AINEW
AI Tools
General & DiscussionPrompt EngineeringLLM JailbreaksHotAI Agents & AutomationLocal / Open Models
AI × Gaming
AI Aimbots & VisionML Anti-CheatGame Bots & Automation
Create
AI Coding / Vibe CodingAI Art & MediaAI Voice & TTS
The AI frontier →Where game hacking meets modern machine learning. Jump in.
Marketplace
Buy & Sell
SellingBuyingTradingUser Services
Trust & Safety
Middleman LoungeMarketplace TalkVouch Copy Profiles
Money
Cryptocurrency TalkCurrency ExchangeWork & Job Offers
Start selling →List accounts, services, and goods. Use the middleman to trade safe.
MPGH The Dark Arts

A community for offensive security research, reverse engineering, and AI.

Community

ForumMarketplaceSearch

Account

RegisterLog in

Legal

Privacy PolicyForum RulesHelp & FAQ
© 2026 MPGH · All rights reserved.Built by the community, for the community. For educational purposes onlyContent is shared for security research and education — we don't condone illegal use. You're responsible for complying with applicable laws. Use at your own risk.
Home › Forum › Programming › Game Development › Unity / UDK / GameStudio / CryEngine Development › In Game Variable not Workin' ...

QuestionIn Game Variable not Workin' ...

Posts 1–4 of 4 · Page 1 of 1
general656
general656
In Game Variable not Workin' ...
I just want when I push "F" the flashlight to turn on ONLY if I have 5 points . And when I push "O" to gain Points so I can use the flashlight . But if I try the "int points = 0 " to make it "static int points = 0" it doesn't work . It sends me an error "Unexpected Symbol 'static' . In this code I put the 'static' in brackets just to remind you I have used it without and with it in this code .
Code:
using UnityEngine;
using System.Collections;

public class flashing : MonoBehaviour
{
    void Update()
    {
        (static) int points = 0;
        
        if (Input.GetKeyDown(KeyCode.O))
            points++;
            
        if (Input.GetKeyDown(KeyCode.F) && points == 5)
        {
            points = 0;
            light.enabled = !light.enabled;
        }
    }
}
#1 · 13y ago
AT
atom0s
Try defining the points outside of the function then as part of the class. I'm not sure if Unity puts limitations on the code it runs inside its scripts or not.
Also you should check if greater than or equal to 5 for the flash light. Since you don't cap how much points O will generate.

Code:
using UnityEngine;
using System.Collections;

public class flashing : MonoBehaviour
{
    private static int _points;

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.O))
            _points++;
            
        if (Input.GetKeyDown(KeyCode.F) && _points >= 5)
        {
            _points -= 5;
            light.enabled = !light.enabled;
        }
    }
}
#2 · edited 13y ago · 13y ago
general656
general656
Quote Originally Posted by atom0s View Post
Try defining the points outside of the function then as part of the class. I'm not sure if Unity puts limitations on the code it runs inside its scripts or not.
Also you should check if greater than or equal to 5 for the flash light. Since you don't cap how much points O will generate.

Code:
using UnityEngine;
using System.Collections;

public class flashing : MonoBehaviour
{
    private static int _points;

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.O))
            this._points++;
            
        if (Input.GetKeyDown(KeyCode.F) && this._points >= 5)
        {
            this._points -= 5;
            light.enabled = !light.enabled;
        }
    }
}
Nope ... it's not working too ... -_- This unity ... The error :
"CS0176: Static member 'flashing.points' cannot be accessed with an intance reference, qualify it with a type name instead"
Thank you for the supporting dude ... But I want to fint a solution to this issue very much . If I will find a solution I will be able to do more things . I am a nearly beginner and I want to learn more .
#3 · 13y ago
AT
atom0s
Oh blah that was my bad, and what I get for not thinking after just waking up.
Remove the this. keywords from the _points given that it is static.

Updated the code above.
#4 · 13y ago
Posts 1–4 of 4 · Page 1 of 1

Post a Reply

Similar Threads

  • Make It Clear For CA Not Workin!By DurangoSan in Combat Arms Hacks & Cheats
    19Last post 17y ago
  • crossfire hacks gettin not workin QQBy retard223 in CrossFire Hacks & Cheats
    17Last post 17y ago
  • Swear in a game room. [Not Crtl+BackSpace]By Raymondx3 in Combat Arms Glitches
    7Last post 17y ago
  • public hack not workin proplyBy lamont in CrossFire Hacks & Cheats
    0Last post 17y ago
  • injector not workinBy loonylezzy in CrossFire Hacks & Cheats
    12Last post 16y ago

Tags for this Thread

#csharp#help#points#problem#static#unity