chat problem
#1

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) == || strcmp(cmd"/ttc"true) == 0)
    {
        new 
message[128], string[128];
        if(
sscanf(paramsstring[128], message))
        {
            
SendClientMessage(playeridCOLOR_WHITE"TROLL:  /ttc [MESSAGE]");
        }
        else
        {
            if(
PlayerInfo[playerid][ptroll] >= 1)
            {
                if(
strlen(message) < 1)
                {
                    
SendClientMessage(playeridCOLOR_WHITE"TROLL:  /ttc [MESSAGE]");
                }
                else
                {
                    
format(stringsizeof(string), "[TROLL OOC] %s says (Level %d): %s"sendernamePlayerInfo[playerid][ptroll], message);
                    for(new 
0MAX_PLAYERSi++)
                    {
                        if(
IsPlayerConnected(i) && PlayerInfo[i][ptroll] >= 1)
                        {
                            
SendClientMessage(iCOLOR_WHITEstring);
                        }
                    }
                }
            }
        }
        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.
Reply
#2

Variable string already defined, and use strcmp to use strtok not use sscanf.
Reply
#3

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.
Reply
#4

hmm its not works i got 26 errors..
Reply
#5

Quote:
Originally Posted by kepa333
Посмотреть сообщение
hmm its not works i got 26 errors..
Post the errors?
Reply
#6

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

allready fixed ty.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)