27.09.2015, 18:46
Hi, today I release a simple include made completely by me that add new spec functions, so you have more information about this mode.
Functions:
IsPlayerSpectating(playerid)
Checks if the player is spectating or not
Parameters:
playerid = The ID of the player who determine if is spectating
Return:
-1 if playerid is not connected, 0 if is not spectating, 1 if do it
IsPlayerSpectatingAnyPlayer(playerid)
Checks if the player is spectating to any player
Parameters:
playerid = The ID of the player who determine if is spectating
Return:
-1 if playerid is not connected, 0 if is not spectating to a player, 1 if do it
IsPlayerSpectatingPlayer(playerid,targetplayerid)
Checks if the player is spectating to a specific player
Parameters:
playerid = The ID of the player who determine if is spectating
targetplayerid = The ID of the player to check if is spectated
Return:
-1 if playerid or targetplayerid is not connected, 0 if playerid is not spectating to targetplayerid, 1 if do it
IsPlayerSpectatingAnyVehicle(playerid)
Checks if the player is spectating to any vehicle
Parameters:
playerid = The ID of the player who determine if is spectating
Return:
-1 if playerid is not connected, 0 if is not spectating to a vehicle, 1 if do it
IsPlayerSpectatingVehicle(playerid,targetvehicleid )
Checks if the player is spectating to a specific vehicle
Parameters:
playerid = The ID of the player who determine if is spectating
targetvehicleid = The ID of the vehicle to check if is spectated
Return:
-1 if playerid is not connectado or if targetvehicleid is invalid, 0 if playerid is not spectating to targetvehicleid, 1 if do it
GetPlayerSpectatedByPlayer(playerid)
Gets the player who is being spectated by the indicated player
Parameters:
playerid = The ID of the player who is spectating
Return:
The ID of the player spectated, INVALID_PLAYER_ID if playerid is not spectating or is spectating to a invalid player
GetVehicleSpectatedByPlayer(playerid)
Gets the vehicle that it is being spectated by the indicated player
Parameters:
playerid = The ID of the player who is spectating
Return:
The ID of the vehicle spectated, INVALID_VEHICLE_ID if playerid is not spectating or is spectating to a invalid vehicle
GetPlayersSpectatingPlayerCount(playerid)
Gets the count of players who are spectating to the indicated player
Parameters:
playerid = The ID of the player spectated
Return:
The count of players spectating to playerid, -1 if playerid is not connected
GetPlayersSpectatingVehicleCount(vehicleid)
Gets the count of players who are spectating to the indicated vehicle
Parameters:
vehicleid = The ID of the vehicle spectated
Return:
The count of players spectating to vehicleid, -1 if vehicleid is a invalid vehicle
Examples of use:
Download:
Mediafire
Credits:
losrivarola98 (Creator of the include)
Kalcor (Creator of SA-MP)
Any bug let me know, I will fix it. Enjoy!
Functions:
IsPlayerSpectating(playerid)
Checks if the player is spectating or not
Parameters:
playerid = The ID of the player who determine if is spectating
Return:
-1 if playerid is not connected, 0 if is not spectating, 1 if do it
IsPlayerSpectatingAnyPlayer(playerid)
Checks if the player is spectating to any player
Parameters:
playerid = The ID of the player who determine if is spectating
Return:
-1 if playerid is not connected, 0 if is not spectating to a player, 1 if do it
IsPlayerSpectatingPlayer(playerid,targetplayerid)
Checks if the player is spectating to a specific player
Parameters:
playerid = The ID of the player who determine if is spectating
targetplayerid = The ID of the player to check if is spectated
Return:
-1 if playerid or targetplayerid is not connected, 0 if playerid is not spectating to targetplayerid, 1 if do it
IsPlayerSpectatingAnyVehicle(playerid)
Checks if the player is spectating to any vehicle
Parameters:
playerid = The ID of the player who determine if is spectating
Return:
-1 if playerid is not connected, 0 if is not spectating to a vehicle, 1 if do it
IsPlayerSpectatingVehicle(playerid,targetvehicleid )
Checks if the player is spectating to a specific vehicle
Parameters:
playerid = The ID of the player who determine if is spectating
targetvehicleid = The ID of the vehicle to check if is spectated
Return:
-1 if playerid is not connectado or if targetvehicleid is invalid, 0 if playerid is not spectating to targetvehicleid, 1 if do it
GetPlayerSpectatedByPlayer(playerid)
Gets the player who is being spectated by the indicated player
Parameters:
playerid = The ID of the player who is spectating
Return:
The ID of the player spectated, INVALID_PLAYER_ID if playerid is not spectating or is spectating to a invalid player
GetVehicleSpectatedByPlayer(playerid)
Gets the vehicle that it is being spectated by the indicated player
Parameters:
playerid = The ID of the player who is spectating
Return:
The ID of the vehicle spectated, INVALID_VEHICLE_ID if playerid is not spectating or is spectating to a invalid vehicle
GetPlayersSpectatingPlayerCount(playerid)
Gets the count of players who are spectating to the indicated player
Parameters:
playerid = The ID of the player spectated
Return:
The count of players spectating to playerid, -1 if playerid is not connected
GetPlayersSpectatingVehicleCount(vehicleid)
Gets the count of players who are spectating to the indicated vehicle
Parameters:
vehicleid = The ID of the vehicle spectated
Return:
The count of players spectating to vehicleid, -1 if vehicleid is a invalid vehicle
Examples of use:
pawn Код:
#include <a_samp>
#include <LSpectating>
#include <zcmd>
#include <sscanf2>
CMD:specplayer(playerid,params[])
{
new id;
if(sscanf(params,"i",id)) return SendClientMessage(playerid,-1,"The correct way is: /specplayer [ID]");
if(IsPlayerSpectating(id)) return SendClientMessage(playerid,-1,"The player entered is spectating");
if(IsPlayerSpectatingPlayer(playerid,id)) return SendClientMessage(playerid,-1,"You already are spectating to this player");
if(GetPlayersSpectatingPlayerCount(id) > 0) return SendClientMessage(playerid,-1,"This player already has being spectated");
TogglePlayerSpectating(playerid,true);
PlayerSpectatePlayer(playerid,id);
return 1;
}
CMD:specveh(playerid,params[])
{
new id;
if(sscanf(params,"i",id)) return SendClientMessage(playerid,-1,"The correct way is: /specveh [ID]");
if(IsPlayerSpectatingVehicle(playerid,id)) return SendClientMessage(playerid,-1,"You already are spectating to this vehicle");
if(GetPlayersSpectatingVehicleCount(id) > 0) return SendClientMessage(playerid,-1,"This vehicle already has being spectated");
TogglePlayerSpectating(playerid,true);
PlayerSpectateVehicle(playerid,id);
return 1;
}
CMD:whospec(playerid,params[])
{
new id,str[128],name[2][MAX_PLAYER_NAME];
if(sscanf(params,"i",id)) return SendClientMessage(playerid,-1,"The correct way is: /whospec [ID]");
GetPlayerName(id,name[0],sizeof(name[0]));
if(!IsPlayerSpectating(id)) return SendClientMessage(playerid,-1,"The player entered is'nt spectating");
else if(IsPlayerSpectatingAnyPlayer(id))
{
GetPlayerName(GetPlayerSpectatedForPlayer(id),name[1],sizeof(name[1]));
format(str,sizeof(str),"The player %s is spectating to %s",name[0],name[1]);
SendClientMessage(playerid,-1,str);
}
else if(IsPlayerSpectatingAnyVehicle(id))
{
format(str,sizeof(str),"The player %s is spectating to the vehicle ID: %i",name[0],GetVehicleSpectatedForPlayer(id));
SendClientMessage(playerid,-1,str);
}
return 1;
}
Mediafire
Credits:
losrivarola98 (Creator of the include)
Kalcor (Creator of SA-MP)
Any bug let me know, I will fix it. Enjoy!