A little problem I have
#1

I get this
Код:
C:\Documents and Settings\YkZBoY\Desktop\dec-lands\gamemodes\decvtesteeeeeee.pwn(148) : error 010: invalid function or declaration
C:\Documents and Settings\YkZBoY\Desktop\dec-lands\gamemodes\decvtesteeeeeee.pwn(12363) : warning 225: unreachable code
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
On this script

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
    {
      if(strcmp(cmdtext, "/n", true) == 0)
      {
    new idx;
          new string[150];
          if(PlayerInfo[playerid][pMuted] == 1) return SendClientMessage(playerid, COLOR_GREY, "You are muted from the newbie chat channel.");
          if(NewbieTimer[playerid] > 0)
          {
              format(string, sizeof(string), "You must wait another %d seconds.", NewbieTimer[playerid]);
              return SendClientMessage(playerid, COLOR_GREY, string);
          }
          new result[64];
          new length = strlen(cmdtext);
          new offset = idx;
          while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
          {
              result[idx - offset] = cmdtext[idx];
              idx++;
          }
          result[idx - offset] = EOS;
          if(!strlen(result)) return SendClientMessage(playerid, COLOR_GREEN, "{33CCFF}USAGE:{FFFFFF} /n [text]");
          if(strlen(result) > 108) return SendClientMessage(playerid, COLOR_GREEN, "The length of your message must be less than 108 characters.");
          if(PlayerInfo[playerid][pAdmin] < 1)
          {
              NewbieTimer[playerid] = 30;
          }
          if(PlayerInfo[playerid][pAdmin] < 1)
          {
              format(string, sizeof(string), "** Newbie %s: %s", GetPlayerNameEx(playerid), result);
          }
          if(PlayerInfo[playerid][pAdmin] == 1)
          {
              format(string, sizeof(string), "** Moderator %s: %s", GetPlayerNameEx(playerid), result);
          }
          if(PlayerInfo[playerid][pAdmin] >= 2)
          {
              format(string, sizeof(string), "** Admin %s: %s", GetPlayerNameEx(playerid), result);
          }
          SendClientMessageToAll(COLOR_GREEN, string);
          return 1;
      }
Reply
#2

What line is : 148?

Код:
This forum requires that you wait 120 seconds between posts. Please try again in 19 seconds.
Reply
#3

Which line is line 148?

The second warning is probably due to code after a return which always happens

&e:
^ was faster
Reply
#4

Line 148
pawn Код:
NewbieTimer[playerid] = 0;
Reply
#5

You either didn't initialize NewbieTimer array or it is function and you used "[]" instead of "()"
Reply
#6

Quote:
Originally Posted by Misiur
Посмотреть сообщение
You either didn't initialize NewbieTimer array or it is function and you used "[]" instead of "()"
I'll let you have this one c;
Reply
#7

Changed to "()"

Код:
C:\Documents and Settings\YkZBoY\Desktop\dec-lands\gamemodes\decvtesteeeeeee.pwn(148) : error 010: invalid function or declaration
C:\Documents and Settings\YkZBoY\Desktop\dec-lands\gamemodes\decvtesteeeeeee.pwn(12322) : error 028: invalid subscript (not an array or too many subscripts): "NewbieTimer"
C:\Documents and Settings\YkZBoY\Desktop\dec-lands\gamemodes\decvtesteeeeeee.pwn(12322) : warning 215: expression has no effect
C:\Documents and Settings\YkZBoY\Desktop\dec-lands\gamemodes\decvtesteeeeeee.pwn(12322) : error 001: expected token: ";", but found "]"
C:\Documents and Settings\YkZBoY\Desktop\dec-lands\gamemodes\decvtesteeeeeee.pwn(12322) : error 029: invalid expression, assumed zero
C:\Documents and Settings\YkZBoY\Desktop\dec-lands\gamemodes\decvtesteeeeeee.pwn(12322) : fatal error 107: too many error messages on one line

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


5 Errors.
Reply
#8

Ok, so it is an array. Change back to "[]". Do you have somewhere in your code something like
pawn Код:
new NewbieTimer[MAX_PLAYERS];
? Is it inside some function, or not? If it is inside any function, you have to move it to the top of script, so it will be accessible from every function
Reply
#9

Yes I do.
pawn Код:
new NewbieTimer[MAX_PLAYERS];
It's inside function, and it's at the top of the script.
Reply
#10

Here's a little lecture: https://sampwiki.blast.hk/wiki/Scripting_Basics#global

If you want 2 functions to share variable/array, then the variable has to be global
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)