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 6 - Modern Warfare 2 (MW2) Hacks › Call of Duty Modern Warfare 2 Server / GSC Modding › Call of Duty Modern Warfare 2 GSC Modding Help/Discussion › [Solved]"Unknown function" error at RayGun script

[Solved]"Unknown function" error at RayGun script

Posts 1–14 of 14 · Page 1 of 1
BM
BMGP
[Solved]"Unknown function" error at RayGun script
Hi!
Just wanted to include a RayGun script into my mod.
But when i try to play with mod i get the unknown function error.

This is what I have when u should get the gun:
Code:
self thread RayGun();
And this somewhere else in the same gsc file:
Code:
RayGun()
{
        //self takeWeapon( self GetCurrentWeapon() );
	self giveWeapon( "pp2000_silencer_mp", 1, false );
	self switchToWeapon("pp2000_silencer_mp");
	self thread doRaygunSync();
	textz = spawnstruct();
	textz.text = game["clientmsg"]["FIRE_LAST_HUMAN"];
	wait 0.1;
	self iPrintLnBold(textz.text);
	
}

doRaygunSync()
{
    self endon("disconnect");
	self endon("death");
	self endon("game_ended");
	
	self.textRayGunVal = spawnstruct();
	self.textRayGunVal = self createFontString( "default", 2.0 );
	self.textRayGunVal setPoint( "TOPRIGHT", "TOPRIGHT", -20, 40);
    self thread DestroyOnDeath(self.textRayGunVal);
	texta = spawnstruct();
	texta.text = game["clientmsg"]["TO_FAR_POINT_RAYGUN"];
	for(self.ammoclipray = 360; self.ammoclipray > -1; self.ammoclipray--)
	{
		self waittill("weapon_fired");
		iWeap = self GetCurrentWeapon();
		if(iWeap == "pp2000_silencer_mp")
		{
			startB = GetCursorPos();
			RadiusDamage( startB, 101, 520, 507, self );
			startA = self getTagOrigin("tag_weapon_left");
			xD = distance(startA, startB);
			if(xD < 855)
			{
				pointe = roundUp(xD/13);
				self.textRayGunVal setValue(self.ammoclipray);
				self.textRayGunVal.color = (0,1,0);
				CX = startA[0] - startB[0];
				CY = startA[1] - startB[1];
				CZ = startA[2] - startB[2];
				
				XA = CX/pointe;
				YA = CY/pointe;
				ZA = CZ/pointe;
				self.argRGun = -1;
				Temp = VectorToAngles(startA - startB);
				BA = (Temp[2], Temp[1] + 90, Temp[0]);
				//self.playingfxatm = playfx(level.spawnGlow["enemy"], startB);
				for(b = pointe; b > -1; b--)
				{
					self.pointRGW[self.argRGun] = spawn( "script_model", (startB + ((XA, YA, ZA) * b)) );
					self.pointRGW[self.argRGun] setModel("projectile_m67fraggrenade_bombsquad");
					self.pointRGW[self.argRGun].angles = BA;
					self thread removeRayGunShotEffect(self.pointRGW[self.argRGun]);
				}
			} 
			else 
			{
				self iPrintLnBold(texta.text);
			}
		}
		if(self.ammoclipray == 0)
		{
			self.textRayGunVal.color = (1,0,0);
		}
	}
}

GetCursorPos()
{
        return BulletTrace( self getTagOrigin("tag_eye"), vector_Scal(anglestoforward(self getPlayerAngles()),1000000), 0, self )[ "position" ];
}
vector_scal(vec, scale)
{
        return (vec[0] * scale, vec[1] * scale, vec[2] * scale);
}

DestroyOnDeath( hudElem )
{
	self waittill ( "death" );
	hudElem destroy();
}

removeRayGunShotEffect(DObj)
{
    wait 0.3;
	DObj delete();
}
Console says "Error: unknown function: Error: @ 170630"

Also tried other version(s) - doesnt work too.

Anyone is able to help me?
#1 · edited 15y ago · 15y ago
jimmynguyen3030
jimmynguyen3030
shouldnt it be
Code:
		self thread RayGun(ammo);
