(HELP) Read file from scriptfiles folder
#1

Quote:

public OnPlayerCommandText(playerid, cmdtext[]) {
new
cmd[256], tmp[256], idx,
p_name[MAX_PLAYER_NAME], o_name[MAX_PLAYER_NAME]
;
cmd = strtok(cmdtext, idx);
if(strcmp("/dlicense", cmd, true) == 0) {
tmp = strtok(cmdtext,idx);
if(!strlen(tmp)) return SendClientMessage(playerid, -1, "USAGE: /dlicense [ID]");
new ID = strval(tmp);
if(ID == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "SERVER: playerid isn't connected!");
GetPlayerName(ID, o_name, sizeof(o_name));
GetPlayerName(playerid, p_name, sizeof(p_name));
//Do your code here, getting the playerid his INI file and checking if he owns a LICENSE!
printf("LICENSE: [%d]%s showed [%d]%s his license.", playerid, p_name, ID, o_name);
return 1;
}
return 0;
}

stock strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}

new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}

What code i must write there? Where is typed: //Do your code here, getting the playerid his INI file and checking if he owns a LICENSE!
Please?
Reply
#2

You must be having a player database folder using dini or sql

Just open the player file, eg:
When a player logs in, you open his file and update his ingame stats like
Код:
PlayerInfo[playerid][Kills] = dini_Int(file,"Kills");
Then when you want to check if he has a licence or is he having the required amount of kills like in this example, you do a simple check:
Код:
if(PlayerInfo[playerid][Kills] >= 200)
//do something
It would be helpful to know what you are using to save player stats.
Reply
#3

Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)