SA-MP Forums Archive
only works for id 0 - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: only works for id 0 (/showthread.php?tid=109857)



only works for id 0 - [HKS]dlegend - 22.11.2009

only seems to work for one id 0 not sure y
Код:
irccmd_plinfo(conn, channel[], user[], params[])
{
	#pragma unused conn , params , user 
	if(!IsPlayerOp(conn,channel,user)) return AccessDenied(user);
	new string[284];
	new player1;
	new playerid;
	if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID) {
	  new Float:player1health, Float:player1armour, playerip[128], Float:x, Float:y, Float:z;

		GetPlayerHealth(player1,player1health);
		GetPlayerArmour(player1,player1armour);
  	GetPlayerIp(player1, playerip, sizeof(playerip));
  	GetPlayerPos(player1,x,y,z);

 		format(string, sizeof(string),"7,4(Player Info) ---====> Name: %s ID: %d <====---", PlayerName(player1), player1);
		IRC_GroupSay(GroupID[0], channel, string);
	 	format(string, sizeof(string),"7,4Health: %d Armour: %d | Score: %d | Cash: %d | Skin: %d | IP: %s | Ping: %d | ",floatround(player1health),floatround(player1armour),
		GetPlayerScore(player1),GetPlayerMoney(player1),GetPlayerSkin(player1),playerip,GetPlayerPing(player1));
		IRC_GroupSay(GroupID[0], channel, string);
		format(string, sizeof(string),"7,4Interior: %d | Virtual World: %d | Wanted Level: %d X %0.1f Y %0.1f Z %0.1f", GetPlayerInterior(player1), GetPlayerVirtualWorld(player1), GetPlayerWantedLevel(player1), Float:x,Float:y,Float:z);
	 	IRC_GroupSay(GroupID[0], channel, string);

		if(IsPlayerInAnyVehicle(player1)) {
			new Float:VHealth, carid = GetPlayerVehicleID(playerid); GetVehicleHealth(carid,VHealth);
			format(string, sizeof(string),"7,4VehicleID: %d | Model: %d | Vehicle Name: %s | Vehicle Health: %d",carid, GetVehicleModel(carid), VehicleNames[GetVehicleModel(carid)-400], floatround(VHealth) );
			IRC_GroupSay(GroupID[0], channel, string);
		}

		new slot, ammo, weap, Count1, WeapName[24], WeapSTR[128], p; WeapSTR = "7,4Weaps: ";
		for (slot = 0; slot < 14; slot++) {	GetPlayerWeaponData(player1, slot, weap, ammo); if( ammo != 0 && weap != 0) Count1++; }
		if(Count1 < 1) return IRC_GroupSay(GroupID[0], channel, "7,4Player has no weapons");
		else {
			for (slot = 0; slot < 14; slot++)
			{
				GetPlayerWeaponData(player1, slot, weap, ammo);
				if (ammo > 0 && weap > 0)
				{
					GetWeaponName(weap, WeapName, sizeof(WeapName) );
					if (ammo == 65535 || ammo == 1) format(WeapSTR,sizeof(WeapSTR),"7,4%s%s (1)",WeapSTR, WeapName);
					else format(WeapSTR,sizeof(WeapSTR),"7,4%s|%s (%d)",WeapSTR, WeapName, ammo);
					p++;
 					if(p >= 5) { SendClientMessage(playerid, lightblue, WeapSTR); format(WeapSTR, sizeof(WeapSTR), "7,4Weaps: "); p = 0;
					} else format(WeapSTR, sizeof(WeapSTR), "7,4%s, ", WeapSTR);
				}
			}
			if(p <= 4 && p > 0) {
				string[strlen(string)-3] = '.';
  			IRC_GroupSay(GroupID[0], channel, WeapSTR);
			}
			return 0;
		}
	} else return IRC_GroupSay(conn, channel,"7,4Sorry please enter a vaild id,");
}



Re: only works for id 0 - dice7 - 22.11.2009

player1 and playerid will always be 0. You need a split function like sscanf to separate the playerid from the input command string


Re: only works for id 0 - [HKS]dlegend - 22.11.2009

and i split it how cuz i have a few cmds like this for irc

thanks for the help


Re: only works for id 0 - [HKS]dlegend - 22.11.2009

bump i beleave it is 12 hours please help i have spent most of my time on this


Re: only works for id 0 - Zeromanster - 22.11.2009

Quote:
Originally Posted by dlegend
bump i beleave it is 12 hours please help i have spent most of my time on this
It's only 5 hours passed...


Re: only works for id 0 - kukars22 - 23.11.2009

new player1 [MAX_PLAYERS];


Re: only works for id 0 - [HKS]dlegend - 23.11.2009

thanks and my laptop clock is wrong sorry


Re: only works for id 0 - Outbreak - 23.11.2009

Quote:
Originally Posted by zєяσмαиѕтєя
Quote:
Originally Posted by dlegend
bump i beleave it is 12 hours please help i have spent most of my time on this
It's only 5 hours passed...
Nerd if you're gonna post, post something useful.. Quit going on a post count boosting mission..


You didnt define what playerid is.

What i mean is... if you use sscanf you'd write it like this.

pawn Код:
irccmd_plinfo(conn, channel[], user[], params[])
{
   #pragma unused conn , params , user
   if(!IsPlayerOp(conn,channel,user)) return AccessDenied(user);
   new string[284];
   new playerid;
   
   if(sscanf(params, "i", playerid))
     return IRC_GroupSay(GroupID[0], channel, "USAGE: !plinfo [playerid]");
Basically that means, playerid is defined as the integer you input after !plinfo

So after the code above, you would also need to do checks like if(!IsPlayerConnected(playerid)) then do a return message for that.

As dice7 said, playerid will be 0. The reason for that is when an array is created its automatically given the value 0.

So you must define what exactly it will be used as, in order for it to work correctly.