Making scripts HELP!

i made this thing for deathrun gamemode

If only one runner survived(and still Death player alives), Play music But it seems to be not worked…

[lua]
resource.AddFile(“sound/deathrun/oneandonly.mp3”)

function checkAlive(ply)
if ply:Alive() then //Returns Boolean
if #team.GetPlayers( TEAM_RUN ) = 1 then
ply:ChatPrint(‘You are “Still Alive”’) //If true (You are Alive)
only:EmitSound( “deathrun/oneandonly.mp3”, 150, 100 );
else
//If not (You are Dead)
ply:ChatPrint(“The Cake was a lie? Now do you believe me?”)
end //End If statement
end //End Function

[/lua]

HELP!

anyone?

Two main mistakes here, firstly you need to use ‘==’ instead of ‘=’. And secondly, you missed an end out.

[lua]
resource.AddFile(“sound/deathrun/oneandonly.mp3”)

function checkAlive(ply)
if ply:Alive() then
if #team.GetPlayers( TEAM_RUN ) == 1 then
ply:ChatPrint(‘You are “Still Alive”’) //If true (You are Alive)
only:EmitSound( “deathrun/oneandonly.mp3”, 150, 100 );
end
else
//If not (You are Dead)
ply:ChatPrint(“The Cake was a lie? Now do you believe me?”)
end //End If statement
end //End Function
[/lua]

Also, should you be using only for the EmitSound()? If you want the player to emit the sound replace only with ply. Finally, you don’t need the backslashes inside ChatPrint(). You are using an alternate method of string specification so you only need to do ply:ChatPrint(‘You are “Still Alive”’).

[lua]
resource.AddFile(“sound/deathrun/oneandonly.mp3”)

function checkAlive(ply)
if ply:Alive() then //Returns Boolean
if #team.GetPlayers( TEAM_RUN ) == 1 and team.GetPlayers( TEAM_RUN )[1] == ply then
ply:ChatPrint(‘You are “Still Alive”’) //If true (You are Alive)
ply:EmitSound( “deathrun/oneandonly.mp3”, 150, 100 );
else
//If not (You are Dead)
ply:ChatPrint(“The Cake was a lie? Now do you believe me?”)
end //End If statement
end
end
[/lua]

Try with that.

Thanks You guys !! :smiley:

But it still not worked…

Check to see what team.GetPlayers( TEAM_RUN ) returns:

[lua]
PrintTable(team.GetPlayers(TEAM_RUN))
[/lua]

Where i should type PrintTable(team.GetPlayers(TEAM_RUN)) ?

Into the top of the function, you might also want to check in your console using the lua_run command.

Still not works

http://cfile229.uf.daum.net/original/1443BC484E2227BB14AE46

What did it print to your console?

I typed lua_run. but nothing appeared…

\orangebox\garrysmod\lua\autorun\server\only.lua

[lua]

resource.AddFile(“sound/deathrun/oneandonly.mp3”)

function checkAlive(ply)
PrintTable(team.GetPlayers(TEAM_RUN))
if ply:Alive() then //Returns Boolean

if #team.GetPlayers( TEAM_RUN ) == 1 and team.GetPlayers( TEAM_RUN )[1] == ply then

ply:ChatPrint(‘You are “Still Alive”’) //If true (You are Alive)

ply:EmitSound( “deathrun/oneandonly.mp3”, 150, 100 );

else

//If not (You are Dead)

ply:ChatPrint(“The Cake was a lie? Now do you believe me?”)

end //End If statement

end

end
[/lua]

Are you testing this on a dedicated server? If you are, you’ll need to make sure all lua_run commands are run from the remote console. You’ll also need to ensure that you are running the gamemode (I know it seems obvious but a lot of people forget that). If you’re still getting nothing back from the PrintTable() function it means that the TEAM_RUN table has no players in it for some reason.