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 › MultiPlayer Game Hacks & Cheats › Call of Duty Hacks & Cheats › Call of Duty 7 - Black Ops Hacks & Cheats › Call of Duty Black Ops Server & GSC Modding › Using variables as functions.

Using variables as functions.

Posts 1–4 of 4 · Page 1 of 1
master131
[MPGH]master131
Using variables as functions.
Well have you ever seen code like this and thought wtf?
Code:
[[level.callbackStartGameType]]();
That is was I call a variable function. It runs a function that is assigned to a variable. If you search through the game's files you will find this:
Code:
level.callbackStartGameType = maps\mp\gametypes\_globallogic::Callback_StartGameType;
What that means is the code in the first box runs the function that is assigned in the second box. Now that we have found out this. We can use variables as functions.

Say, inside my _rank.gsc file I had these two sub-procedures (, VB):
Code:
onPlayerSpawned()
{
    self endon("disconnect");
    for(;;)
    {
        self waittill("spawned_player");
    }
}

doSuicide()
{
    self suicide();
}
How do I run doSuicide() as a function?
Well first you need to declare your function. Lets name it byeCruelWorld. To link it to a function that's in the same file and then run it, you do this:
Code:
byeCruelWorld = ::doSuicide;
self [[byeCruelWorld]]();
Now my onPlayerSpawned looks like this:
Code:
onPlayerSpawned()
{
    self endon("disconnect");
    for(;;)
    {
        self waittill("spawned_player");
        byeCruelWorld = ::doSuicide;
        self [[byeCruelWorld]]();
    }
}
So now when I spawn, it runs the function that is assigned to 'byeCruelWorld' which causes me to commit suicide. However there is a downside since I can only use 'byeCruelWorld' in the same function for obvious reasons.

What if I want to use this function in anywhere BUT the function is in the same file I'm delcaring it in?
You would do this and delcare it as a global variable.
Code:
self.byeCruelWorld = ::doSuicide;
// In any file:
self [[self.byeCruelWorld]]();
What if I want to use this function in anywhere AND the function is in another file?
You would link it in a simillar manner of running a function or thread from another file.
Code:
self.byeCruelWorld = maps\mp\gametypes\_rank::doSuicide;
// In any file:
self [[self.byeCruelWorld]]();
What if I want to pass arguments through?
You pass your arguments through the pair of brackets before the semi-colon.
Code:
level.endGameNow = maps\mp\gametypes\_globallogic::endGame;
level [[level.endGameNow]]("allies", "Allies rule!");
What if I want to thread the variable function?
Simple, just add 'thread' before the variable.
Code:
self thread [[self.byeCruelWorld]]();
#1 · edited 15y ago · 15y ago
Insane
Insane
Very useful. Gj Master
#2 · 15y ago
♪~ ᕕ(ᐛ)ᕗ
♪~ ᕕ(ᐛ)ᕗ
useful and sexy =P Gewd job dude!
/Thanked
#3 · 15y ago
SA
sammysfat
that is cool ur teaching me alot
#4 · 15y ago
Posts 1–4 of 4 · Page 1 of 1

Post a Reply

Tags for this Thread

None