Server update: 0.3a R8
#2

Some handy utils functions for dealing with lists of PVars:

Code:
//-------------------------------------------
// Sends a list of all PVars to the player as
// client messages.

SendPVarListToPlayer(playerid)
{
  new ubound = GetPVarsUpperIndex(playerid);
	new x=0;
	new name[40+1];
	new line[128+1];
	
  SendClientMessage(playerid,0xF000F0F0, "---Player Vars List---");
	while(x != ubound) {
		if(GetPVarNameAtIndex(playerid,x,name,40)) {
			if(Util_GetPVarEntryAsString(playerid,name,line,128)) {
         SendClientMessage(playerid,0xFFFFFFFF,line);
			}
		}
		x++;
	}
}

//-------------------------------------------
// return PVar entry as 'name'='value' string

stock Util_GetPVarEntryAsString(playerid, name[], ret[], len)
{
	new Float:fValue;
	new iValue;
	new szStrValue[1024+1]; // this might require greater size if you store large strings in PVars
	new type;
  ret[0] = EOS;
  
 	type = GetPVarType(playerid, name);
	if(type != PLAYER_VARTYPE_NONE) {
		switch(type)
		{
			case PLAYER_VARTYPE_STRING:
			{
				GetPVarString(playerid,name,szStrValue,1024);
				format(ret,len,"%s=%s",name,szStrValue);
			}
			case PLAYER_VARTYPE_INT:
			{
				iValue = GetPVarInt(playerid,name);
				format(ret,len,"%s=%d",name,iValue);
			}
			case PLAYER_VARTYPE_FLOAT:
			{
			  fValue = GetPVarFloat(playerid,name);
				format(ret,len,"%s=%f",name,fValue);
			}
		}
		return 1;
	}
	return 0;
}

//-------------------------------------------
// Fills the provided string with all the player's PVars
// seperated by the specified 'delimiter'

stock Util_CreatePVarList(playerid, retstr[], len, delimiter[])
{
	if(!IsPlayerConnected(playerid)) return 0;
	
	new x=0;
	new remaining_string=len;
	new line[2048+1];
	new name[40+1];
	retstr[0] = EOS;

	new ubound = GetPVarsUpperIndex(playerid);
	
	while(x != ubound) {
		if(GetPVarNameAtIndex(playerid,x,name,40)) {
			if(Util_GetPVarEntryAsString(playerid,name,line,2048)) {
				// if there is enough space, concat this line to the return string
				if(remaining_string > (strlen(line) + strlen(delimiter))) {
			  	strcat(retstr,line);
			  	strcat(retstr,delimiter);
					remaining_string -= (strlen(line) + strlen(delimiter));
				}
			}
		}
		x++;
	}
	
	return 1;
}

//-------------------------------------------
Reply


