Raised This Month: $51 Target: $400
 12% 

Problem with playing Sound + StrContains doesn't works


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
n00bfilter
Junior Member
Join Date: Jul 2010
Old 07-28-2010 , 21:00   Problem with playing Sound + StrContains doesn't works
Reply With Quote #1

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

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

Thanks and bye, n00bfilter.

Last edited by n00bfilter; 07-28-2010 at 22:00. Reason: + another problem to solve
n00bfilter is offline
almcaeobtac
Senior Member
Join Date: Nov 2008
Location: Florida
Old 07-28-2010 , 21:57   Re: Problem with playing Sound
Reply With Quote #2

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.
__________________
almcaeobtac is offline
n00bfilter
Junior Member
Join Date: Jul 2010
Old 07-28-2010 , 22:03   Re: Problem with playing Sound + StrContains doesn't works
Reply With Quote #3

Okay, i'll try it. Can you look at my other problem, while I'm testing?
I edited it to the first post 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.

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

Last edited by n00bfilter; 07-28-2010 at 22:19.
n00bfilter is offline
rhelgeby
Veteran Member
Join Date: Oct 2008
Location: 0x4E6F72776179
Old 07-29-2010 , 04:43   Re: Problem with playing Sound + StrContains doesn't works
Reply With Quote #4

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.
__________________
Richard Helgeby

Zombie:Reloaded | PawnUnit | Object Library
(Please don't send private messages for support, they will be ignored. Use the forum.)
rhelgeby is offline
Send a message via MSN to rhelgeby
n00bfilter
Junior Member
Join Date: Jul 2010
Old 07-29-2010 , 06:45   Re: Problem with playing Sound + StrContains doesn't works
Reply With Quote #5

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
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])
        }
    }


Last edited by n00bfilter; 07-29-2010 at 07:18.
n00bfilter is offline
KawMAN
SourceMod Donor
Join Date: Sep 2007
Location: Cracov
Old 07-29-2010 , 09:05   Re: Problem with playing Sound + StrContains doesn't works
Reply With Quote #6

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
__________________
KawMAN is offline
Send a message via ICQ to KawMAN Send a message via Skype™ to KawMAN
n00bfilter
Junior Member
Join Date: Jul 2010
Old 07-29-2010 , 09:28   Re: Problem with playing Sound + StrContains doesn't works
Reply With Quote #7

Okay, works. Thank you. Can you look at this sound-problem, too?
Thanks for StrContains.
n00bfilter is offline
almcaeobtac
Senior Member
Join Date: Nov 2008
Location: Florida
Old 07-29-2010 , 14:32   Re: Problem with playing Sound + StrContains doesn't works
Reply With Quote #8

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.
__________________
almcaeobtac is offline
pheadxdll
AlliedModders Donor
Join Date: Jun 2008
Old 07-29-2010 , 14:38   Re: Problem with playing Sound + StrContains doesn't works
Reply With Quote #9

Precache the sound during OnMapStart()
__________________
pheadxdll is offline
n00bfilter
Junior Member
Join Date: Jul 2010
Old 07-29-2010 , 15:08   Re: Problem with playing Sound + StrContains doesn't works
Reply With Quote #10

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")


Last edited by n00bfilter; 07-29-2010 at 15:12.
n00bfilter is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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