[Help!] Can someone please help me with my /accent command.
#1

Okay so i'm attempting to make an accent system for an gamemode i'm working on, But the problem is that pawno crashes if i try to compile it..

pawn Код:
if(strcmp(cmd, "/Accent", true) == 0 || strcmp(cmd, "/acce", true) == 0)
    {
   if(IsPlayerConnected(playerid))
   {
       if(gPlayerLogged[playerid] == 0)
      {
        SendClientMessage(playerid, COLOR_GREY, "[HINT]  You need to login first ! ");
        return 1;
      }
      new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[64];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            result[idx - offset] = EOS;
            if(length > 64)
            {
              SendClientMessage(playerid, COLOR_GREY, "  Accent is too long ! ");
              return 1;
            }
            if(!strlen(result))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "[USAGE] /Accent [text]");
                return 1;
            }
            if(PlayerInfo[playerid][pAccent] == 0)
            {
              strmid(PlayerInfo[playerid][pAccent], result, 0, strlen(result), 255);
              PlayerInfo[playerid][pAccent] = 1;
              SendClientMessage(playerid, COLOR_WHITE, "[INFO] You have successfuly Set your Accent.");
              return 1;
            }
            else if(PlayerInfo[playerid][pAccent] == 1)
      {
            PlayerInfo[playerid][pAccent] = 0;
            SendClientMessage(playerid, COLOR_WHITE, "[INFO] You have successfuly removed your Accent.");
            }
   }
  }
Reply
#2

You're using pAccent as a string. You've probably got it defined as an integer or something.

Код:
#define isnull(%1) ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))

if(strcmp(cmd, "/Accent", true) == 0 || strcmp(cmd, "/acce", true) == 0)
{
	if(IsPlayerConnected(playerid))
	{
		if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_GREY, "[HINT]  You need to login first ! ");
		new length = strlen(cmdtext);
		if(length > 64) return SendClientMessage(playerid, COLOR_GREY, "Accent is too long! ");
		while ((idx < length) && (cmdtext[idx] <= ' '))
		{
			idx++;
		}
		new offset = idx;
		new result[64];
		while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
		{
			result[idx - offset] = cmdtext[idx];
			idx++;
		}
		result[idx - offset] = EOS;
		if(isnull(result)) return SendClientMessage(playerid, COLOR_GRAD2, "[USAGE] /Accent [text]");
		if(isnull(PlayerInfo[playerid][pAccent]))
		{
			strmid(PlayerInfo[playerid][pAccent], result, 0, strlen(result), 255);
			SendClientMessage(playerid, COLOR_WHITE, "[INFO] You have successfuly Set your Accent.");
		}
		else
		{
			strdel(PlayerInfo[playerid][pAccent], 0, strlen(PlayerInfo[playerid][pAccent]));
			SendClientMessage(playerid, COLOR_WHITE, "[INFO] You have successfuly removed your Accent.");
		}
	}
	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)