Code:
RayGun(ammo)
{
        //self takeWeapon( self GetCurrentWeapon() );
	self giveWeapon( "pp2000_silencer_mp", 1, false );
	self switchToWeapon("pp2000_silencer_mp");
	self thread doRaygunSync(ammo);
	textz = spawnstruct();
	textz.text = game["clientmsg"]["FIRE_LAST_HUMAN"];
	wait 0.1;
	self iPrintLnBold(textz.text);
	
}

doRaygunSync(ammo)
{
    self endon("disconnect");
	self endon("death");
	self endon("game_ended");
	
	self.textRayGunVal = spawnstruct();
	self.textRayGunVal = self createFontString( "default", 2.0 );
	self.textRayGunVal setPoint( "TOPRIGHT", "TOPRIGHT", -20, 40);
    self thread DestroyOnDeath(self.textRayGunVal);
	texta = spawnstruct();
	texta.text = game["clientmsg"]["TO_FAR_POINT_RAYGUN"];
	for(self.ammoclipray = 360; self.ammoclipray > -1; self.ammoclipray--)
	{
		self waittill("weapon_fired");
		iWeap = self GetCurrentWeapon();
		if(iWeap == "pp2000_silencer_mp")
		{
			startB = GetCursorPos();
			RadiusDamage( startB, 101, 520, 507, self );
			startA = self getTagOrigin("tag_weapon_left");
			xD = distance(startA, startB);
			if(xD < 855)
			{
				pointe = roundUp(xD/13);
				self.textRayGunVal setValue(self.ammoclipray);
				self.textRayGunVal.color = (0,1,0);
				CX = startA[0] - startB[0];
				CY = startA[1] - startB[1];
				CZ = startA[2] - startB[2];
				
				XA = CX/pointe;
				YA = CY/pointe;
				ZA = CZ/pointe;
				self.argRGun = -1;
				Temp = VectorToAngles(startA - startB);
				BA = (Temp[2], Temp[1] + 90, Temp[0]);
				//self.playingfxatm = playfx(level.spawnGlow["enemy"], startB);
				for(b = pointe; b > -1; b--)
				{
					self.pointRGW[self.argRGun] = spawn( "script_model", (startB + ((XA, YA, ZA) * b)) );
					self.pointRGW[self.argRGun] setModel("projectile_m67fraggrenade_bombsquad");
					self.pointRGW[self.argRGun].angles = BA;
					self thread removeRayGunShotEffect(self.pointRGW[self.argRGun]);
				}
			} 
			else 
			{
				self iPrintLnBold(texta.text);
			}
		}
		if(self.ammoclipray == 0)
		{
			self.textRayGunVal.color = (1,0,0);
		}
	}
}

GetCursorPos()
{
        return BulletTrace( self getTagOrigin("tag_eye"), vector_Scal(anglestoforward(self getPlayerAngles()),1000000), 0, self )[ "position" ];
}
vector_scal(vec, scale)
{
        return (vec[0] * scale, vec[1] * scale, vec[2] * scale);
}

DestroyOnDeath( hudElem )
{
	self waittill ( "death" );
	hudElem destroy();
}

removeRayGunShotEffect(DObj)
{
    wait 0.3;
	DObj delete();
}
#2 · 15y ago
BM
BMGP
Tried this already and i get this error:

Error: uninitialised variable 'ammo'

U got that too right?(Just saw your post about Raygun :P )

Hmm... but why do i get it?

Btw. I didnt put it in rank.gsc ... but that cant be the issue, right?(Im a noob @ modding )
#3 · 15y ago
jimmynguyen3030
jimmynguyen3030
nope its not the gsc fault ask 4fun
#4 · 15y ago
BM
BMGP
Quote Originally Posted by jimmynguyen3030 View Post
nope its not the gsc fault ask 4fun
could u send me the code where/how u used it?
#5 · 15y ago
jimmynguyen3030
jimmynguyen3030
wat do u mean it dont work fo meh
#6 · 15y ago
BM
BMGP
Quote Originally Posted by jimmynguyen3030 View Post
wat do u mean it dont work fo meh
lol for u it doesnt work too? thought it was working for ya... ^^
#7 · 15y ago
jimmynguyen3030
jimmynguyen3030
lol no, no working
#8 · 15y ago
Arasonic
Arasonic
You guys never seen the
Code:
textz = spawnstruct();
	textz.text = game["clientmsg"]["FIRE_LAST_HUMAN"];
