AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Problem with playing Sound + StrContains doesn't works (https://forums.alliedmods.net/showthread.php?t=133785)

n00bfilter 07-28-2010 21:00

Problem with playing Sound + StrContains doesn't works
 
Hello, this is my first time scripting for SourceMod.
I tried to make a joinsound for everyone, so I put my wav into sound/servername/ on the Server and on the Fastdownload in the same.
Then here is the plugin:
PHP Code:

/* Plugin Template generated by Pawn Studio */

#include <sourcemod>
#include <sdktools_sound>

public Plugin:myinfo 
{
    
name "joinsound",
    
author "r0b",
    
description "plays a sound when joining the server",
    
version "1.0",
    
url "www.fairfailt.de"
}

public 
OnPluginStart()
{
}

public 
OnClientPutInServer(client)
{
    
PrecacheSound("fairfailt/zielen.wav",true)
    
EmitSoundToAll("fairfailt/zielen.wav")


But it always told me that I have to precache the sound.
I fixed it with this PrecacheSound Command, but now it dont play the Sound after joining and it dont show any errors. Please help me, if you can :D

So here is my second problem:
i check with StrContains if my Steamid exists in another String, that i read from a file. I printed the data of the file and my steamid to the server and my steamid was in the String like that:

file:
steamid;1;1;1;1

auth:
steamid

So StrContains should go on to the following commands, but it stops at StrContains..i dont know, why. Please help me :D

Thanks and bye, n00bfilter.

almcaeobtac 07-28-2010 21:57

Re: Problem with playing Sound
 
OnClientPutInServer is ran before you're done Sending Info.
Try putting a timer there instead of playing the sound. Set the timer to 3 seconds, then play the sound. It should work then.

n00bfilter 07-28-2010 22:03

Re: Problem with playing Sound + StrContains doesn't works
 
Okay, i'll try it. Can you look at my other problem, while I'm testing?
I edited it to the first post :D Thanks.


Is is correct like this:
PHP Code:

public OnClientPutInServer(client)
{
    
PrecacheSound("fairfailt/zielen.wav",true)
    
CreateTimer(3.0,ExecJoinsound)
}

public 
Action:ExecJoinsound(Handle:timer)
{
    
EmitSoundToAll("fairfailt/zielen.wav")
    


Because this doesn't work. Or is the timer wrong. First time scripting..sorry. :P

Okay the timer works, but it don't play the sound. :/ No error message. Why i know the timer works, but not the sound? I printed Test to the Server. Test was printend, sound wasnt played. :/
Please help me, for me it looks correct, so it must work :S

rhelgeby 07-29-2010 04:43

Re: Problem with playing Sound + StrContains doesn't works
 
Hook the player_spawn event and check if the player is NOT alive. In that case, their view camera was just spawned, and they can see the map.

n00bfilter 07-29-2010 06:45

Re: Problem with playing Sound + StrContains doesn't works
 
Hello, i hooked the event like this:
PHP Code:

/* Plugin Template generated by Pawn Studio */

#include <sourcemod>
#include <sdktools_sound>
#include <timers>

public Plugin:myinfo 
{
    
name "joinsound",
    
author "r0b",
    
description "plays a specified sound when joining the server",
    
version "1.0",
    
url "www.fairfailt.de"
}

public 
OnPluginStart()
{
    
HookEvent("player_spawn",Event_PlayerSpawn)
}

public 
Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    
PrecacheSound("fairfailt/zielen.wav",true)
    
EmitSoundToAll("fairfailt/zielen.wav")
    
PrintToServer("test")


The Serverconsole looks like this when joining Team. It prints the "test". But dont play the sound. :/
"n00bfilter<2><STEAM_0:0:14636098><Unassigned >" joined team "CT"
test


Also can you please look at my problem above?
I'll post it here again:
i check with StrContains if my Steamid exists in another String, that i read from a file. I printed the data of the file and my steamid to the server and my steamid was in the String like that:

file:
steamid;1;1;1;1

auth:
steamid

So StrContains should go on to the following commands, but it stops at StrContains..i dont know, why. Please help me :D
Code:
PHP Code:

public OnClientAuthorized(client,const String:auth[])
{
    new 
Handle:pfile OpenFile("cfg/sourcemod/r0b_database.ini","r")
    new 
String:data[64],String:clientauth[64];
    
GetClientAuthString(client,clientauth,64)
    new 
String:dataArr[6][64];
    
PrintToServer("%s schaffts bis hierhin.2",clientauth)
    while(!
IsEndOfFile(pfile) && ReadFileLine(pfile,data,64))
    {
        
PrintToServer("%s schaffts bis hierhin.2",clientauth)
        
PrintToServer("weil er die Datei lesen kann: %s",data)
        if(
StrContains(data,"STEAM_0:0:14636098",false))
        {
            
ExplodeString(data,";",dataArr,6,64)
            
PrintToServer("%s schaffts bis hierhin.3",clientauth)
            new 
userid GetClientUserId(client);
            
PrintToServer("Deine Steamid: %s, deine Userid: %d, dein X: %d",clientauth,userid,client)
            
PrintToServer("dataArr: %s",dataArr[2])
        }
    }



KawMAN 07-29-2010 09:05

Re: Problem with playing Sound + StrContains doesn't works
 
StrContaing retrun notes:
Code:

-1 on failure (no match found). Any other value indicates a position in the string where the match starts.
so change
PHP Code:

if(StrContains(data,"STEAM_0:0:14636098",false)) 

to
PHP Code:

if(StrContains(data,"STEAM_0:0:14636098",false)!=-1


n00bfilter 07-29-2010 09:28

Re: Problem with playing Sound + StrContains doesn't works
 
Okay, works. Thank you. Can you look at this sound-problem, too? :D
Thanks for StrContains. :P

almcaeobtac 07-29-2010 14:32

Re: Problem with playing Sound + StrContains doesn't works
 
Maybe your sound isn't set up right to work with half life 2? Try going to the HLSW website, and look up how to convert .wav files.

pheadxdll 07-29-2010 14:38

Re: Problem with playing Sound + StrContains doesn't works
 
Precache the sound during OnMapStart()

n00bfilter 07-29-2010 15:08

Re: Problem with playing Sound + StrContains doesn't works
 
The sound have to work for HL2, because it works at HLDJ.
It doesnt work like you said. This is what i have now:

PHP Code:

#include <sourcemod>
#include <sdktools_sound>

public Plugin:myinfo 
{
    
name "joinsound",
    
author "r0b",
    
description "plays a specified sound when joining the server",
    
version "1.0",
    
url "www.fairfailt.de"
}

public 
OnPluginStart()
{
    
HookEvent("player_spawn",Event_PlayerSpawn)
}

public 
OnMapStart()
{
    
PrecacheSound("fairfailt/zielen.wav",true)
}

public 
Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event,"userid"))
    
EmitSoundToClient(client,"fairfailt/zielen.wav")



KawMAN 07-29-2010 17:35

Re: Problem with playing Sound + StrContains doesn't works
 
give us this zielen.wav

Monkeys 07-29-2010 17:39

Re: Problem with playing Sound + StrContains doesn't works
 
Easy way of checking if the file is correct or not:
if(PrecacheSound("fairfailt/zielen.wav")) PrintToChatAll("Precached");

almcaeobtac 07-29-2010 17:59

Re: Problem with playing Sound + StrContains doesn't works
 
Oh derp. Do your client's have the sound too?

n00bfilter 07-29-2010 19:18

Re: Problem with playing Sound + StrContains doesn't works
 
Idk. It should be. I put in in the fastDL: sound/zielen.wav.bz2
and i put it in the server: sound/zielen.wav
How to get them download this?

DarkEnergy 07-29-2010 23:04

Re: Problem with playing Sound + StrContains doesn't works
 
stock AddFileToDownloadsTable(const String:filename[])

almcaeobtac 07-30-2010 01:17

Re: Problem with playing Sound + StrContains doesn't works
 
Make sure you have it in your own sound folder, then test it again.

n00bfilter 07-30-2010 06:00

Re: Problem with playing Sound + StrContains doesn't works
 
Okay, thanks. It is downloading now, thanks DarkEnergy.
But i cant play it:
when it should be played, this is displayed in the client console:
(Soundpath etc.), file probably missing from disk/repository
I am not good in english, but I think, i know what it tells me.
But on client and server the sound exists.

DarkEnergy 07-30-2010 09:14

Re: Problem with playing Sound + StrContains doesn't works
 
that happens alot even though both the server and the client have the sound files (its client side). the only thing you can do is restarting ur client or try to reinstall your client

n00bfilter 07-30-2010 09:21

Re: Problem with playing Sound + StrContains doesn't works
 
So I should reinstall my Counter-Strike Source? Because restarting, is what I've done the last day again and again. Doesn't change anything. So i reinstall. Hm, okay..:/

n00bfilter 07-30-2010 11:27

Re: Problem with playing Sound + StrContains doesn't works
 
Okay, i reinstalled my CSS, but now its on every spawn.
What event is the team selection display? Can i get an event there?

DarkEnergy 07-30-2010 12:48

Re: Problem with playing Sound + StrContains doesn't works
 
remember this?

public OnClientPutInServer(client)
{

CreateTimer(3.0,ExecJoinsound)
}

public
Action:ExecJoinsound(Handle:timer)
{
EmitSoundToAll("fairfailt/zielen.wav")

}

Death [GER] 07-30-2010 17:17

Re: Problem with playing Sound + StrContains doesn't works
 
Code:

public OnClientPostAdminCheck(client)
{
EmitSoundToAll("fairfailt/zielen.wav")
}


Greyscale 07-30-2010 17:52

Re: Problem with playing Sound + StrContains doesn't works
 
I don't think you even need to delay it in OnClientPutInServer. You should be able to play it then.

almcaeobtac 07-30-2010 19:00

Re: Problem with playing Sound + StrContains doesn't works
 
No, because sometimes OnClientPutInServer runs before the client is fully in the game. Sometimes it runs while they are still sending info.

Greyscale 07-30-2010 21:27

Re: Problem with playing Sound + StrContains doesn't works
 
It's going to consistently fire at a certain point every time. There is no "sometimes" it would either not work or always work. I would think it works. Has anyone tried it?

Monkeys 07-30-2010 21:48

Re: Problem with playing Sound + StrContains doesn't works
 
Quote:

Originally Posted by Greyscale (Post 1256735)
It's going to consistently fire at a certain point every time. There is no "sometimes" it would either not work or always work. I would think it works. Has anyone tried it?

Why do you think that?

almcaeobtac 07-31-2010 00:21

Re: Problem with playing Sound + StrContains doesn't works
 
In my experience, I always connect at slightly different times. Sometimes I hear the join sound, sometimes I don't. That is, until I put a 3 second timer on it. Then I heard it every time.


All times are GMT -4. The time now is 12:09.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.