#1

why is this code wrong in pawn?

it says (2923) : error 030: compound statement not closed at the end of file (started at line 2889)

public OnPlayerCommandText(playerid, cmdtext[])
{
new string[256];
new playermoney;
new sendername[MAX_PLAYER_NAME];
new giveplayer[MAX_PLAYER_NAME];
new playername[MAX_PLAYER_NAME];
new cmd[256];
new tmp[256];
new giveplayerid, moneys, idx;
cmd = strtok(cmdtext, idx);


if(strcmp(cmd, "/ooc", true) == 0 || strcmp(cmd, "/o", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(gPlayerLogged[playerid] == 0)
{
SendClientMessage(playerid, COLOR_GREY, " You havent logged in yet !");
return 1;
}
GetPlayerName(playerid, sendername, sizeof(sendername));
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(!strlen(result))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: (/o)oc [ooc chat]");
return 1;
}
format(string, sizeof(string), "(( %s: %s ))", sendername, result);
printf("%s", string);
{
return 0;
}
Reply
#2

Remove the return 1; after the SendClientMessage.
Reply
#3

You have an opening bracket ({) before return 0; code.
Reply
#4

now i get this error. and it looks like this

error
Код:
C:\Users\TJ's Server\Desktop\Server SA-MP\gamemodes\WEWFGRP.pwn(2935) : error 030: compound statement not closed at the end of file (started at line 2881)
code
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{

		new cmd[256];
		new	tmp[256];
		new Message[256];
		new gMessage[256];
		new pName[MAX_PLAYER_NAME+1];
		new iName[MAX_PLAYER_NAME+1];
		new	idx;
		new string[256];
	  	new playermoney;
	  	new sendername[MAX_PLAYER_NAME];
	  	new giveplayer[MAX_PLAYER_NAME];
	  	new playername[MAX_PLAYER_NAME];

		cmd = strtok(cmdtext, idx);
	{
  	if(strcmp(cmd, "/ooc", true) == 0 || strcmp(cmd, "/o", true) == 0)
  		{
    if(IsPlayerConnected(playerid))
    {
      if(gPlayerLogged[playerid] == 0)
      {
        SendClientMessage(playerid, COLOR_GREY, "  You havent logged in yet !");
       
      }
     GetPlayerName(playerid, sendername, sizeof(sendername));
     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(!strlen(result))
     {
      SendClientMessage(playerid, COLOR_GRAD2, "USAGE: (/o)oc [ooc chat]");
      return 1;
     }
     format(string, sizeof(string), "(( %s: %s ))", sendername, result);
     printf("%s", string);
	}
   return 1;
 }
}
Reply
#5

I have yet to understand why people insist on using that method of getting the single-stringed parameters of a player's command
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  if(strcmp(cmd, "/ooc", true,4) == 0 || strcmp(cmd, "/o", true,2) == 0)
  {
    //if(IsPlayerConnected(playerid)) //Redundant, a player can't type a command if he isn't connected to the server
    if(gPlayerLogged[playerid] == 0)return SendClientMessage(playerid, COLOR_GREY, "  You havent logged in yet !");
    GetPlayerName(playerid, sendername, sizeof(sendername));
    new space=strfind(cmdtext," ");
    if(!strlen(cmdtext[space])||(space==-1))return SendClientMessage(playerid, COLOR_GRAD2, "USAGE: (/o)oc [ooc chat]");
    format(string, sizeof(string), "(( %s: %s ))", sendername, cmdtext[space]);
    printf("%s", cmdtext[space]);
    return 1;
  }
}
Reply
#6

ok now i get an error that says that i have if but not ; chack please

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	{
		new cmd[256];
		new	tmp[256];
		new Message[256];
		new gMessage[256];
		new pName[MAX_PLAYER_NAME+1];
		new iName[MAX_PLAYER_NAME+1];
		new	idx;
		new string[256];
	  	new playermoney;
	  	new sendername[MAX_PLAYER_NAME];
	  	new giveplayer[MAX_PLAYER_NAME];
	  	new playername[MAX_PLAYER_NAME];

		cmd = strtok(cmdtext, idx)

  	if(strcmp(cmd, "/ooc", true,4) == 0 || strcmp(cmd, "/o", true,2) == 0)

    if(gPlayerLogged[playerid] == 0)return SendClientMessage(playerid, COLOR_GREY, "  You havent logged in yet !");
    GetPlayerName(playerid, sendername, sizeof(sendername));
    new space=strfind(cmdtext," ");
    if(!strlen(cmdtext[space])||(space==-1))return SendClientMessage(playerid, COLOR_GRAD2, "USAGE: (/o)oc [ooc chat]");
    format(string, sizeof(string), "(( %s: %s ))", sendername, cmdtext[space]);
    printf("%s", cmdtext[space]);
    return 1;
  }
}
Reply
#7

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
		new cmd[256];
		new	tmp[256];
		new Message[256];
		new gMessage[256];
		new pName[MAX_PLAYER_NAME+1];
		new iName[MAX_PLAYER_NAME+1];
		new	idx;
		new string[256];
	  	new playermoney;
	  	new sendername[MAX_PLAYER_NAME];
	  	new giveplayer[MAX_PLAYER_NAME];
	  	new playername[MAX_PLAYER_NAME];

		cmd = strtok(cmdtext, idx)

  	if(strcmp(cmd, "/ooc", true,4) == 0 || strcmp(cmd, "/o", true,2) == 0)
    {
    if(gPlayerLogged[playerid] == 0)return SendClientMessage(playerid, COLOR_GREY, "  You havent logged in yet !");
    GetPlayerName(playerid, sendername, sizeof(sendername));
    new space=strfind(cmdtext," ");
    if(!strlen(cmdtext[space])||(space==-1))return SendClientMessage(playerid, COLOR_GRAD2, "USAGE: (/o)oc [ooc chat]");
    format(string, sizeof(string), "(( %s: %s ))", sendername, cmdtext[space]);
    printf("%s", cmdtext[space]);
    return 1;
  }
  return 0;
}
Reply
#8

it is an error with this line.

if(strcmp(cmd, "/ooc", true,4) == 0 || strcmp(cmd, "/o", true,2) == 0)

C:\Users\TJ's Server\Desktop\Server SA-MP\gamemodes\WEWFGRP.pwn(2914) : error 001: expected token: ";", but found "if"
Reply
#9

Change
pawn Код:
cmd = strtok(cmdtext, idx)
into
pawn Код:
cmd = strtok(cmdtext, idx);
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)