/ocheck
#1

Hi,

would anyone know how should I make an /ocheck command in ZCMD? It will actually show player's statistics when he/she is offline. It'll work for an admin level 2+.

The /check command;
Код:
IRP:check(playerid, var[])
{
    new user;
   	if(!Logged(playerid)) return NoLogin(playerid);
	if(Player[playerid][pAdmin] >= 2 || Player[playerid][pStaffObserver])
	{
      	if(sscanf(var,"us[32]", user, var))
    	{
    	    SendClientMessage(playerid, COLOR_WHITE, "{00BFFF}Usage:{FFFFFF} /check [playerid] [checks]");
    	    SendClientMessage(playerid, COLOR_GRAD2, "** [CHECKS]: stats");
    	    return 1;
    	}
    	if(!strcmp(var, "stats", true))
    	{
            if(!Logged(user)) return NoLoginB(playerid);
        	ShowStats(playerid, user);
        }
    }
    else
	{
		NoAuth(playerid);
	}
	return 1;
}
And the stock ShowStats
Код:
stock ShowStats(playerid, user)
{
	new string[256], gender[8], admin[15], famed[12], helper[12], vip[12], ogate1[8], ogate2[8], gate3[8], beta[12];
	// Gender
	if(Player[user][pGender] == 1) format(gender, sizeof(gender), "Male");
	else if(Player[user][pGender] == 2) format(gender, sizeof(gender), "Female");
	// Helper
	if(Player[user][pHelper]) format(helper, sizeof(helper), "{00FF00}Yes");
	else if(!Player[user][pHelper]) format(helper, sizeof(helper), "{00FF00}No");
	// Famed
	if(Player[user][pFamed]) format(famed, sizeof(famed), "{FF9900}Yes");
	else if(!Player[user][pFamed]) format(famed, sizeof(famed), "{FF9900}No");
	// VIP
	if(Player[user][pVIP]) format(vip, sizeof(vip), "{C93CCE}Yes");
	else if(!Player[user][pVIP]) format(vip, sizeof(vip), "{C93CCE}No");
	// Beta Tester
	if(Player[user][pTester]) format(beta, sizeof(beta), "{FFFF00}Yes");
	else if(!Player[user][pTester]) format(beta, sizeof(beta), "{FFFF00}No");
	// Admin
	if(Player[user][pAdmin]) format(admin, sizeof(admin), "{FFFF00}Yes");
	else if(!Player[user][pAdmin]) format(admin, sizeof(admin), "{FFFF00}No");
	// Gates
	if(Player[user][pGate][0]) format(ogate1, sizeof(ogate1), "Yes");
	else if(!Player[user][pGate][0]) format(ogate1, sizeof(ogate1), "None");
	if(Player[user][pGate][1]) format(ogate2, sizeof(ogate2), "Yes");
	else if(!Player[user][pGate][1]) format(ogate2, sizeof(ogate2), "None");
	if(Player[user][pGate][2]) format(gate3, sizeof(gate3), "Yes");
	else if(!Player[user][pGate][2]) format(gate3, sizeof(gate3), "None");
	// Respect points and next level
	new exp = Player[user][pExp];
	new nxtlevel = Player[user][pLevel]+1;
	new expamount = nxtlevel*4;
	new costlevel = nxtlevel*2000;

	//Showing Stats
	format(string, sizeof(string), "[Account] {BFC0C2}Name: [%s] Level: [%d] Gender: [%s] Age: [%d] Respects: [%d/%d -(%d)]", GetName(user), Player[user][pLevel], gender, Player[user][pAge], exp, expamount, costlevel);
	SendClientMessage(playerid, COLOR_STATS, string);
	format(string, sizeof(string), "[Details] {BFC0C2}Money: [$%d] Bank: [$%d] Job: [%s] Phone No. [%s]", Player[user][pMoney], Player[user][pBank], RPJN(user), Player[user][pPhone], Player[user][pWTC]);
	SendClientMessage(playerid, COLOR_STATS, string);
	format(string, sizeof(string), "[Records] {BFC0C2}Wanted: [%d] Crimes: [%d] Arrested: [%dx]", Player[user][pWanted], Player[user][pCrimes], Player[user][pArrested]);
	SendClientMessage(playerid, COLOR_STATS, string);
	format(string, sizeof(string), "[Affiliation] {BFC0C2}Faction: [%s]  Rank: [%s]  Division: [%s] || Family: [%s]  Rank: [%s]", RPFN(user), RPFRN(user), RPFDN(user), RPFaN(user), RPFaRN(user));
	SendClientMessage(playerid, COLOR_STATS, string);
	format(string, sizeof(string), "[Status] {BFC0C2}Admin: [%s{FFFFFF}] Helper: [%s{FFFFFF}] Famed: [%s{FFFFFF}] VIP: [%s{FFFFFF}] Beta Tester: [%s{FFFFFF}]", admin, helper, famed, vip, beta);
	SendClientMessage(playerid, COLOR_STATS, string);
	format(string, sizeof(string), "[Property] {BFC0C2}Gate 1: [%s] Gate 2: [%s] Gate 3: [%s] Garage: 1[%s - (ID:%s)] - 2[%s - (ID:%s)]", ogate1, ogate2, gate3, GT(Player[user][pGarage]), RPGK(user), GT(Player[user][pVGarage]), RPVIPGK(user));
	SendClientMessage(playerid, COLOR_STATS, string);
	format(string, sizeof(string), "[Property] {BFC0C2}Vehicles: 1[%s (ID:%d)] - 2[%s (ID:%d)] - 3[%s (ID:%d)] - 4[%s (ID:%d)]", RVN(GetVehicleModel(Player[user][pVeh])), Player[user][pVeh], RVN(GetVehicleModel(Player[user][pVVeh])), Player[user][pVVeh], RVN(GetVehicleModel(Player[user][pVVVeh])), Player[user][pVVVeh], RVN(GetVehicleModel(Player[user][pVVVVeh])), Player[user][pVVVVeh]);
	SendClientMessage(playerid, COLOR_STATS, string);
	format(string, sizeof(string), "[Property] {BFC0C2}Business: 1[%s (ID:%s)] - 2[%s (ID:%s)] House: 1[%s (ID:%s)] - 2[%s (ID:%s)]", RBT(Player[user][pBiz]), RPBK(user), RBT(Player[user][pVBiz]), RPVIPBK(user), HT(Player[user][pHouse]), RPHK(user), HT(Player[user][pVHouse]), RPVIPHK(user));
	SendClientMessage(playerid, COLOR_STATS, string);
	format(string, sizeof(string), "[Items] {BFC0C2}Weed:[%d] Seed: [%d] Cocaine:[%d] Cigars:[%d] Sprunk:[%d] Spraycan:[%d]", Player[user][pWeed], Player[user][pSeeds], Player[user][pCocaine], Player[user][pCigar], Player[user][pSprunk], Player[user][pSpray]);
	SendClientMessage(playerid, COLOR_STATS, string);
	format(string, sizeof(string), "[Items] {BFC0C2}Cookies: [%d] Low-Materials: [%d] Medium-Materials: [%d] High-Materials: [%d]", Player[user][pCookie], Player[user][pLMaterials], Player[user][pMMaterials], Player[user][pHMaterials]);
	SendClientMessage(playerid, COLOR_STATS, string);
	format(string, sizeof(string), "[Items] {BFC0C2}Gas Can:[%d litres] Ropes:[%d] Blindfolds:[%d]", Player[user][pGas], Player[user][pRope], Player[user][pBlindfold]);
	SendClientMessage(playerid, COLOR_STATS, string);
	return 1;
}
It's not hard, but I'd appreciate because I don't know how would I use stock ShowStats when a player is offline.

