I am receiving a lvalue (non-constant) error on 2 different lines -
Disorder - 02.09.2016
I am attempting to make the server tell everybody when connected how many users are online. Here are my lines below:
ERRORS Receiving:
C:\Users\Parent\Desktop\My Samp Server(BETA)\gamemodes\testtwo.pwn(63) : error 022: must be lvalue (non-constant)
C:\Users\Parent\Desktop\My Samp Server(BETA)\gamemodes\testtwo.pwn(73) : error 022: must be lvalue (non-constant)
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
2 Errors.
(LINE 58-66)
public OnPlayerConnect(playerid)
{
SendClientMessage(playerid, 0x7BFF00, "Welcome To My First Server");
playersconnected[0]++;
new string[100];
format(string, sizeof(string), "There are currently %d people in the server.", playersconnected++);
SendClientMessageToAll(0xE81A1AFF, string);
return 1;
}
(LINE 68-76):
public OnPlayerDisconnect(playerid, reason)
{
SendClientMessage(playerid, 0x7BFF00, "Welcome To My First Server");
playersconnected[0]--;
new string[100];
format(string, sizeof(string), "There are currently %d people in the server.", playersconnected--);
SendClientMessageToAll(0xE81A1AFF, string);
return 1;
}
Respuesta: I am receiving a lvalue (non-constant) error on 2 different lines -
HidroDF - 02.09.2016
remove the ++ and -- from lines 63 and 73.
Код:
format(string, sizeof(string), "There are currently %d people in the server.", playersconnected);
Re: I am receiving a lvalue (non-constant) error on 2 different lines -
jwh - 02.09.2016
playersconnected is an array, as I can see because you are using
playersconnected[0]--..Not sure why it is an array but let's say it is.
Now you're doing -- ++ on an array on line 63 and 73. The array itself is a constant. You must increment or decrement the data of the array and not the array itself. so replace playersconnected--/++ by playersconnected[0]--/[0]++.. Also not sure why you are incrementing playersconnected in format()