Messages In This Thread
Server update: 0.3a R8 - by Kalcor - 24.03.2010, 01:11
Re: Server update: 0.3a R5 - by Kalcor - 24.03.2010, 01:25
Re: Server update: 0.3a R5 - by Woet - 24.03.2010, 01:27
Re: Server update: 0.3a R5 - by Carlton - 24.03.2010, 01:31
Re: Server update: 0.3a R5 - by niCe - 24.03.2010, 01:35
Re: Server update: 0.3a R5 - by Bob_Mars - 24.03.2010, 01:45
Re: Server update: 0.3a R5 - by Hijolion - 24.03.2010, 01:50
Re: Server update: 0.3a R5 - by DaRkDeViiL - 24.03.2010, 01:54
Re: Server update: 0.3a R5 - by CJ101 - 24.03.2010, 01:57
Re: Server update: 0.3a R5 - by gotenks918 - 24.03.2010, 02:05
Re: Server update: 0.3a R5 - by Tannz0rz - 24.03.2010, 02:07
Re: Server update: 0.3a R5 - by Kalcor - 24.03.2010, 02:08
Re: Server update: 0.3a R5 - by Mr187 - 24.03.2010, 02:14
Re: Server update: 0.3a R5 - by Woet - 24.03.2010, 02:30
Re: Server update: 0.3a R5 - by Matite - 24.03.2010, 02:31
Re: Server update: 0.3a R5 - by [Saint] - 24.03.2010, 02:36
Re: Server update: 0.3a R5 - by Aygem - 24.03.2010, 02:38
Re: Server update: 0.3a R5 - by shady91 - 24.03.2010, 02:42
Re: Server update: 0.3a R5 - by Mr187 - 24.03.2010, 02:47
Re: Server update: 0.3a R5 - by cyber_punk - 24.03.2010, 02:47
Re: Server update: 0.3a R5 - by CracK - 24.03.2010, 03:34
Re: Server update: 0.3a R5 - by deather - 24.03.2010, 03:37
Re: Server update: 0.3a R5 - by Norn - 24.03.2010, 03:51
Re: Server update: 0.3a R5 - by FujiNNN - 24.03.2010, 04:28
Re: Server update: 0.3a R5 - by Tenshi - 24.03.2010, 04:52
Re: Server update: 0.3a R5 - by Calgon - 24.03.2010, 05:02
Re: Server update: 0.3a R5 - by CracK - 24.03.2010, 05:35
Re: Server update: 0.3a R5 - by Calgon - 24.03.2010, 05:40
Re: Server update: 0.3a R5 - by Finn - 24.03.2010, 05:42
Re: Server update: 0.3a R5 - by CracK - 24.03.2010, 06:03
Re: Server update: 0.3a R5 - by DarkPower - 24.03.2010, 22:34
Re: Server update: 0.3a R5 - by Chaprnks - 24.03.2010, 23:01
Re: Server update: 0.3a R5 - by ruarai - 24.03.2010, 23:08
Re: Server update: 0.3a R5 - by MX_Master - 25.03.2010, 03:50
Re: Server update: 0.3a R5 - by Simon - 25.03.2010, 08:04
Re: Server update: 0.3a R5 - by Whitetiger - 25.03.2010, 09:25
Re: Server update: 0.3a R5 - by Brian_Furios - 25.03.2010, 13:05
Re: Server update: 0.3a R5 - by Correlli - 25.03.2010, 13:18
Re: Server update: 0.3a R5 - by Brian_Furios - 25.03.2010, 13:35
Re: Server update: 0.3a R5 - by Vandooz - 25.03.2010, 14:09
Re: Server update: 0.3a R5 - by Maccer - 26.03.2010, 21:35
Re: Server update: 0.3a R5 - by Maccer - 26.03.2010, 21:48
Re: Server update: 0.3a R5 - by Sergei - 26.03.2010, 22:27
Re: Server update: 0.3a R5 - by Kalcor - 26.03.2010, 22:28
Re: Server update: 0.3a R5 - by Correlli - 26.03.2010, 22:30
Re: Server update: 0.3a R5 - by Extremo - 27.03.2010, 01:30
Re: Server update: 0.3a R6 - by whooper - 27.03.2010, 02:35
Re: Server update: 0.3a R6 - by Simon - 27.03.2010, 02:45
Re: Server update: 0.3a R6 - by Whitetiger - 27.03.2010, 02:59
Re: Server update: 0.3a R6 - by CC. - 27.03.2010, 04:14
Re: Server update: 0.3a R7 - by Maccer - 28.03.2010, 13:05
Re: Server update: 0.3a R7 - by Correlli - 28.03.2010, 13:06
Re: Server update: 0.3a R7 - by IDownload - 28.03.2010, 13:06
Re: Server update: 0.3a R7 - by Geso - 28.03.2010, 13:08
Re: Server update: 0.3a R7 - by Correlli - 28.03.2010, 13:12
Re: Server update: 0.3a R7 - by Kalcor - 28.03.2010, 13:16
Re: Server update: 0.3a R7 - by Geso - 28.03.2010, 13:19
Re: Server update: 0.3a R7 - by xcasio - 28.03.2010, 14:24
Re: Server update: 0.3a R7 - by Sergei - 28.03.2010, 14:53
Re: Server update: 0.3a R7 - by Dark_Kostas - 28.03.2010, 16:06
Re: Server update: 0.3a R7 - by Spik3 - 28.03.2010, 23:18
Re: Server update: 0.3a R7 - by Sim00n - 29.03.2010, 03:12
Re: Server update: 0.3a R7 - by MPKaboose - 29.03.2010, 12:59
Re: Server update: 0.3a R7 - by BeckzyBoi - 29.03.2010, 13:38
Re: Server update: 0.3a R7 - by Mikep. - 29.03.2010, 13:43
Re: Server update: 0.3a R7 - by xenowort - 29.03.2010, 16:57
Re: Server update: 0.3a R7 - by Sim00n - 29.03.2010, 21:33
Re: Server update: 0.3a R7 - by damianxb - 29.03.2010, 21:52
Re: Server update: 0.3a R7 - by Mikep. - 30.03.2010, 00:18
Re: Server update: 0.3a R7 - by yezizhu - 30.03.2010, 01:23
Re: Server update: 0.3a R7 - by ev0lution - 30.03.2010, 01:48
Re: Server update: 0.3a R7 - by Google63 - 30.03.2010, 08:30
Re: Server update: 0.3a R7 - by Panoulis - 30.03.2010, 10:35
Re: Server update: 0.3a R7 - by bajskorv123 - 31.03.2010, 17:28
Re: Server update: 0.3a R7 - by Correlli - 31.03.2010, 17:47
Re: Server update: 0.3a R7 - by wafffllesss - 31.03.2010, 17:49
Re: Server update: 0.3a R7 - by Krozz - 02.04.2010, 15:43
Re: Server update: 0.3a R7 - by Mikep. - 02.04.2010, 15:51
Re: Server update: 0.3a R7 - by Zlayer - 02.04.2010, 20:33
Re: Server update: 0.3a R7 - by Krozz - 02.04.2010, 23:53
Re: Server update: 0.3a R7 - by [03]Garsino - 02.04.2010, 23:55
Re: Server update: 0.3a R7 - by XGh0stz - 03.04.2010, 02:06
Re: Server update: 0.3a R7 - by Toribio - 03.04.2010, 06:21
Re: Server update: 0.3a R7 - by XGh0stz - 03.04.2010, 08:25
Re: Server update: 0.3a R7 - by oggylt - 06.04.2010, 13:06
Re: Server update: 0.3a R7 - by pspleo - 06.04.2010, 13:37
Re: Server update: 0.3a R7 - by XGh0stz - 06.04.2010, 17:29
Re: Server update: 0.3a R7 - by Tannz0rz - 06.04.2010, 17:33
Re: Server update: 0.3a R7 - by oggylt - 07.04.2010, 14:43
Re: Server update: 0.3a R7 - by XGh0stz - 07.04.2010, 15:43
Re: Server update: 0.3a R7 - by oggylt - 07.04.2010, 16:20
Re: Server update: 0.3a R7 - by XGh0stz - 11.04.2010, 06:10
Re: Server update: 0.3a R7 - by biltong - 11.04.2010, 10:47
Re: Server update: 0.3a R7 - by Dark_Kostas - 11.04.2010, 15:37
Re: Server update: 0.3a R7 - by Joe Staff - 11.04.2010, 16:32
Re: Server update: 0.3a R7 - by XGh0stz - 11.04.2010, 19:00
Re: Server update: 0.3a R7 - by [03]Garsino - 11.04.2010, 19:05
Re: Server update: 0.3a R7 - by biltong - 12.04.2010, 16:34
Re: Server update: 0.3a R7 - by shady91 - 12.04.2010, 16:39
Re: Server update: 0.3a R7 - by [JIeXa] - 13.04.2010, 14:15
Re: Server update: 0.3a R8 - by [03]Garsino - 22.06.2010, 14:40
Re: Server update: 0.3a R8 - by matthewdriftking - 22.06.2010, 14:51
Re: Server update: 0.3a R8 - by [03]Garsino - 22.06.2010, 14:55
Re: Server update: 0.3a R8 - by Panorama_ - 22.06.2010, 15:11
Re: Server update: 0.3a R8 - by Correlli - 22.06.2010, 15:35
Re: Server update: 0.3a R8 - by Littl3j0hNy - 22.06.2010, 15:40
Re: Server update: 0.3a R8 - by Pawno_Scripter - 22.06.2010, 17:18
Re: Server update: 0.3a R8 - by OKStyle - 22.06.2010, 18:13
Re: Server update: 0.3a R8 - by Trooper[Y] - 22.06.2010, 19:07
Re: Server update: 0.3a R8 - by Kar - 22.06.2010, 22:00
Re: Server update: 0.3a R8 - by Scenario - 23.06.2010, 01:40
Re: Server update: 0.3a R8 - by W00Z - 23.06.2010, 12:18
Re: Server update: 0.3a R8 - by Calgon - 24.06.2010, 03:32
Re: Server update: 0.3a R8 - by Killa[DGZ] - 24.06.2010, 11:36
Re: Server update: 0.3a R8 - by HydraX - 05.07.2010, 20:47
Re: Server update: 0.3a R8 - by Calgon - 05.07.2010, 20:53
Re: Server update: 0.3a R8 - by HydraX - 05.07.2010, 21:28
Re: Server update: 0.3a R8 - by TheGuardianAngel - 22.07.2010, 14:11
Re: Server update: 0.3a R8 - by Maggi - 25.07.2010, 16:31
Re: Server update: 0.3a R8 - by ikey07 - 30.07.2010, 09:18
Re: Server update: 0.3a R8 - by GaGlets(R) - 30.07.2010, 19:53
Re: Server update: 0.3a R8 - by jiggy89 - 09.08.2010, 19:04
Re: Server update: 0.3a R8 - by [NoV]LaZ - 09.08.2010, 19:56
Re: Server update: 0.3a R8 - by gamer931215 - 11.08.2010, 08:55
Re: Server update: 0.3a R8 - by Kwarde - 31.10.2010, 15:12
Re: Server update: 0.3a R8 - by bigcomfycouch - 31.10.2010, 15:36

Forum Jump:


Users browsing this thread: 1 Guest(s)