Ok, I figured out the problem. You can't reuse the variable "sentence" because you are trying to make it longer but is only as long as the original string that was submitted to it.
Try this:
PHP Code:
spk(sentence[],pitch,volume)
{
new szSoundSettings[32];
new szCmd[64];
new iPos;
if(pitch != 100)
{
iPos = formatex(szSoundSettings, charsmax(szSoundSettings), "p%i", pitch)
}
if(volume != 100)
{
formatex(szSoundSettings[iPos], charsmax(szSoundSettings) - iPos, "%sv%i", szSoundSettings[0] ? " " : "", volume)
}
if(szSoundSettings[0])
{
new iSlashPos
if( (iSlashPos = contain(sentence, "/")) != -1 )
{
iPos = add(szCmd, charsmax(szCmd), sentence, iSlashPos+1)
formatex(szCmd[iPos], charsmax(szCmd) - iPos, "(%s) %s", szSoundSettings, sentence[iSlashPos+1])
}
}
else
{
copy(szCmd, charsmax(szCmd), sentence)
}
new iPlayers[32], iNumPlayers;
get_players(iPlayers, iNumPlayers);
for(new i=0; i < iNumPlayers; i++)
{
client_cmd(iPlayers[i],"spk ^"%s^"",szCmd);
}
}
__________________