Commands crashes player
#1

Hello,I'm trying to make a filterscript,and it works,but for some reason if I type in "/hirado" my game freezes (crash)
Can someone help me?


Код:
#include <a_samp>

public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/hirado", cmdtext, true, 10) == 0)
	{
	new string[128],name[24];
	GetPlayerName(playerid,name,sizeof(name));
	format(string,sizeof(string),"{FF0000}Hнradу kцvetkezik! A stъdiуban {0099FF}%s!",name);
	SendClientMessageToAll(0xFF000000,string);
	for(new mindenki = 0; mindenki < MAX_PLAYERS; mindenki++)
	{
	PlayAudioStreamForPlayer(playerid, "https://dl.dropboxusercontent.com/s/yi9hlwb51rpaek2/tenyek.wav?");
	}
	return 1;
	}
Reply
#2

Try this instead for 2 seconds and tell me if the command works, it's not suppose to play the sound with the following code, just want to see if it's a problem with the audio stream.

pawn Код:
if (strcmp("/hirado", cmdtext, true, 10) == 0)
    {
    new string[128],name[24];
    GetPlayerName(playerid,name,sizeof(name));
    format(string,sizeof(string),"{FF0000}Hнradу kцvetkezik! A stъdiуban {0099FF}%s!",name);
    SendClientMessageToAll(0xFF000000,string);
    return 1;
    }
PS: Why are you only playing the sound for the "playerid", when you've looped all the players online with the variable of "mindenki"?.
Reply
#3

Well, I'm not sure why or even if PlayAudioStreamForPlayer causes that. Anyways, I'll correct few things for you. Since it's a filterscript, define it. "/hirado" has not lenght of 10, but 7. Although, length is optional so don't use it. At the end, you loop through all the players and you play the audio for the player who typed the command only.
pawn Код:
#define FILTERSCRIPT

#include <a_samp>

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp("/hirado", cmdtext, true))
    {
        new string[128],name[24];
        GetPlayerName(playerid,name,sizeof(name));
        format(string,sizeof(string),"{FF0000}Hнradу kцvetkezik! A stъdiуban {0099FF}%s!",name);
        SendClientMessageToAll(0xFF000000,string);
        for(new mindenki = 0; mindenki < MAX_PLAYERS; mindenki++)
        {
            if(!IsPlayerConnected(mindenki)) continue;
            PlayAudioStreamForPlayer(mindenki, "https://dl.dropboxusercontent.com/s/yi9hlwb51rpaek2/tenyek.wav?");
        }
        return 1;
    }
    return 0;
}
Reply
#4

Quote:
Originally Posted by DanishHaq
Посмотреть сообщение
Try this instead for 2 seconds and tell me if the command works, it's not suppose to play the sound with the following code, just want to see if it's a problem with the audio stream.

pawn Код:
if (strcmp("/hirado", cmdtext, true, 10) == 0)
    {
    new string[128],name[24];
    GetPlayerName(playerid,name,sizeof(name));
    format(string,sizeof(string),"{FF0000}Hнradу kцvetkezik! A stъdiуban {0099FF}%s!",name);
    SendClientMessageToAll(0xFF000000,string);
    return 1;
    }
PS: Why are you only playing the sound for the "playerid", when you've looped all the players online with the variable of "mindenki"?.
Yes it works without the audio stream,I edited it and it works. Thanks.
Topic can be locked.
Reply
#5

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Well, I'm not sure why or even if PlayAudioStreamForPlayer causes that. Anyways, I'll correct few things for you. Since it's a filterscript, define it. "/hirado" has not lenght of 10, but 7. Although, length is optional so don't use it. At the end, you loop through all the players and you play the audio for the player who typed the command only.
pawn Код:
#define FILTERSCRIPT

#include <a_samp>

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp("/hirado", cmdtext, true))
    {
        new string[128],name[24];
        GetPlayerName(playerid,name,sizeof(name));
        format(string,sizeof(string),"{FF0000}Hнradу kцvetkezik! A stъdiуban {0099FF}%s!",name);
        SendClientMessageToAll(0xFF000000,string);
        for(new mindenki = 0; mindenki < MAX_PLAYERS; mindenki++)
        {
            if(!IsPlayerConnected(mindenki)) continue;
            PlayAudioStreamForPlayer(mindenki, "https://dl.dropboxusercontent.com/s/yi9hlwb51rpaek2/tenyek.wav?");
        }
        return 1;
    }
    return 0;
}
Alright,it's working now,but I got another fs what is buggy,i will try this there.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)