~Kevin

Thanks in advance.

P.S.: Saving system is Dini.
Reply
#2

This is really urgent. Please.
Reply
#3

You should have used SQLite for better and easy saving system. I'm not good at dini but you should open the player's file first and then extract all the informations.
Reply
#4

Could you give me steps because I don't understand how do I do that. If you don't knoe dini good, can you ****** it to see how would you open a file with it and then tell me how?

P.S.: How much time would it need to convert 40k lines to SQLite?
Reply
#5

Quote:
Originally Posted by KevinExec
Посмотреть сообщение
Could you give me steps because I don't understand how do I do that. If you don't knoe dini good, can you ****** it to see how would you open a file with it and then tell me how?

P.S.: How much time would it need to convert 40k lines to SQLite?
It would take you like 10 days to convert it but if you are an expert in SQLite, maybe 4 days. Even you can ****** it.
Reply
#6

Yes but I don't understand it.
Reply
#7

Just open the player's file in scriptfiles (using code obviously...), read its data and display it on a dialog or in messages.
Reply
#8

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
Just open the player's file in scriptfiles (using code obviously...), read its data and display it on a dialog or in messages.
How many times will I have to ask "HOW?"
Reply
#9

The best attempt would be to use you existing code
You load the data from the file into an unused PlayerInfo cell and call ShowStats with the cell
The loading code should be somewhere in your login system, extract that into a function so you can call it individually

