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




All times are GMT -4. The time now is 18:30.

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