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 [B]end[/B] 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 [B]only[/B] for the [I]EmitSound()[/I]? If you want the player to emit the sound replace [B]only[/B] with [B]ply[/B]. Finally, you don't need the backslashes inside [I]ChatPrint()[/I]. You are using an alternate method of string specification so you only need to do [I]ply:ChatPrint('You are "Still Alive"')[/I].
[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 !! :D
But it still not worked..
Check to see what [I]team.GetPlayers( TEAM_RUN )[/I] returns:
[lua]
PrintTable(team.GetPlayers(TEAM_RUN))
[/lua]
[QUOTE=thefreeman193;31151312]Check to see what [I]team.GetPlayers( TEAM_RUN )[/I] returns:
[lua]
PrintTable(team.GetPlayers(TEAM_RUN))
[/lua][/QUOTE]
Where i should type PrintTable(team.GetPlayers(TEAM_RUN)) ?
[QUOTE=Predaor;31152410]Where i should type PrintTable(team.GetPlayers(TEAM_RUN)) ?[/QUOTE]
Into the top of the function, you might also want to check in your console using the [I]lua_run[/I] command.
[QUOTE=thefreeman193;31152626]Into the top of the function, you might also want to check in your console using the [I]lua_run[/I] command.[/QUOTE]
Still not works
[img]http://cfile229.uf.daum.net/original/1443BC484E2227BB14AE46[/img]
What did it print to your console?
[QUOTE=thefreeman193;31170277]What did it print to your console?[/QUOTE]
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 [I]lua_run[/I] 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 [I]PrintTable()[/I] function it means that the [B]TEAM_RUN[/B] table has no players in it for some reason.
Sorry, you need to Log In to post a reply to this thread.