Spree with Sound system.

Started by [VM_U]Spectra.PhantoM^, Feb 29, 2016, 09:08 AM

Previous topic - Next topic

[VM_U]Spectra.PhantoM^

function onPlayerDeath( player, reason )
{   
player.Score == 0;
}

function onPlayerKill( player, killer, reason, bodypart )
{
killer.Score++;
if (killer.Score == 5) PlaySound( player.UniqueWorld , 50000 , killer.Pos );
else if (killer.Score == 5) PlaySound( player.UniqueWorld , 50001 , killer.Pos );
else if (killer.Score == 20) PlaySound( player.UniqueWorld , 50002 , killer.Pos );
else if (killer.Score == 30) PlaySound( player.UniqueWorld , 50003 , killer.Pos );
else if (killer.Score == 40) PlaySound( player.UniqueWorld , 50004 , killer.Pos );
else if (killer.Score == 50) PlaySound( player.UniqueWorld , 50005 , killer.Pos );
}
Now for the Sounds.

Create a sounds folder in store and paste these sounds there.
Wanna Talk To Me? Come At Irc #Jugo@LUNet

DizzasTeR

Where'd you get that 'Headshot' from? I had it but it didn't seem to work ingame. Have you tested them?

.

#2
Quote from: Doom_Kill3R on Feb 29, 2016, 09:09 AMWhere'd you get that 'Headshot' from? I had it but it didn't seem to work ingame. Have you tested them?

Obviously.



Quote from: {ultimatejugo} on Feb 29, 2016, 09:08 AMfunction onPlayerDeath( player, reason )
{   
player.Score == 0;
}

function onPlayerKill( player, killer, reason, bodypart )
{
killer.Score++;
if (killer.Score == 5) PlaySound( player.UniqueWorld , 50000 , killer.Pos );
else if (killer.Score == 5) PlaySound( player.UniqueWorld , 50001 , killer.Pos );
else if (killer.Score == 20) PlaySound( player.UniqueWorld , 50002 , killer.Pos );
else if (killer.Score == 30) PlaySound( player.UniqueWorld , 50003 , killer.Pos );
else if (killer.Score == 40) PlaySound( player.UniqueWorld , 50004 , killer.Pos );
else if (killer.Score == 50) PlaySound( player.UniqueWorld , 50005 , killer.Pos );
}
Now for the Sounds.

Create a sounds folder in store and paste these sounds there.



1) This is a good case of using the switch statement.
2) You're testing 2 times for 5 kills. And the second one will never be reached.
3) Playing the "headshot" sound for 5 kills? Does that make any sense to you?
4) I'm not gonna waste time enumerating all the issues.



I can't say to you what I've said last time because it's not appropriate but I can still say that you're useless and you're snippets are useless piece of junk that can be created in less than a minute. And probably done more correctly than you did.
.

[VM_U]Spectra.PhantoM^

My server aint hosted aint i didnt have anyone to kill so its a little bit tested.
Wanna Talk To Me? Come At Irc #Jugo@LUNet

MacTavish

#4
Like this? @S.L.C

function onPlayerKill( killer, player, reason, bodypart )
{
killer.Score++;
if (bodypart == BODYPART_HEAD) PlaySound( player.UniqueWorld , 50001 , killer.Pos );
else
{
switch(killer.Score)
{
case 5: PlaySound( killer.UniqueWorld , 50000 , killer.Pos );
case 20: PlaySound( killer.UniqueWorld , 50002 , killer.Pos );
case 30: PlaySound( killer.UniqueWorld , 50003 , killer.Pos );
case 40: PlaySound( killer.UniqueWorld , 50004 , killer.Pos );
case 50: PlaySound( killer.UniqueWorld , 50005 , killer.Pos );
default: return;
}
}
}

Edited: added else statement after if and code modified

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

.

@Kusanagi You need to return after the first if statement because if that head-shot happens to be 5'th kill then it'll play that spree sound as well. Or at least include the switch statement after else...
.

Anik

#6
function onPlayerKill( player, killer, reason, bodypart )isn't it
Quotefunction onPlayerKill( killer, player, reason, bodypart )

KAKAN

Quote from: [DS]Anik on Feb 29, 2016, 10:53 AMfunction onPlayerKill( player, killer, reason, bodypart )isn't it
Quotefunction onPlayerKill( killer, player, reason, bodypart )
Depends on you. You need to edit your script accordingly.
oh no

ysc3839

Quote from: [DS]Anik on Feb 29, 2016, 10:53 AMfunction onPlayerKill( player, killer, reason, bodypart )isn't it
Quotefunction onPlayerKill( killer, player, reason, bodypart )
See squirrel source code. https://bitbucket.org/stormeus/0.4-squirrel/src/dfdf3960226db784d7e807770ca3b1b46f51b16c/CallbackHandler.cpp?at=master#CallbackHandler.cpp-279
callback.Execute<CPlayer *, CPlayer *, int, int>(killerInstance, playerInstance, nReason, nBodyPart);

[VM_U]Spectra.PhantoM^

@S.L.C  you should've learned by now that i don't give crap bout rude gestures. No Offense btw. But srsly, IDC. And i don't want to start a fight in this topic so i will keep mah mouth shut.
Wanna Talk To Me? Come At Irc #Jugo@LUNet

Striker

Quote from: {ultimatejugo] on Feb 29, 2016, 03:12 PM@S.L.C  you should've learned by now that i don't give crap bout rude gestures. No Offense btw. But srsly, IDC. And i don't want to start a fight in this topic so i will keep mah mouth shut.
Well, we all take S.L.C rude;however, i don't think he is really wrong -_- he just points out our mistakes, by which we become hyperbole, not S.L.C! it's not his fault if mistakes are, so noobish.
P.S: - At least he tells what is the basic mistake.

Murdock

I never knew people could fail so miserably with just a 10-line code

KAKAN

Quote from: {ultimateretard on Feb 29, 2016, 09:08 AMfunction onPlayerDeath( player, reason )
{   
player.Score [b]==[/b] 0;
}
Genius!
oh no

Anik

Update that to
player.Score=0;

Murdock

And aside all the issues SLC mentioned, the spree would only end if a player committed suicide, and isn't the sound supposed to be played for the killer?
Everything that could possibly be wrong writing this 10-lined code is done wrong. This is the worst snippet I have ever seen.

Here's a little less terrible implementation of this snippet, this plays sound 50000 on each 5th kill, 50001 on each 10th kill until it reached the number of total sounds, after that it starts at 50000 again.

total_sounds <- 6;

function onPlayerDeath( player, reason ) { player.Score = 0; }

function onPlayerKill( killer, victim, reason, bodypart )
{
  killer.Score++;
  victim.Score = 0;

  if ( killer.Score > 4 && killer.Score % 5 == 0 )
    PlaySound( killer.UniqueWorld, (50000 + ((killer.Score / 5 + 5) % total_sounds)), killer.Pos );
}