PM help
#1

Iv'e created a pm cmd but i get errors

Код:
CMD:pm(playerid, params[])
{
  new str[128], str[128], id, Name1[MAX_PLAYER_NAME] , Name2[MAX_PLAYER_NAME];
  if(sscanf(params, "us", id, str2))
  {
  SendClientMessage(playerid, 0xFF0000FF, "{ff0000}USAGE:/pm <id/name> <Message>
  return 1;
  }
  if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFF0000FF, "{ff0000}ERROR: This Player Is Not Connected.");
  if(playerid != id) return SendClientMessage(playerid, 0xFF0000FF, "{ff0000}ERROR: You Cannot Send PM Message To Your Self.");
  {
	GetPlayerName(playerid, Name1, sizeof(Name1));
	GetPlayerName(id, Name2, sizeof(Name2));
	format(str, sizeof(str), "PM To %s (ID: %d): %s", Name2, id, str2);
	format(str, sizeof(str), "PM From %s (ID %d): %s", Name1, playerid, str2);
	SendCilentMessage(id, 0xFF0000FF, str);
  }
  return 1;
}
Код:
C:\Users\NINA\Desktop\LSGW\gamemodes\LSGW.pwn(340) : error 021: symbol already defined: "str"
C:\Users\NINA\Desktop\LSGW\gamemodes\LSGW.pwn(341) : error 017: undefined symbol "str2"
C:\Users\NINA\Desktop\LSGW\gamemodes\LSGW.pwn(343) : error 037: invalid string (possibly non-terminated string)
C:\Users\NINA\Desktop\LSGW\gamemodes\LSGW.pwn(343) : error 017: undefined symbol "ff0000"
C:\Users\NINA\Desktop\LSGW\gamemodes\LSGW.pwn(343) : warning 217: loose indentation
C:\Users\NINA\Desktop\LSGW\gamemodes\LSGW.pwn(343) : error 029: invalid expression, assumed zero
C:\Users\NINA\Desktop\LSGW\gamemodes\LSGW.pwn(343) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


6 Errors.
Reply
#2

Here:

pawn Код:
CMD:pm(playerid, params[])
{
    new str[128], str2[128], id, Name1[MAX_PLAYER_NAME] , Name2[MAX_PLAYER_NAME];
    if(sscanf(params, "us[128]", id, str))
    {
        SendClientMessage(playerid, 0xFF0000FF, "USAGE:/pm <id/name> <Message>");
        return 1;
    }
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: This Player Is Not Connected.");
    if(playerid == id) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: You Cannot Send PM Message To Your Self.");
    {
        GetPlayerName(playerid, Name1, sizeof(Name1));
        GetPlayerName(id, Name2, sizeof(Name2));
        format(str, sizeof(str), "PM To %s (ID: %d): %s", Name2, id, str);
        format(str, sizeof(str), "PM From %s (ID %d): %s", Name1, playerid, str2);
        SendCilentMessage(id, 0xFF0000FF, str2);
        SendClientMessage(id, 0xFF0000FF, str);
    }
    return 1;
}
I hope I helped any feedback would be appreciated!
Reply
#3

pawn Код:
CMD:pm(playerid, params[])
{
    new message[128], str[145], id, Name[MAX_PLAYER_NAME] // There's no need to have 2 names, as you can just use 1
  // You also added to new str, you on'y need 1.
    if(sscanf(params, "us[128]", id, message)) // When using s in sscanf put the length in [] next to it
    {
        SendClientMessage(playerid, 0xFF0000FF, "USAGE:/pm <id/name> <Message>"); // You did not end this with ");
        // You also don't need to put the same color at the start, as you already did that in SendClientMessage
        return 1;
    }
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: This Player Is Not Connected."); // Same thing as above
    if(playerid != id) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: You Cannot Send PM Message To Your Self."); // Same thing as above
    {
        GetPlayerName(id, Name, sizeof(Name));
        format(str, sizeof(str), "PM To %s (ID: %d): %s", Name, id, message);
        SendClientMessage(playerid, 0xFF0000FF, str);
        GetPlayerName(playerid, Name, sizeof (Name));
        format(str, sizeof(str), "PM From %s (ID %d): %s", Name, playerid, message);
        SendCilentMessage(id, 0xFF0000FF, str);
    }
    return 1;
}
Reply
#4

pawn Код:
CMD:pm(playerid, params[])
{
    new str[128], str2[128], id, Name1[MAX_PLAYER_NAME] , Name2[MAX_PLAYER_NAME];
    if(sscanf(params, "us[128]", id, str2))
    {
        SendClientMessage(playerid, 0xFF0000FF, "USAGE:/pm <id/name> <Message>");
        return 1;
    }
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: This Player Is Not Connected.");
    if(playerid != id) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: You Cannot Send PM Message To Your Self.");
    {
        GetPlayerName(playerid, Name1, sizeof(Name1));
        GetPlayerName(id, Name2, sizeof(Name2));
        format(str, sizeof(str), "PM To %s (ID: %d): %s", Name2, id, str2);
        format(str, sizeof(str), "PM From %s (ID %d): %s", Name1, playerid, str2);
        SendClientMessage(id, 0xFF0000FF, str);
    }
    return 1;
}
Compiled this with no errors, give it a go.

EDIT: you had 2 str's defined and some typo's.
Reply
#5

same errors
Reply
#6

Quote:
Originally Posted by JordanDoughty
Посмотреть сообщение
pawn Код:
CMD:pm(playerid, params[])
{
    new str[128], str2[128], id, Name1[MAX_PLAYER_NAME] , Name2[MAX_PLAYER_NAME];
    if(sscanf(params, "us[128]", id, str2))
    {
        SendClientMessage(playerid, 0xFF0000FF, "USAGE:/pm <id/name> <Message>");
        return 1;
    }
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: This Player Is Not Connected.");
    if(playerid != id) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: You Cannot Send PM Message To Your Self.");
    {
        GetPlayerName(playerid, Name1, sizeof(Name1));
        GetPlayerName(id, Name2, sizeof(Name2));
        format(str, sizeof(str), "PM To %s (ID: %d): %s", Name2, id, str2);
        format(str, sizeof(str), "PM From %s (ID %d): %s", Name1, playerid, str2);
        SendClientMessage(id, 0xFF0000FF, str);
    }
    return 1;
}
Compiled this with no errors, give it a go.

EDIT: you had 2 str's defined and some typo's.
Quote:
Originally Posted by YanLanger
Посмотреть сообщение
same errors
Sure? Mine compiled without any and so did Stinged's.
Reply
#7

is it a fs or in gm?
Reply
#8

Try mine? I have updated it
Reply
#9

Quote:
Originally Posted by YanLanger
Посмотреть сообщение
is it a fs or in gm?
mine was in my gamemode.
Reply
#10

oh fixed, can you add /r to it? like replay
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)