My code doesn't work please help.
#1

Код:
enum pStats{
	Killstreak
};
new Player[MAX_PLAYERS][pStats];
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
 	pStats[playerid][Killstreak] = 0;
	return 1;
}
ERROR I GET:
(170) : error 028: invalid subscript (not an array or too many subscripts): "pStats"
(170) : warning 215: expression has no effect
(170) : error 001: expected token: ";", but found "]"
(170) : error 029: invalid expression, assumed zero
(170) : fatal error 107: too many error messages on one line

I need some assistance and someone to point me in my way, and tell me what I'm doing wrong so I can learn for next time.
Reply
#2

You need to use Player array to check for the info stored inside that array. pStats is not an array, it is merely where the data used from the array is stored at.
Reply
#3

Quote:
Originally Posted by CuervO
Посмотреть сообщение
You need to use Player array to check for the info stored inside that array. pStats is not an array, it is merely where the data used from the array is stored at.
And would you mind pointing me in the right direction as to help with the code? How can I use my killstreak in an enum and still edit it?
Reply
#4

pawn Код:
Player[playerid][Killstreak] = 0;
pStats is the name of the enum, not of the array.
Reply
#5

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
pawn Код:
Player[playerid][Killstreak] = 0;
pStats is the name of the enum, not of the array.
How do I fix this to make my code work. I want the killstreak to be saved under the pStats enum. And I want to be able to set the killstreak to a certain number.
Reply
#6

Your code resets the KillStreak of the player who dies to 0. If you want to increase the killstreak when a player kills a player then:
pawn Код:
if (killerid != INVALID_PLAYER_ID) Player[killerid][Killstreak]++;
Reply
#7

Код:
enum pStats{
	Killstreak
}
new Player[MAX_PLAYERS][pStats];
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
 	Player[playerid][Killstreak] = 0;
	return 1;
}
Call the name of the array when you want to change something in the enum, not the enum's name itself. Player[playerid][thingtobeset]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)