AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to make this correctly (https://forums.alliedmods.net/showthread.php?t=312143)

Croxeye. 11-18-2018 08:49

How to make this correctly
 
PHP Code:

enum _:playerAchievementsTable {
    
id,
    
achievement_id,
    
unlocked
}

enum _:playerTable {
    
/* ... */
        
id,
    
playerAchievements[][playerAchievementsTable// ERROR: error 029: invalid expression, assumed zero
}

new 
player[33][playerTable];

enum _:achievementsTable {
    
id,
    
name[64],
    
description[64],
    
rewardType[10],
    
rewardAmount,
    
to_unlock
}

new 
achievements[][achievementsTable];

for(new 
1achievements[]; i++) {
     
ColorChat(idGREEN"%s"player[id][playerAchievements[i][unlocked]] == achievements[i][to_unlock] ? ("%s"achievements[i][description]) : ("Achievement Completed.")); // ERRORS: error 028: invalid subscript (not an array or too many subscripts): "playerAchievements"; error 029: invalid expression, assumed zero



OciXCrom 11-18-2018 08:54

Re: How to make this correctly
 
Remove the [].

Croxeye. 11-18-2018 09:06

Re: How to make this correctly
 
Quote:

Originally Posted by OciXCrom (Post 2624586)
Remove the [].

Code:

error 028: invalid subscript (not an array or too many subscripts): "playerAchievements"
(on last line)

OciXCrom 11-18-2018 12:51

Re: How to make this correctly
 
Remove the [i] in the "playerachievements" too.

Croxeye. 11-18-2018 17:32

Re: How to make this correctly
 
Then that is not what i'm looking for.. I have to identify each achievement...

Bugsy 11-18-2018 19:09

Re: How to make this correctly
 
You may want to re-think your data layout. Are multiple enumerators needed or can you put all data into 1 or possibly 2? You also cannot re-use the constant 'id' in all of your enumerators. In addition, which will resolve my previous statement, the player id who the data corresponds to is covered based on the index of the array holding the players data so there is no need to store it.

Croxeye. 11-20-2018 12:06

Re: How to make this correctly
 
can you show me correct way to do this please.. I want to make player session and store data in it, and destroy session on client disconnect.

Bugsy 11-20-2018 12:14

Re: How to make this correctly
 
I need more info. Is achievementsTable a pre-defined set of achievements that any player can get? Can each player get a set number of achievements? The more info you can give me the better I can help you

Croxeye. 11-20-2018 12:27

Re: How to make this correctly
 
achievements table:
id | name | description | reward_type | reward_amount | to_unlock
1 | League Master | Join Cristal League | 1 | 100 | 0

player_achievements table:
player_id | achievement_id | unlocked
1 | 1 | 0

Player with id 1 didn't unlocked achievement with id 1

Bugsy 11-20-2018 12:41

Re: How to make this correctly
 
What does to_unlock correspond to? Is a player accumulating XP and once X is reached they get a reward? Does this value reset when they get one? The more info the better


All times are GMT -4. The time now is 07:36.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.