little help with zcmd
#1

I want to make a command like /play <audiostream link>

But I don't know how to make it so the <audiostream link> bit goes into PlayAudioStreamForPlayer(playerid, <audiostream link>)
Reply
#2

Using sscanf it would be something like this
pawn Код:
CMD:playstream(playerid,params[])
{
    new url[256];
    if(sscanf(params,"s[256]",url)) return SendClientMessage(playerid,-1,"Usage: /playstream <url>");
    PlayAudioStreamForPlayer(playerid,url);
    return 1;
}
If you need any clarification on functions, tell me, and I'll explain them.
Reply
#3

Quote:
Originally Posted by Jstylezzz
Посмотреть сообщение
Using sscanf it would be something like this
pawn Код:
CMD:playstream(playerid,params[])
{
    new url[256];
    if(sscanf(params,"s[256]",url)) return SendClientMessage(playerid,-1,"Usage: /playstream <url>");
    PlayAudioStreamForPlayer(playerid,url);
    return 1;
}
If you need any clarification on functions, tell me, and I'll explain them.
I'd prefer not using sscanf for such as command and declaring a string with size 256.

pawn Код:
CMD:playstream(playerid,params[])
{
    if(isnull(params)) return SendClientMessage(playerid,-1,"Usage: /playstream <url>");
    PlayAudioStreamForPlayer(playerid,params);
    return 1;
}
Reply
#4

Quote:
Originally Posted by Jstylezzz
Посмотреть сообщение
Using sscanf it would be something like this
pawn Код:
CMD:playstream(playerid,params[])
{
    new url[256];
    if(sscanf(params,"s[256]",url)) return SendClientMessage(playerid,-1,"Usage: /playstream <url>");
    PlayAudioStreamForPlayer(playerid,url);
    return 1;
}
If you need any clarification on functions, tell me, and I'll explain them.
Just this part please: if(sscanf(params,"s[256]",url))

I don't know what sscanf has to do with it?
Reply
#5

To clarify the string size, I wasn't sure whether 128 cells was enough since some links are rather large.
sscanf is, like it's written on the SA-MP wiki:
Quote:
Originally Posted by SA-MP Wiki
Sscanf is string splitting routine made by Alex a.k.a. ******. It is the inverse to format.
It basically splits the input provided (which in this case is 'params') into the specifiers specified in the sscanf code. If you don't want to use sscanf, and don't want to use a string size, you can try this.
pawn Код:
CMD:playstream(playerid,params[])
{
    PlayAudioStreamForPlayer(playerid,params[0]);
    return 1;
}
Not sure if it works like that though, I never used it like that.
Reply
#6

Max input size is 128 in all cases.
Doesn't matter what is
Reply
#7

Quote:
Originally Posted by ReVo_
Посмотреть сообщение
Max input size is 128 in all cases.
Doesn't matter what is
Wrong.

Limits
Reply


Forum Jump:


Users browsing this thread: