AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugin/Gameplay Ideas and Requests (https://forums.alliedmods.net/forumdisplay.php?f=60)
-   -   Help to supplement the plugin [Fall sound] (https://forums.alliedmods.net/showthread.php?t=338533)

ORdli 07-10-2022 21:20

Help to supplement the plugin [Fall sound]
 
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");
}
}

DiogoOnAir 07-11-2022 09:30

Re: Help to supplement the plugin [Fall sound]
 
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.

ORdli 07-12-2022 11:59

Re: Help to supplement the plugin [Fall sound]
 
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...

alasfourom 07-12-2022 15:07

Re: Help to supplement the plugin [Fall sound]
 
Quote:

Originally Posted by ORdli (Post 2783619)
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 😂😂😂😂😂😂😂😂

Marttt 07-12-2022 16:14

Re: Help to supplement the plugin [Fall sound]
 
probably was a reply based on his signature.

Anyway, this kind of "random" usually is achieved by "GetRandomInt" with a switch/case statement.

alasfourom 07-14-2022 07:19

Re: Help to supplement the plugin [Fall sound]
 
Quote:

Originally Posted by Franc1sco (Post 1849291)
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); 
                }
            }
        } 



Cruze 07-15-2022 02:31

Re: Help to supplement the plugin [Fall sound]
 
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]);
    }




All times are GMT -4. The time now is 05:48.

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