All pastes #394111 Raw Edit

Someone

public text v1 · immutable
·published 2007-03-14 01:58 UTC
rendered paste body
	//------------------- /stats
	
	if(strcmp(cmd, "/stats", true) == 0) {
		new tmp[256];
		tmp = strtok(cmdtext, idx);
		if(!strlen(tmp)) {
		    if(IsLoggedIn(playerid)) {
  				new die = gPlayerStats[playerid][1], kill = gPlayerStats[playerid][0];
  				new name[24];
  				GetPlayerName(playerid,name,sizeof(name));
  				format(string,sizeof(string),"*** %s has: %d Kills - %d Deaths - Ratio: %s",name,kill,die, GetRatio(kill,die));
  				SendClientMessage(playerid,COLOR_MEBLUE,string);
  				if(gPlayerStats[playerid][2] == 1) {
  					SendClientMessage(playerid,COLOR_MEBLUE,"*** Your Stats are disabled");
				}
  				return 1;
			}
			else {
				SendClientMessage(playerid,COLOR_MEBLUE,"** Please login to access your stats");
  				return 1;
			}
		}
		else {
			new buffer[256], xkill[24], xdie[24], kill, die, id;
			
			if(IsNumeric(tmp) && IsPlayerConnected(strval(tmp))) {
			    if(strval(tmp) == playerid) {
					SendClientMessage(playerid,COLOR_MEBLUE,"** Please use /stats to view your own stats");
  					return 1;
				}
			    id = strval(tmp);
  				die = gPlayerStats[id][1], kill = gPlayerStats[id][0];
				format(string,sizeof(string),"*** %s has: %d Kills - %d Deaths - Ratio: %s",GetName(id),kill,die, GetRatio(kill,die));
  				SendClientMessage(playerid,COLOR_MEBLUE,string);
  				return 1;
			}
			
			for(new x=0; x<MAX_PLAYERS; x++) {
			    if(IsPlayerConnected(x)) {
     				if(strcmp(tmp,GetName(x),true) == 0) {
						if(strcmp(tmp,GetName(playerid),true) == 0) {
							SendClientMessage(playerid,COLOR_MEBLUE,"** Please use /stats to view your own stats");
  							return 1;
						}
     					die = gPlayerStats[x][1], kill = gPlayerStats[x][0];
						format(string,sizeof(string),"*** %s has: %d Kills - %d Deaths - Ratio: %s",tmp,kill,die, GetRatio(kill,die));
  						SendClientMessage(playerid,COLOR_MEBLUE,string);
  						return 1;
					}
				}
			}

			if(fexist(encode(tmp))) {
				if(strcmp(tmp,GetName(playerid),true) == 0) {
					SendClientMessage(playerid,COLOR_MEBLUE,"** Please use /stats to view your own stats");
  					return 1;
				}
				new File:stats = fopen(encode(tmp),io_read);
				while(fread(stats, buffer, sizeof(buffer), false)) {
	    			new index2 = 0;
					xkill = strtok(buffer,index2);
					xdie = strtok(buffer,index2);
					kill = strval(xkill);
					die = strval(xdie);

 					format(string,sizeof(string),"*** %s has: %d Kills - %d Deaths - Ratio: %s",tmp,kill,die, GetRatio(kill,die));
  					SendClientMessage(playerid,COLOR_MEBLUE,string);
				}
			}
			else {
			    SendClientMessage(playerid,COLOR_YELLOW,"ERROR: Player not found (Case sensitive)");
			}
		}
		return 1;
	}