Retorna diretamente o nome do player, podendo ser utilizado dentro de um format sem a necessidade de ficar criando variavel e atribuindo o nome do jogador toda hora, aumentando a produtividade e reutilização do código:
(editado)
(editado)
(editado)
- Código:
stock GetPlayerNameEx(playerid)
{
new PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
return PlayerName;
}
(editado)
[14:30]
Geta a posição da parte de trás de um veículo:- Código:
stock GetPosBehindVehicle (vehicleid, &Float:x, &Float:y, &Float:z, Float:offset=0.5)
{
new Float:vehicleSize[3], Float:vehiclePos[3];
GetVehiclePos(vehicleid, vehiclePos[0], vehiclePos[1], vehiclePos[2]);
GetVehicleModelInfo(GetVehicleModel(vehicleid), VEHICLE_MODEL_INFO_SIZE,vehicleSize[0],vehicleSize[1], vehicleSize[2]);
GetXYBehindVehicle(vehicleid, vehiclePos[0], vehiclePos[1], (vehicleSize[1]/2)+offset);
x = vehiclePos[0];
y = vehiclePos[1];
z = vehiclePos[2];
return 1;
}
GetXYBehindVehicle(vehicleid, &Float:q, &Float:w, Float:distance)
{
new Float:a;
GetVehiclePos(vehicleid, q, w, a);
GetVehicleZAngle(vehicleid, a);
q += (distance * -floatsin(-a, degrees));
w += (distance * -floatcos(-a, degrees));
}
(editado)
[14:31]
Retorna Vida e Colete:- Código:
ReturnHealth(playerid)
{
static Float:amount;
GetPlayerHealth(playerid, amount);
return floatround(amount, floatround_round);
}
ReturnArmour(playerid)
{
static Float:amount;
GetPlayerArmour(playerid, amount);
return floatround(amount, floatround_round);
}
(editado)
[14:32]
Vehicle Utils:- Código:
stock ReturnVehicleHealth(vehicleid)
{
if (!IsValidVehicle(vehicleid)) return 0;
static Float:amount;
GetVehicleHealth(vehicleid, amount);
return floatround(amount, floatround_round);
}
stock ReturnVehicleModelName(model)
{
new name[32] = "None";
if (model < 400 || model > 611)
return name;
format(name, sizeof(name), g_arrVehicleNames[model - 400]);
return name;
}
stock ReturnVehicleName(vehicleid)
{
new
model = GetVehicleModel(vehicleid),
name[32] = "None";
if (model < 400 || model > 611)
return name;
format(name, sizeof(name), g_arrVehicleNames[model - 400]);
return name;
}
stock GetVehicleModelByName(const name[])
{
if (IsNumeric(name) && (strval(name) >= 400 && strval(name) <= 611))
return strval(name);
for (new i = 0; i < sizeof(g_arrVehicleNames); i ++)
{
if (strfind(g_arrVehicleNames[i], name, true) != -1)
{
return i + 400;
}
}
return 0;
}
stock GetVehicleDriver(vehicleid)
{
foreach (new i : Player)
{
if (GetPlayerState(i) == PLAYER_STATE_DRIVER && GetPlayerVehicleID(i) == vehicleid)
return i;
}
return INVALID_PLAYER_ID;
}
[14:32]
Retorna Data e Hora:- Código:
ReturnDateTime()
{
static date[36];
getdate(date[2], date[1], date[0]);
gettime(date[3], date[4], date[5]);
format(date, sizeof(date), "%02d/%02d/%d, %02d:%02d", date[0], date[1], date[2], date[3], date[4]);
return date;
}
[14:35]
SendClientMessageEx, com parametro especial, desta forma vc poderá formatar a string diretamente na função, sem necessidade de criar um variavel string para repassá-la na função SendClientMessage:- Código:
stock SendClientMessageEx(playerid, color, const str[], {Float,_}:...)
{
static
args,
start,
end,
string[144]
;
#emit LOAD.S.pri 8
#emit STOR.pri args
if (args > 12)
{
#emit ADDR.pri str
#emit STOR.pri start
for (end = start + (args - 12); end > start; end -= 4)
{
#emit LREF.pri end
#emit PUSH.pri
}
#emit PUSH.S str
#emit PUSH.C 144
#emit PUSH.C string
#emit PUSH.C args
#emit SYSREQ.C format
SendClientMessage(playerid, color, string);
#emit LCTRL 5
#emit SCTRL 4
#emit RETN
}
return SendClientMessage(playerid, color, str);
}
[14:36]
Retorna o nome do jogador sem o Underline:- Código:
ReturnName(playerid, underscore=1)
{
static
name[MAX_PLAYER_NAME + 1];
GetPlayerName(playerid, name, sizeof(name));
if (!underscore) {
for (new i = 0, len = strlen(name); i < len; i ++) {
if (name[i] == '_') name[i] = ' ';
}
}
return name;
}
Creditos pela reunião dos codigos: Chainksain.