#include <YSI\y_ini>
#define PATH "MapLicense/%s.ini"
enum PlayerInfo
{
maplicense
}
new MappingLicense[MAX_PLAYERS][PlayerInfo];
forward LoadMappingLicenseData(playerid,name[],value[]);
public LoadMappingLicenseData(playerid,name[],value[])
{
INI_Int("Mapping", MappingLicense[playerid][maplicense]);
return 1;
}
stock UserMappingLicensePath(playerid)
{
new string[128],playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playername));
format(string,sizeof(string),PATH,playername);
return string;
}
public OnPlayerConnect(playerid)
{
if(fexist(UserMappingLicensePath(playerid)))
{
INI_ParseFile(UserMappingLicensePath(playerid), "LoadMappingLicenseData", .bExtra = true, .extra = playerid);
}
else
{
new INI:ini = INI_Open(UserMappingLicensePath(playerid));
INI_WriteInt(ini,"MapLicense", 0);
MappingLicense[playerid][maplicense] = 0;
INI_Close(ini);
}
return 1;
}
public OnFilterScriptExit()
{
foreach(new i : Player)
{
new INI:ini = INI_Open(UserMappingLicensePath(i));
INI_WriteInt(ini,"MapLicense", MappingLicense[i][maplicense]);
INI_Close(ini);
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new INI:ini = INI_Open(UserMappingLicensePath(playerid));
INI_WriteInt(ini,"MapLicense", MappingLicense[playerid][maplicense]);
INI_Close(ini);
return 1;
}
if(MappingLicense[playerid][maplicense] == 1)
{
//object thing
}
else
{
//sendclientmessage thingy
}
CMD:givemaplicense(playerid, params[])
{
if(IsPlayerAdmin(playerid))
{
new targetid, license, name[MAX_PLAYER_NAME], string[128 + MAX_PLAYER_NAME];
if(sscanf(params, "ud", targetid, license))
{
return SendClientMessage(playerid, 0xFF0000FF, "[Error:] /givemaplicense <id> <0 - 1>");
}
if(license > 1 || license < 0)
{
return SendClientMessage(playerid, 0xFF0000FF, "[Error:] The valid number is only 0 and 1!");
}
if(license == MappingLicense[targetid][maplicense])
{
return SendClientMessage(playerid, 0xFF0000FF, "[Error:] That player already have a mapping license!");
}
if(license > MappingLicense[targetid][maplicense])
{
GetPlayerName(targetid, name, sizeof(name));
format(string, sizeof(string), "[MAP] You have given %s a mapping license!", name);
SendClientMessage(playerid, 0xFFFF00FF, string);
if(targetid != playerid)
{
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "[MAP] %s have given you a mapping license!", name);
SendClientMessage(targetid, 0xFFFF00FF, string);
}
MappingLicense[targetid][maplicense] = license;
}
else
{
GetPlayerName(targetid, name, sizeof(name));
format(string, sizeof(string), "[MAP] You have removed %s mapping license!", name);
SendClientMessage(playerid, 0xFFFF00FF, string);
if(targetid != playerid)
{
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "[MAP] %s have removed your mapping license!", name);
SendClientMessage(targetid, 0xFFFF00FF, string);
}
MappingLicense[targetid][maplicense] = license;
}
new INI:ini = INI_Open(UserMappingLicensePath(playerid));
INI_WriteInt(ini,"MapLicense", license);
INI_Close(ini);
}
else
{
return SendClientMessage(playerid, 0xFF0000FF, "[Error:] You are not logged in to RCON!");
}
return 1;
}
#include <a_samp>
#include <command_proccessor> // zcmd for me
#include <sscanf2>
public OnPlayerConnect(playerid) {
new path[64], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(path, 64, "maplicenses/%s", name);
if(fexist(path))
SetPVarInt(playerid, "mapping_license", 1);
else SetPVarInt(playerid, "mapping_license", 0);
return 1;
}
CMD:setmaplicense(playerid, params[]) {
if(IsPlayerAdmin(playerid)) {
new targetid, license;
if(!sscanf(params, "ui", targetid, license)) {
//always check for the first param first btw
if(IsPlayerConnected(targetid)) {
if((license == 1) || (license == 0)) {
if(license != GetPVarInt(targetid, "mapping_license")) {
new name[MAX_PLAYER_NAME], message[144], path[64];
GetPlayerName(targetid, name, MAX_PLAYER_NAME);
if(license == 0) {
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(path, 64, "maplicenses/%s", name);
if(fexist(path))
fremove(path);
format(message, 144, "[MAP] You have removed %s mapping license!", name);
SendClientMessage(playerid, 0xFFFF00FF, message);
if(targetid != playerid) {
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(message, 144, "[MAP] %s have removed your mapping license!", name);
SendClientMessage(targetid, 0xFFFF00FF, message);
}
SetPVarInt(targetid, "mapping_license", 0);
}
else {
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(path, 64, "maplicenses/%s", name);
if(!fexist(path)) {
new File:file = fopen(path, io_write);
fclose(file);
}
format(message, 144, "[MAP] You have given %s a mapping license!", name);
SendClientMessage(playerid, 0xFFFF00FF, message);
if(targetid != playerid) {
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(message, 144, "[MAP] %s have given you a mapping license!", name);
SendClientMessage(targetid, 0xFFFF00FF, message);
}
SetPVarInt(targetid, "mapping_license", 1);
}
}
else SendClientMessage(playerid, 0xFF0000FF, "[Error:] That player already have their mapping license set at that!");
}
else SendClientMessage(playerid, 0xFF0000FF, "[Error:] The valid number is only 0 and 1!");
}
else SendClientMessage(playerid, 0xFF0000FF, "[Error:] That player is not connected!");
}
else SendClientMessage(playerid, 0xFF0000FF, "[Error:] /givemaplicense <id> <0 - 1>");
}
else SendClientMessage(playerid, 0xFF0000FF, "[Error:] You are not logged in to RCON!");
return 1;
}
if(GetPVarInt(targetid, "mapping_license") == 1) { }
PHP Code:
To check if he's got a map license simply type: PHP Code:
|
So, if I use your method will it fix my problem or you just showing me the simple way to do this?
![]() |
If it\'s sporadic, then it could be something else interfering with it.
|