Command problem - 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: Command problem (
/showthread.php?tid=541499)
Command problem -
rraulinio - 12.10.2014
Hello guys!
I have a problem with a command. I've coded a VIP system for my server with some new commands and also, I've introduced a /vipchat command. Because I didn't want to waste time, I've copied the /adminchat command and just replaced some lines. The problem is that when I use /vipchat in game, it does work, but it is also followed by the "
SERVER: Unknown command" message and I just don't understand why. Bellow is the script, please help me.
Thanks in advance!
Код:
//===============================================================================================//
if(strcmp(cmd, "/vipchat", true) == 0 || strcmp(cmd, "/vc", true) == 0 || strcmp(cmd, "/vchat", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(gPlayerLogged[playerid] == 0)
{
SendClientMessage(playerid, COLOR_WHITE, "You havent logged in yet");
return 1;
}
if (PlayerInfo[playerid][pVIP]==0 && PlayerInfo[playerid][pAdmin] < 1)
{
SendClientMessage(playerid, COLOR_WHITE, "You are not a VIP member");
return 1;
}
if(PlayerInfo[playerid][pMuted] == 1)
{
SendClientMessage(playerid, TEAM_CYAN_COLOR, "You can't speak, you have been silenced");
return 1;
}
new result[64];
GetPlayerName(playerid, sendername, sizeof(sendername));
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_GREY, "USAGE: /(v)ip©hat [text]");
return 1;
}
format(string, sizeof(string), "{FFFFFF}» {F3FF02}[VIP CHAT] %s: {FFFFFF}%s", sendername, result);
for(new i=0; i<=MAX_PLAYERS; i++) {
if(PlayerInfo[i][pVIP]==1)
SendClientMessage(i, -1, string);
}
}
return 1;
}
//===============================================================================================//
Re: Command problem -
Stinged - 12.10.2014
Add return 1; above the last }
Re: Command problem -
rraulinio - 12.10.2014
return 1; is already added for the if(strcmp...) ... look in the code.
Re: Command problem -
XGreen - 12.10.2014
Try to add this:
Re: Command problem -
MrJunkiTM - 12.10.2014
I think you have to use return 0;
Re: Command problem -
rraulinio - 12.10.2014
@XGreen @MrJunkiTM Did both of those things and still nothing ...
Re: Command problem -
Stinged - 12.10.2014
I got to say, your indentation is fucked up.
Re: Command problem -
XGreen - 12.10.2014
Try This:
pawn Код:
if(strcmp(cmd, "/vipchat", true) == 0 || strcmp(cmd, "/vc", true) == 0 || strcmp(cmd, "/vchat", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_WHITE, "You havent logged in yet");
if (PlayerInfo[playerid][pVIP]==0 && PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_WHITE, "You are not a VIP member");
if(PlayerInfo[playerid][pMuted] == 1) return SendClientMessage(playerid, TEAM_CYAN_COLOR, "You can't speak, you have been silenced");
if(sscanf(params, "uds[50]", cmdtext)) return SendClientMessage(playerid, 0xFFFFFFFF, "Correct usage: /(v)ip©hat [text]");
new result[64];
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "{FFFFFF}» {F3FF02}[VIP CHAT] %s: {FFFFFF}%s", sendername, result);
for(new i=0; i<=MAX_PLAYERS; i++) {
if(PlayerInfo[i][pVIP]==1)
SendClientMessage(i, -1, string);
}
}
return 1;
}
Also, I Suggest To You To Use zcmd, it's much easier in creating commands.
Re: Command problem -
rraulinio - 12.10.2014
Y... I know. I've solve the indentation afther the problem is solved.
Re: Command problem -
dominik523 - 12.10.2014
Quote:
Originally Posted by XGreen
|
Please check out this thread.