SA-MP Forums Archive
My code doesn't work please help. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: My code doesn't work please help. (/showthread.php?tid=496970)



My code doesn't work please help. - Bubbly - 24.02.2014

Код:
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.


Respuesta: My code doesn't work please help. - CuervO - 24.02.2014

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.


Re: Respuesta: My code doesn't work please help. - Bubbly - 24.02.2014

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?


Re: My code doesn't work please help. - Konstantinos - 24.02.2014

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


Re: My code doesn't work please help. - Bubbly - 24.02.2014

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.


Re: My code doesn't work please help. - Konstantinos - 24.02.2014

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]++;



Re: My code doesn't work please help. - Garr - 24.02.2014

Код:
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]