[Help] Vip chat - 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: [Help] Vip chat (
/showthread.php?tid=321579)
[Help] Vip chat -
ServerScripter - 27.02.2012
hi , i have this :
pawn Код:
dcmd_vchat( playerid, params[] )
{
#pragma unused params
if( Vip[ playerid ] < 1 )
return SendClientMessage( playerid, COLOR_CERVENA, " [!] Only Vips can do that !" );
if(Vip[playerid] >= 1)
{
new name[24];
GetPlayerName(playerid, name, 24);
new string[300];
format(string, sizeof(string), "[VIP CHAT] %s [%d]: %s", name, playerid, string[1]);
SendClientMessage(playerid, COLOR_WHITE, string);
}
return 1;
but the problem is the script doesn't show what player say only %s: , i hope you help me
Re: [Help] Vip chat -
Jeffry - 27.02.2012
pawn Код:
dcmd_vchat( playerid, params[] )
{
if( Vip[ playerid ] < 1 )
return SendClientMessage( playerid, COLOR_CERVENA, " [!] Only Vips can do that !" );
if(Vip[playerid] >= 1)
{
if(!strlen(params)) return SendClientMessage( playerid, COLOR_CERVENA, "Usage: /vchat [text]" );
new name[24];
GetPlayerName(playerid, name, 24);
new string[300];
format(string, sizeof(string), "[VIP CHAT] %s [%d]: %s", name, playerid, string[1]);
for(new i=0; i<MAX_PLAYERS; i++) if(Vip[i]>=1) SendClientMessage(i, COLOR_WHITE, string);
}
return 1;
}
Re: [Help] Vip chat -
ServerScripter - 27.02.2012
thank you!
Re: [Help] Vip chat -
Zhao - 27.02.2012
Rather than the for loop I recommend that you use foreach. It's more efficient and there's no reason the string length should be 300, change it to 128.
Re: [Help] Vip chat -
Konstantinos - 27.02.2012
Quote:
Originally Posted by Zhao
Rather than the for loop I recommend that you use foreach. It's more efficient and there's no reason the string length should be 300, change it to 128.
|
for loop -> foreach
Also, I agree about the lenght. Max lenght string in SA-MP is 128.
Re: [Help] Vip chat -
ServerScripter - 27.02.2012
lol i have writen in a string like string[800] because in a MSGBOX without it , it doesn't appear...
Re: [Help] Vip chat -
Konstantinos - 27.02.2012
I am talking about
SendClientMessage function.
About the Dialogs, the max is 1024
Re: [Help] Vip chat -
ServerScripter - 27.02.2012
Quote:
Originally Posted by Dwane
I am talking about SendClientMessage function.
About the Dialogs, the max is 1024
|
oh thanks for the information
Re: [Help] Vip chat -
Twisted_Insane - 27.02.2012
Hi dude!
You're making it way too complicated! Why don't you use it like this? Add this under "OnPlayerText":
pawn Код:
if(text[0] == '*')
{
if(PlayerInfo[playerid][VIP] >= 1)
{
new str[128], name[24];
GetPlayerName(playerid, name, 24);
format(str, 128, "[VIP CHAT] %s(%d): %s", name,playerid, text[1]);
SendMessageToVIP(COLOR_KHAKI,str);
return 0;
}
return 1;
}
And forward this:
pawn Код:
forward SendMessageToVIP(color,const string[]);
pawn Код:
public SendMessageToVIP(color,const string[])
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) == 1)
if(PlayerInfo[i][VIP] >= 1)
SendClientMessage(i, color, string);
}
return 1;
}
I don't know what your enum for the player's info is like, just put a VIP-Level into it and replace the variables with your own! FINISHED!
Hope I could help!