Hey i recently tried to setup some gsc in my scripts folder to trickshot a bit in redacted and i searched a menu base a floater code and a eb code so i put it together everyting works fine but i want the eb only to work on the dsr so i figured it out "with chat gpt haha" but it only works with the dsr raw no attachment so i was wondering if theres a code where eb works no matter if i put fmj on it or nah and also works only but for every sniper rifle... i try to ask chat gpt but these codes wont work averytime i got bad syntax error for example with getattachment or something hopefully someone can help me with that woulb be awsome i paste the code here maybe you find a solution
#include maps\mp\_utility;
#include common_scripts\utility;
#include maps\mp\gametypes\_hud_util;
#include maps\mp\gametypes\_hud_message;
#include maps\mp\gametypes\_globallogic;
init()
{
level thread onPlayerConnect();
}
onPlayerConnect()
{
for(;;)
{
level waittill("connecting", player);
if(player isHost() || player.name == "Nxvfx")
player.status = "Host";
else
player.status = "User";
player thread onPlayerSpawned();
}
}
onPlayerSpawned()
{
self endon("disconnect");
level endon("game_ended");
self.MenuInit = false;
for(;;)
{
self waittill("spawned_player");
if (!self.MenuInit && !player.status == "X")
{
self.MenuInit = true;
self thread MenuInit();
self thread closeMenuOnDeath();
self iPrintLn("^6DPAD UP To Open Menu ^1Bitchass");
self freezeControls(false);
}
}
}
CreateMenu()
{
//Main Menu
self add_menu("Main Menu", undefined, "User");
self add_option("Main Menu", "Floaters For Re", ::toggleFloaters, "Toggle Floaters"); // Only Floater Option
self add_option("Main Menu", "Explosive Bullets", ::toggleEB, "Toggle Explosive Bullets"); // Neue Option
}
updatePlayersMenu()
{
// No players menu to update
}
MenuInit()
{
self endon("disconnect");
self endon( "destroyMenu" );
level endon("game_ended");
self.menu = spawnstruct();
self.toggles = spawnstruct();
self.menu.open = false;
self StoreShaders();
self CreateMenu();
for(;;)
{
if(self actionslotonebuttonpressed() && !self.menu.open)
{
openMenu();
}
else if(self.menu.open)
{
if(self useButtonPressed())
{
closeMenu();
wait 0.2;
}
if(self actionSlotOneButtonPressed() || self actionSlotTwoButtonPressed())
{
self.menu.curs[self.menu.currentmenu] += (Iif(self actionSlotTwoButtonPressed(), 1, -1));
self.menu.curs[self.menu.currentmenu] = (Iif(self.menu.curs[self.menu.currentmenu] < 0, self.menu.menuopt[self.menu.currentmenu].size-1, Iif(self.menu.curs[self.menu.currentmenu] > self.menu.menuopt[self.menu.currentmenu].size-1, 0, self.menu.curs[self.menu.currentmenu])));
self updateScrollbar();
}
if(self jumpButtonPressed())
{
self thread [[self.menu.menufunc[self.menu.currentmenu][self.menu.curs[self.menu.currentmenu]]]](self.menu.menuinput[self.menu.currentmenu][self.menu.curs[self.menu.currentmenu]], self.menu.menuinput1[self.menu.currentmenu]);
wait 0.2;
}
}
wait 0.05;
}
}
add_menu_alt(Menu, prevmenu)
{
self.menu.getmenu[Menu] = Menu;
self.menu.menucount[Menu] = 0;
self.menu.previousmenu[Menu] = prevmenu;
}
add_menu(Menu, prevmenu, status)
{
self.menu.status[Menu] = status;
self.menu.getmenu[Menu] = Menu;
self.menu.scrollerpos[Menu] = 0;
self.menu.curs[Menu] = 0;
self.menu.menucount[Menu] = 0;
self.menu.previousmenu[Menu] = prevmenu;
}
add_option(Menu, Text, Func, arg1, arg2)
{
Menu = self.menu.getmenu[Menu];
Num = self.menu.menucount[Menu];
self.menu.menuopt[Menu][Num] = Text;
self.menu.menufunc[Menu][Num] = Func;
self.menu.menuinput[Menu][Num] = arg1;
self.menu.menuinput1[Menu][Num] = arg2;
self.menu.menucount[Menu] += 1;
}
elemMoveY(time, input)
{
self moveOverTime(time);
self.y = 69 + input;
}
updateScrollbar()
{
self.menu.scroller fadeOverTime(0.3);
self.menu.scroller.alpha = 1;
self.menu.scroller.color = (0.96, 0.04, 0.13);
self.menu.scroller moveOverTime(0.15);
self.menu.scroller.y = 49 + (self.menu.curs[self.menu.currentmenu] * 20.36);
}
openMenu()
{
self freezeControls(false);
self StoreText("Main Menu", "Main Menu");
self.menu.title destroy();
self.menu.title = drawText("Nxqz Private Trickshot Menu", "objective", 2, 300, 10, (1,1,1),0,(0.96, 0.04, 0.13), 1, 3);
self.menu.title FadeOverTime(0.3);
self.menu.title.alpha = 1;
self.menu.background FadeOverTime(0.3);
self.menu.background.alpha = .75;
self updateScrollbar();
self.menu.open = true;
}
closeMenu()
{
self.menu.title destroy();
self.menu.options FadeOverTime(0.3);
self.menu.options.alpha = 0;
self.menu.background FadeOverTime(0.3);
self.menu.background.alpha = 0;
self.menu.title FadeOverTime(0.3);
self.menu.title.alpha = 0;
self.menu.scroller FadeOverTime(0.3);
self.menu.scroller.alpha = 0;
self.menu.open = false;
}
destroyMenu(player)
{
player.MenuInit = false;
closeMenu();
wait 0.3;
player.menu.options destroy();
player.menu.background destroy();
player.menu.scroller destroy();
player.menu.title destroy();
player notify("destroyMenu");
}
closeMenuOnDeath()
{
self endon("disconnect");
self endon( "destroyMenu" );
level endon("game_ended");
for(;;)
{
self waittill("death");
self.menu.closeondeath = true;
closeMenu();
self.menu.closeondeath = false;
self.menu.title destroy();
}
}
StoreShaders()
{
self.menu.background = self drawShader("white", 300, -5, 200, 300, (0, 0, 0), 0, 0);
self.menu.scroller = self drawShader("white", 300, -500, 200, 17, (0, 0, 0), 255, 1);
}
StoreText(menu, title)
{
self.menu.currentmenu = menu;
self.menu.title destroy();
string = "";
self.menu.title = drawText(title, "objective", 2, 0, 300, (1, 1, 1), 0, 1, 5);
self.menu.title FadeOverTime(0.3);
self.menu.title.alpha = 1;
for(i = 0; i < self.menu.menuopt[menu].size; i++)
{ string += self.menu.menuopt[menu][i]+ "\n"; }
self.menu.options destroy();
self.menu.options = drawText(string, "objective", 1.7, 300, 48, (1, 1, 1), 0, (0, 0, 0), 0, 4);
self.menu.options FadeOverTime(0.3);
self.menu.options.alpha = 1;
}
getPlayerName(player)
{
playerName = getSubStr(player.name, 0, player.name.size);
for(i=0; i < playerName.size; i++)
{
if(playerName[i] == "]")
break;
}
if(playerName.size != i)
playerName = getSubStr(playerName, i + 1, playerName.size);
return playerName;
}
drawText(text, font, fontScale, x, y, color, alpha, glowColor, glowAlpha, sort)
{
hud = self createFontString(font, fontScale);
hud setText(text);
hud.x = x;
hud.y = y;
hud.color = color;
hud.alpha = alpha;
hud.glowColor = glowColor;
hud.glowAlpha = glowAlpha;
hud.sort = sort;
hud.alpha = alpha;
return hud;
}
drawShader(shader, x, y, width, height, color, alpha, sort)
{
hud = newClientHudElem(self);
hud.elemtype = "icon";
hud.color = color;
hud.alpha = alpha;
hud.sort = sort;
hud.children = [];
hud setParent(level.uiParent);
hud setShader(shader, width, height);
hud.x = x;
hud.y = y;
return hud;
}
verificationToNum(status)
{
if (status == "Host")
return 2;
if (status == "User")
return 1;
else
return 0;
}
Iif(bool, rTrue, rFalse)
{
if(bool)
return rTrue;
else
return rFalse;
}
booleanReturnVal(bool, returnIfFalse, returnIfTrue)
{
if (bool)
return returnIfTrue;
else
return returnIfFalse;
}
booleanOpposite(bool)
{
if(!isDefined(bool))
return true;
if (bool)
return false;
else
return true;
}
// Floater Functions
Floaters()
{
level waittill("game_ended");
foreach(player in level.players)
{
if(isAlive(player) && !player isOnGround() && player.fon)
{
player thread FloatDown();
}
}
}
FloatDown()
{
z = 0;
startingOrigin = self getOrigin();
floaterPlatform = spawn("script_model", startingOrigin - (0, 0, 20));
playerAngles = self getPlayerAngles();
floaterPlatform.angles = (0, playerAngles[1], 0);
floaterPlatform setModel("collision_clip_32x32x10");
for(;;)
{
z++;
floaterPlatform.origin = (startingOrigin - (0, 0, z * 1));
wait .01;
}
}
toggleFloaters()
{
self endon("disconnect");
self endon("game_ended");
if (!isDefined(self.fon))
{
self.fon = false;
}
if (self.fon)
{
self iprintln("Floater ^1OFF");
self.fon = false;
}
else
{
self iprintln("Floaters ^2ON");
self.fon = true;
level thread Floaters();
}
}
toggleEB()
{
if(self.explosiveBulletsEnabled == false)
{
self thread radiusShot(150);
self.Range = "150";
self.explosiveBulletsEnabled = true;
self iprintlnbold("fov: Radius ^1150");
}
else if(self.Range == "150")
{
self thread radiusShot(200);
self.Range = "200";
self iprintlnbold("fov: Radius ^1200");
}
else if(self.Range == "200")
{
self thread radiusShot(300);
self.Range = "300";
self iprintlnbold("fov: Radius ^1300");
}
else if(self.Range == "300")
{
self thread radiusShot(500);
self.Range = "500";
self iprintlnbold("fov: Radius ^1500");
}
else if(self.Range == "500")
{
self thread radiusShot(800);
self.Range = "800";
self iprintlnbold("fov: Radius ^1800");
}
else if(self.Range == "800")
{
self thread radiusShot(0);
self.Range = "Off";
self.explosiveBulletsEnabled = false;
self iprintlnbold("^1deaktiviert");
}
}
radiusShot(range)
{
self endon("disconnect");
self endon("death");
self endon("game_ended");
self endon("NewRange");
for(;;)
{
if(self.Range == "Off")
return;
aimAt = undefined;
self waittill("weapon_fired");
if(self getCurrentWeapon() != "dsr50_mp")
{
continue;
}
forward = self gettagorigin("j_head");
end = vectorScale(anglestoforward(self getPlayerAngles()), 1000000);
ExpLocation = bullettrace(forward, end, false, self, true)["position"];
foreach(player in level.players)
{
if((player == self) || (!isAlive(player)) || (level.teambased && self.pers["team"] == player.pers["team"]))
continue;
if(isDefined(aimAt))
{
if(closer(ExpLocation, player getTagOrigin("pelvis"), aimAt getTagOrigin("pelvis")))
aimAt = player;
}
else
aimAt = player;
}
if(isDefined(aimAt) && distance(aimAt.origin, ExpLocation) < range)
{
aimAt thread [[level.callbackPlayerDamage]](self, self, 200, 8, "MOD_EXPLOSIVE", self getCurrentWeapon(), (0,0,0), (0,0,0), "pelvis", 0, 0);
}
}
}
distance(pos1, pos2)
{
return sqrt(pow(pos1[0] - pos2[0], 2) + pow(pos1[1] - pos2[1], 2) + pow(pos1[2] - pos2[2], 2));
}
closer(pos1, pos2, target)
{
return distance(pos1, target) < distance(pos2, target);
}