PDA

View Full Version : break ; illegal break statement



malyczolg
1st April 2013, 11:38
who can add delete turret ?
if i add :


self._sentry delete();
self._sentryasd delete();
self._sentryhead delete();

Turret is invisible and kill enemy.

script :

init()
{

precachemodel("xmodel/prop_barrel_black_wet");
precachemodel("xmodel/superweap_worldmodel");
precachemodel("xmodel/military_flak88_tube");






level.effects["large_bark"]=loadfx("fx/impacts/large_woodhit.efx");
level.effects["large_brick"]=loadfx("fx/impacts/large_brick.efx");
level.effects["large_carpet"]=loadfx("fx/impacts/default_hit.efx");
level.effects["large_cloth"]=loadfx("fx/impacts/cloth_hit.efx");
level.effects["large_concrete"]=loadfx("fx/impacts/large_plaster.efx");
level.effects["large_dirt"]=loadfx("fx/impacts/large_dirt.efx");
level.effects["large_flesh"]=loadfx("fx/impacts/flesh_hit.efx");
level.effects["large_foliage"]=loadfx("fx/impacts/small_foliage.efx");
level.effects["large_glass"]=loadfx("fx/impacts/large_glass.efx");
level.effects["large_grass"]=loadfx("fx/impacts/small_grass.efx");
level.effects["large_gravel"]=loadfx("fx/impacts/large_gravel.efx");
level.effects["large_ice"]=loadfx("fx/impacts/small_snowhit.efx");
level.effects["large_metal"]=loadfx("fx/impacts/large_metalhit.efx");
level.effects["large_mud"]=loadfx("fx/impacts/large_mud.efx");
level.effects["large_paper"]=loadfx("fx/impacts/default_hit.efx");
level.effects["large_plaster"]=loadfx("fx/impacts/large_plaster.efx");
level.effects["large_rock"]=loadfx("fx/impacts/large_rock.efx");
level.effects["large_sand"]=loadfx("fx/impacts/large_dirt.efx");
level.effects["large_snow"]=loadfx("fx/impacts/small_snowhit.efx");
level.effects["large_water"]=loadfx("fx/impacts/large_waterhit.efx");
level.effects["large_wood"]=loadfx("fx/impacts/large_woodhit.efx");
level.effects["large_asphalt"]=loadfx("fx/impacts/large_rock.efx");
level.effects["large_default"]=loadfx("fx/impacts/default_hit.efx");
level.effects["small_bark"]=loadfx("fx/impacts/large_woodhit.efx");
level.effects["small_brick"]=loadfx("fx/impacts/small_brick.efx");
level.effects["small_carpet"]=loadfx("fx/impacts/default_hit.efx");
level.effects["small_cloth"]=loadfx("fx/impacts/cloth_hit.efx");
level.effects["small_concrete"]=loadfx("fx/impacts/small_concrete.efx");
level.effects["small_dirt"]=loadfx("fx/impacts/small_dirt.efx");
level.effects["small_flesh"]=loadfx("fx/impacts/flesh_hit.efx");
level.effects["small_foliage"]=loadfx("fx/impacts/small_foliage.efx");
level.effects["small_glass"]=loadfx("fx/impacts/small_glass.efx");
level.effects["small_grass"]=loadfx("fx/impacts/small_grass.efx");
level.effects["small_gravel"]=loadfx("fx/impacts/small_gravel.efx");
level.effects["small_ice"]=loadfx("fx/impacts/small_snowhit.efx");
level.effects["small_metal"]=loadfx("fx/impacts/small_metalhit.efx");
level.effects["small_mud"]=loadfx("fx/impacts/small_mud.efx");
level.effects["small_paper"]=loadfx("fx/impacts/default_hit.efx");
level.effects["small_plaster"]=loadfx("fx/impacts/small_concrete.efx");
level.effects["small_rock"]=loadfx("fx/impacts/small_rock.efx");
level.effects["small_sand"]=loadfx("fx/impacts/small_dirt.efx");
level.effects["small_snow"]=loadfx("fx/impacts/small_snowhit.efx");
level.effects["small_water"]=loadfx("fx/impacts/small_waterhit.efx");
level.effects["small_wood"]=loadfx("fx/impacts/large_woodhit.efx");
level.effects["small_asphalt"]=loadfx("fx/impacts/small_concrete.efx");
level.effects["small_default"]=loadfx("fx/impacts/default_hit.efx");
}

