Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error 033: array must be indexed (variable "dt2") #1

Open
Spressed1 opened this issue Jan 12, 2022 · 1 comment
Open

error 033: array must be indexed (variable "dt2") #1

Spressed1 opened this issue Jan 12, 2022 · 1 comment

Comments

@Spressed1
Copy link

dt = DateTime.Now();
pInfo[playerid][pVIPLevel] = 1;
SendClientMessage(playerid,-1,"Hello");
dt2 = DateTime.AddMinutes(dt, 2);
new cell: DataCompareR = DateTime.Compare(dt,dt2);
if (DataCompareR == 0 || DataCompareR > 0){
TempVip(playerid);
}

How would I go about adding minutes to the actual date which will constantly update, and then save that value on variable DT2, so I can compare them later on? to do timed actions/temporary actions saved?

@Sasino97
Copy link
Owner

Sasino97 commented Jul 1, 2023

Hi, sorry for the long delay. This repository isn't actively maintained so it took me a while to see this issue.
You have probably already found out, but I'll write it here for anyone who might be having the same issue.
Basically, DateTime.AddMinutes doens't return anything, it operates directly on the array you pass (by reference).
So, a correct way solve your problem would be:

new DateTime: now = DateTime.Now();
new DateTime: later = DateTime.Now();
DateTime.AddMinutes(later, 2);
if (DateTime.Compare(now, later) >= 0) {
    TempVip(playerid);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants