chat 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: chat problem (
/showthread.php?tid=357232)
chat problem -
kepa333 - 06.07.2012
so... i made chat for ppls wich will have trol status... so i i made like this and i alos fixed some errors but idk how to fix that 2.
PHP код:
if(strcmp(cmd, "/trolchat", true) == 0 || strcmp(cmd, "/ttc", true) == 0)
{
new message[128], string[128];
if(sscanf(params, string[128], message))
{
SendClientMessage(playerid, COLOR_WHITE, "TROLL: /ttc [MESSAGE]");
}
else
{
if(PlayerInfo[playerid][ptroll] >= 1)
{
if(strlen(message) < 1)
{
SendClientMessage(playerid, COLOR_WHITE, "TROLL: /ttc [MESSAGE]");
}
else
{
format(string, sizeof(string), "[TROLL OOC] %s says (Level %d): %s", sendername, PlayerInfo[playerid][ptroll], message);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && PlayerInfo[i][ptroll] >= 1)
{
SendClientMessage(i, COLOR_WHITE, string);
}
}
}
}
}
return 1;
}
Код:
C:\Users\MaticKepa\Desktop\Real Life ENG\gamemodes\mazda.pwn(87044) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\MaticKepa\Desktop\Real Life ENG\gamemodes\mazda.pwn(87045) : error 017: undefined symbol "params"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Error.
Re: chat problem -
.FuneraL. - 06.07.2012
Variable string already defined, and use strcmp to use strtok not use sscanf.
Re: chat problem -
milanosie - 06.07.2012
pawn Код:
if(strcmp(cmd, "/trolchat", true) == 0 || strcmp(cmd, "/ttc", true) == 0)
{
new stri[128];
new message[128];
if(sscanf(params,"s", message)) return SendClientMessage(playerid, COLOR_WHITE, "TROLL: /ttc [MESSAGE]");
{
if(PlayerInfo[playerid][ptroll] >= 1)
{
if(strlen(message) < 1)
{
SendClientMessage(playerid, COLOR_WHITE, "TROLL: /ttc [MESSAGE]");
}
else
{
format(stri, sizeof(stri), "[TROLL OOC] %s says (Level %d): %s", sendername, PlayerInfo[playerid][ptroll], message);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && PlayerInfo[i][ptroll] >= 1)
{
SendClientMessage(i, COLOR_WHITE, stri);
}
}
}
}
return 1;
}
Untested but should work.
Re: chat problem -
kepa333 - 06.07.2012
hmm its not works i got 26 errors..
Re: chat problem -
milanosie - 06.07.2012
Quote:
Originally Posted by kepa333
hmm its not works i got 26 errors..
|
Post the errors?
Re: chat problem -
kepa333 - 06.07.2012
ok i fixed all errors but now in game....
http://prntscr.com/bnxbq
EDIT: my ingame names is player becouse i connecting via debug.
EDIT: CODE:
Код:
if(strcmp(cmd, "/trolchat", true) == 0 || strcmp(cmd, "/ttc", true) == 0)
{
new stri[128];
new message[128];
if(PlayerInfo[playerid][ptroll] == 1)
{
if(strlen(message) > 1)
{
SendClientMessage(playerid, COLOR_WHITE, "TROLL: /ttc [MESSAGE]");
}
else
{
format(stri, sizeof(stri), "[TROL CHAT] %s says: %s", sendername, message);
}
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && PlayerInfo[i][ptroll] >= 1)
{
SendClientMessage(i, COLOR_WHITE, stri);
}
}
}
return 1;
}
Re: chat problem -
kepa333 - 08.07.2012
allready fixed ty.