SA-MP Forums Archive
Commands crashes player - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Commands crashes player (/showthread.php?tid=465692)



Commands crashes player - RaptorX72 - 23.09.2013

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;
	}



Re: Commands crashes player - DanishHaq - 23.09.2013

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"?.


Re: Commands crashes player - Konstantinos - 23.09.2013

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;
}



Re: Commands crashes player - RaptorX72 - 23.09.2013

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.


Re: Commands crashes player - RaptorX72 - 23.09.2013

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.