Example
PHP код:
IRP:check(playerid, var[])
{
    if(!
Logged(playerid)) {
        return 
NoLogin(playerid);
    if(
Player[playerid][pAdmin] < && Player[playerid][pStaffObserver]) {
        return 
NoAuth(playerid);
    }
    new
        
name[MAX_PLAYER_NAME]
    ;
    if(
sscanf(var,"s[24]s[128]"name, var)) {
        
SendClientMessage(playeridCOLOR_WHITE"{00BFFF}Usage:{FFFFFF} /check [name] [checks]");
        return 
SendClientMessage(playeridCOLOR_GRAD2"** [CHECKS]: stats");
    }
    if(!
strcmp(var, "stats"true)) {
        new
            
user
        
;
        
sscanf(name"u"user);
         
// not connected or not logged
        
if(user == INVALID_PLAYER_ID || !Logged(user)) {
            
user sizeof PlayerInfo 1// last cell - probably unused
            
if(IsPlayerConnected(user)) { // to be sure check if the player is connected
                
return SendClientMessage(playeridCOLOR_GRAD2"** Command unavailable at the moment :p");
            } 
// to avoid the IsPlayerConnect check /\ increase PlayerInfo by 1
            // (new PlayerInfo[MAX_PLAYERS + 1][pInfo])
            
if(!LoadPlayerInfo(username)) { // loading function which normally gets called after login
                
return SendClientMessage(playeridCOLOR_GRAD2"** Playername not found!");
            } 
// if the loading failed to due an invalid playername /\
        
}
        
ShowStats(playeriduser);
    }
    return 
true;

Reply
#10

Quote:
Originally Posted by Nero_3D
Посмотреть сообщение
The best attempt would be to use you existing code
You load the data from the file into an unused PlayerInfo cell and call ShowStats with the cell
The loading code should be somewhere in your login system, extract that into a function so you can call it individually

Example
PHP код:
IRP:check(playerid, var[])
{
    if(!
Logged(playerid)) {
        return 
NoLogin(playerid);
    if(
Player[playerid][pAdmin] < && Player[playerid][pStaffObserver]) {
        return 
NoAuth(playerid);
    }
    new
        
name[MAX_PLAYER_NAME]
    ;
    if(
sscanf(var,"s[24]s[128]"name, var)) {
        
SendClientMessage(playeridCOLOR_WHITE"{00BFFF}Usage:{FFFFFF} /check [name] [checks]");
        return 
SendClientMessage(playeridCOLOR_GRAD2"** [CHECKS]: stats");
    }
    if(!
strcmp(var, "stats"true)) {
        new
            
user
        
;
        
sscanf(name"u"user);
         
// not connected or not logged
        
if(user == INVALID_PLAYER_ID || !Logged(user)) {
            
user sizeof PlayerInfo 1// last cell - probably unused
            
if(IsPlayerConnected(user)) { // to be sure check if the player is connected
                
return SendClientMessage(playeridCOLOR_GRAD2"** Command unavailable at the moment :p");
            } 
// to avoid the IsPlayerConnect check /\ increase PlayerInfo by 1
            // (new PlayerInfo[MAX_PLAYERS + 1][pInfo])
            
if(!LoadPlayerInfo(username)) { // loading function which normally gets called after login
                
return SendClientMessage(playeridCOLOR_GRAD2"** Playername not found!");
            } 
// if the loading failed to due an invalid playername /\
        
}
        
ShowStats(playeriduser);
    }
    return 
true;

Thanks, I'll see if it Works.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)