sentrygun()
{

//start = self._sentry.origin;

//players=getentarray("player","classname");
//for(i=0;i<players.size;i++)
//end = player.origin;

self endon("disconnect");

vec=anglestoforward(self getplayerangles());

self._sentry = spawn( "script_model", self.origin );
self._sentry setModel("xmodel/prop_barrel_black_wet");
self._sentry.angles = self.angles;

self._sentryasd=spawn("script_model", self.origin + (0,0,30));
self._sentryasd setModel("xmodel/military_flak88_tube");
target = self.origin;

self._sentryhead=spawn("script_model", self.origin + (0,0,50));
self._sentryhead setModel("xmodel/superweap_worldmodel");
self._sentryhead rotateyaw(5100,40);

self._sentrysound = spawn("script_origin",self._sentry.origin);

self iprintln("^9TUR^9RET ^3~> ^910^7Sec ^9Le^7ft");
wait 1;
self iprintln("^9TUR^9RET ^3~> ^99^7Sec ^9Le^7ft");
wait 1;
self iprintln("^9TUR^9RET ^3~> ^98^7Sec ^9Le^7ft");
wait 1;
self iprintln("^9TUR^9RET ^3~> ^97^7Sec ^9Le^7ft");
wait 1;
self iprintln("^9TUR^9RET ^3~> ^96^7Sec ^9Le^7ft");
wait 1;
self iprintln("^9TUR^9RET ^3~> ^95^7Sec ^9Le^7ft");
wait 1;
self iprintln("^9TUR^9RET ^3~> ^94^7Sec ^9Le^7ft");
wait 1;
self iprintln("^9TUR^9RET ^3~> ^93^7Sec ^9Le^7ft");
wait 1;
self iprintln("^9TUR^9RET ^3~> ^92^7Sec ^9Le^7ft");
wait 1;
self iprintln("^9TUR^9RET ^3~> ^91^7Sec ^9Le^7ft");
wait 1;

self._sentry delete();
self._sentryasd delete();
self._sentryhead delete();

for(;;)
{
players=getentarray("player","classname");
for(i=0;i<players.size;i++)
{
player = players[i];
trace = bulletTrace(self._sentryhead.origin, player.origin + (0,0,50), false, self._sentryhead);

if(isAlive(player) && distance(player.origin,self._sentryhead.origin) > 1 && trace["fraction"] == 1)
{
if ((isDefined(player.spawnprotected) && player.spawnprotected == 0) && (player.pers["team"] != self.pers["team"]))
{
self._sentryhead.angles = vectortoangles(player.origin - self._sentryhead.origin);
player finishPlayerDamage(player, self, 15, 1, "MOD_EXPLOSIVE", "tesla_mp", (0,0,0), (0,0,0), "none",0);
self._sentrysound playSoundAtLocation("turrettesla", target, 0 );
break;
}
}
self._sentryhead rotateyaw(5100,40);
}
wait 0.2;
}
}

PlaySoundAtLocation(sound, location, iTime)
{
org = spawn("script_model", location);
wait 0.05;
org show();
org playSound(sound);
wait iTime;
org delete();
return;
}

Jeplaa
1st April 2013, 12:22
delete() only remove the model, but the loop (for;; ) is active anyway.
Stopping the loop will no longer kill players.

You can use something like:
self.isTurret = true; and then
if(isDefined(self.isTurret))

Earliboy
1st April 2013, 12:42
I don't understand what you were trying to do. I edited your sentrygun() thread a littlebit.


sentrygun()
{
sentryTime = 60; //1 Minute

team = self.pers["team"];

vec = anglestoforward(self getplayerangles());

self._sentry = spawn( "script_model", self.origin );
self._sentry setModel("xmodel/prop_barrel_black_wet");
self._sentry.angles = self.angles;

self._sentryasd=spawn("script_model", self.origin + (0,0,30));
self._sentryasd setModel("xmodel/military_flak88_tube");
target = self.origin;

self._sentryhead=spawn("script_model", self.origin + (0,0,50));
self._sentryhead setModel("xmodel/superweap_worldmodel");
self._sentryhead rotateyaw(5100,40);

self._sentrysound = spawn("script_origin",self._sentry.origin);

wait 1;

for(i = 0; i < sentryTime * 5; i++) //*5 because the loop waits 0.2
{
if(!isDefined(self) || !isAlive(self) || self.pers["team"] != team)
break;

players=getentarray("player","classname");
for(i=0;i<players.size;i++)
{
player = players[i];
trace = bulletTrace(self._sentryhead.origin, player.origin + (0,0,50), false, self._sentryhead);

if(isAlive(player) && distance(player.origin, self._sentryhead.origin) > 1 && trace["fraction"] == 1)
{
if ((isDefined(player.spawnprotected) && !player.spawnprotected) && (player.pers["team"] != self.pers["team"]))
{
self._sentryhead.angles = vectortoangles(player.origin - self._sentryhead.origin);
player finishPlayerDamage(player, self, 15, 1, "MOD_EXPLOSIVE", "tesla_mp", (0,0,0), (0,0,0), "none",0);
self._sentrysound playSoundAtLocation("turrettesla", target, 0 );
break;
}
}
self._sentryhead rotateyaw(5100,40);
}

if(i / 5 == 50) //Iprint player about sentry will delete in 10 seconds
self iprintln("^9TUR^9RET ^3~> ^910^7Sec ^9Le^7ft");

wait 0.2;
}

self._sentry delete();
self._sentryasd delete();
self._sentryhead delete();
}

malyczolg
1st April 2013, 13:10
Earliboy i test your script , not work i wait 1min and turret not destroyed

Earliboy
1st April 2013, 17:21
Did u tested it with developer 1?

malyczolg
1st April 2013, 18:18
no i test with developer 0

kung foo man
1st April 2013, 18:56
Then just start with +set developer 1