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

Help to supplement the plugin [Fall sound]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ORdli
Member
Join Date: Nov 2021
Old 07-10-2022 , 21:20   Help to supplement the plugin [Fall sound]
Reply With Quote #1

I have a plugin that plays sound when a player crashes to death, who could help me supplement it, I need to make it so that 3 random sounds are played instead of 1


#include <sourcemod>
#include <sdktools>

public Plugin:myinfo =
{
name = "worldspawn Kill Sound",
version = "1.0",
}

public OnPluginStart()
{
HookEvent("player_death", Death);
}

public OnMapStart()
{
AddFileToDownloadsTable("sound/worldspawn.mp3");
AddToStringTable(FindStringTable("soundprecac he"), "*worldspawn.mp3");
}


public Death(Handle:event, const String:name[], bool:dontBroadcast)
{
decl String:str[32];
GetEventString(event, "weapon", str, sizeof(str));
if(strcmp(str, "worldspawn", true) == 0)
{
decl clients[MaxClients];
new total = 0;

for (new i=1; i<=MaxClients; i++)
{
if (IsClientInGame(i))
{
clients[total++] = i;
}
}
EmitSound(clients, total, "*worldspawn.mp3");
}
}
ORdli is offline
DiogoOnAir
Senior Member
Join Date: Jul 2018
Location: Portugal
Old 07-11-2022 , 09:30   Re: Help to supplement the plugin [Fall sound]
Reply With Quote #2

Do a GetRandomInt with a switch statement
https://sm.alliedmods.net/new-api/halflife/GetRandomInt
https://forums.alliedmods.net/showthread.php?t=265448

Here ,there should be everything you need.
__________________
I accept Private(Paid) plugins requests
If you like my job donate me Here
Feel free to add me on Steam
Feel free to add me on Discord DiogoOnAir | Config & Developer#7961
Check my website
If you want to buy any server, you can buy it from here!
Datacenters around the world!
DiogoOnAir is offline
ORdli
Member
Join Date: Nov 2021
Old 07-12-2022 , 11:59   Re: Help to supplement the plugin [Fall sound]
Reply With Quote #3

no thanks, but I've already been written a plugin for free, it turns out I only needed to add 4 lines, I don't think I had to pay for it...
ORdli is offline
alasfourom
Senior Member
Join Date: Feb 2022
Location: Saudi Arabia
Old 07-12-2022 , 15:07   Re: Help to supplement the plugin [Fall sound]
Reply With Quote #4

Quote:
Originally Posted by ORdli View Post
no thanks, but I've already been written a plugin for free, it turns out I only needed to add 4 lines, I don't think I had to pay for it...
He is trying to help you 😂😂😂😂😂😂😂😂
alasfourom is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 07-12-2022 , 16:14   Re: Help to supplement the plugin [Fall sound]
Reply With Quote #5

probably was a reply based on his signature.

Anyway, this kind of "random" usually is achieved by "GetRandomInt" with a switch/case statement.
__________________
Marttt is offline
alasfourom
Senior Member
Join Date: Feb 2022
Location: Saudi Arabia
Old 07-14-2022 , 07:19   Re: Help to supplement the plugin [Fall sound]
Reply With Quote #6

Quote:
Originally Posted by Franc1sco View Post
Is used for get a random integer.

For example:

PHP Code:
// teleport player to random site
            
new suerte GetRandomInt(13); // this will be a number between 1-3
            
switch (suerte)
            {
                case 
1// if is 1
                
{
                              
TeleportEntity(clientsite13NULL_VECTORNULL_VECTOR); 
                }
                case 
2// if is 2
                
{
                              
TeleportEntity(clientsite14NULL_VECTORNULL_VECTOR); 
                }
                case 
3// ...
                
{
                              
TeleportEntity(clientsite15NULL_VECTORNULL_VECTOR); 
                }
            }
        } 

Last edited by alasfourom; 07-14-2022 at 07:28.
alasfourom is offline
Cruze
Veteran Member
Join Date: May 2017
Old 07-15-2022 , 02:31   Re: Help to supplement the plugin [Fall sound]
Reply With Quote #7

Untested
PHP Code:
#include <sourcemod>
#include <sdktools>

char g_sWSSounds[][] =
{
    
"*worldspawn.mp3""*worldspawn2.mp3""*worldspawn3.mp3"
};

int g_iLen = -1;

public 
Plugin myinfo =
{
    
name "Worldspawn Death Sound",
    
author "ORdli, Cruze",
    
version "1.0",
};

public 
void OnPluginStart()
{
    
HookEvent("player_death"Event_PlayerDeath);
}

public 
void OnMapStart()
{
    
char sBuffer[256];
    
g_iLen sizeof(g_sWSSounds);
    for(
int i 0g_iLeni++)
    {
        
Format(sBuffer256"sound/%s"g_sWSSounds[i][1]);
        
        if(
FileExists(sBuffer) || FileExists(sBuffertrue))
        {
            
AddFileToDownloadsTable(sBuffer);
            
AddToStringTable(FindStringTable("soundprecache"), g_sWSSounds[i]);
        }
    }
}


public 
Action Event_PlayerDeath(Event ev, const char[] namebool dbc)
{
    
char sWeapon[64];
    
ev.GetString("weapon"sWeapon64);
    if(
strcmp(sWeapon"worldspawn"true) == 0)
    {
        
int random GetRandomInt(0g_iLen-1);
        
EmitSoundToAll(g_sWSSounds[random]);
    }

__________________
Taking paid private requests! Contact me
Cruze 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 08:53.


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