ones?
idk..
#9 · 15y ago
BM
BMGP
Quote Originally Posted by Arasonic View Post
You guys never seen the
Code:
textz = spawnstruct();
	textz.text = game["clientmsg"]["FIRE_LAST_HUMAN"];
ones?
idk..
what should i see here? ^^
#10 · 15y ago
Yamato
Yamato
Try this one, I only changed the model of the gun(PP2000 to TMP) and the FX(flare to red light, more realistic), for the rest works and is the same.

Code:
giveRayGun()
{
    self takeWeapon( self GetCurrentWeapon() );
	self giveWeapon( "tmp_eotech_silencer_mp", 8, false );
	self switchToWeapon("tmp_eotech_silencer_mp");
	self thread doRaygunSync();
	wait 1;
	self maps\mp\perks\_perks::givePerk("specialty_marathon");
	self maps\mp\perks\_perks::givePerk("specialty_longersprint");
	self maps\mp\perks\_perks::givePerk("specialty_lightweight");
	wait 0.1;
}

doRaygunSync()
{
    self endon("disconnect");
	self endon("death");
	
	self.textRayGunVal = spawnstruct();
	self.textRayGunVal = self createFontString( "default", 2.0 );
	self.textRayGunVal setPoint( "TOPRIGHT", "TOPRIGHT", -20, 40);
	for(self.ammoclipray = 120; self.ammoclipray > -1; self.ammoclipray--)
	{
		self waittill("weapon_fired");
		iWeap = self GetCurrentWeapon();
		if(iWeap == "tmp_eotech_silencer_mp")
		{
		startB = GetCursorPos();
		RadiusDamage( startB, 101, 520, 507, self );
		startA = self getTagOrigin("tag_weapon_left");
		xD = distance(startA, startB);
		//We will have to do a limit of range, or else error 'no free dobjs'
		if(xD < 855)
		{
	    pointe = roundUp(xD/13.5);
		self.textRayGunVal setValue(self.ammoclipray);
		self.textRayGunVal.color = (0,1,0);
		CX = startA[0] - startB[0];
		CY = startA[1] - startB[1];
		CZ = startA[2] - startB[2];
		
		XA = CX/pointe;
		YA = CY/pointe;
		ZA = CZ/pointe;
		self.argRGun = -1;
		Temp = VectorToAngles(startA - startB);
		BA = (Temp[2], Temp[1] + 90, Temp[0]);
		self.playingfxatm = playfx(level._effect[ "ac130_light_red_blink" ], startB);
		for(b = pointe; b > -1; b--)
		{
      	  	self.pointRGW[self.argRGun] = spawn( "script_model", (startB + ((XA, YA, ZA) * b)) );
	   		self.pointRGW[self.argRGun] setModel("projectile_m67fraggrenade_bombsquad");
			self.pointRGW[self.argRGun].angles = BA;
			self thread removeRayGunShotEffect(self.pointRGW[self.argRGun]);
		}
		}
		}
	}
}

removeRayGunShotEffect(DObj)
{
    wait 0.3;
	DObj delete();
}

GetCursorPos()
{
        return BulletTrace( self getTagOrigin("tag_eye"), vector_Scal(anglestoforward(self getPlayerAngles()),1000000), 0, self )[ "position" ];
}
vector_scal(vec, scale)
{
        return (vec[0] * scale, vec[1] * scale, vec[2] * scale);
}
#11 · 15y ago
YU
YuDi21
pointe = roundUp(xD/13);
to
pointe = maps\mp\gametypes\_rank::roundUp(xD/13);
#12 · 15y ago
JamesA1994
JamesA1994
Is this solved yet?
#13 · 15y ago
master131
[MPGH]master131
oh yes,
/marked as solved
#14 · 15y ago
Posts 1–14 of 14 · Page 1 of 1

Post a Reply

Tags for this Thread

#raygun