21.05.2010, 21:04
Hi all
I'm trying to make my own basic script to verify if a user is an admin or not.
The idea is that it'll load a file with the same name as the user, and the file will have a value of either a 1 or a 0.
Te 1 will represent the user as an admin and 0 will be a regular user.
My script can load the file and read it just fine. The problem is once I get the value I can't do anything with it.
The if and else bit won't reconize the value of 'string' being 1, even though printf prints 1 or whatever value I make the file. I'm pretty sure it's just me doing a bad job initializing/calling the veriables.. Been a while since I wrote something more complex than javascript :P
Any tips or help will be greatly appreciated
I'm trying to make my own basic script to verify if a user is an admin or not.
The idea is that it'll load a file with the same name as the user, and the file will have a value of either a 1 or a 0.
Te 1 will represent the user as an admin and 0 will be a regular user.
My script can load the file and read it just fine. The problem is once I get the value I can't do anything with it.
Код:
new name [MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name)); new string[64]; new File:user = fopen(name, io_read); fread(user, string); if (string[1] == 1){ printf("Is admin"); } else { printf("Is not admin"); } printf("\n%s",string); fclose(user);
Any tips or help will be greatly appreciated