Noticias:

Debes de estar registrado para poder ver el contenido indicado. Registrate o Conectate

Menú Principal

Sistema de Estrellas

Iniciado por Swarlog, Ene 30, 2023, 04:32 PM

Tema anterior - Siguiente tema

Swarlog

Información Adicional:

Para todos aquellos que desean incorporar el sistema de estrellas de búsqueda/policial en su servidor os dejo este script que contiene el código necesario para ello y además está vinculado con el envio de usuarios a la carcel.

Código:

#include <a_samp>


enum pInfo
{
    pEstrellas,
    pEnCarcel,
    pTiempo
};
new PlayerInfo[MAX_PLAYERS][pInfo];

new DetectarJail;
#define Rojo   0xa80707FF

public OnFilterScriptInit()
{
DetectarJail = SetTimer("SacarDeLaCarcel", 1000, 1);
return 1;
}


#if defined FILTERSCRIPT

#else

main(){}

#endif

public OnPlayerSpawn(playerid)
{
if(PlayerInfo[playerid][pEstrellas] > 0) return MetenEnJail(playerid);
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    KillTimer(DetectarJail);
return 1;
}




public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256];
new idx;
cmd = strtok(cmdtext, idx);
new tmp[256];

if(strcmp(cmd, "/Estrellas", true) == 0)
{
    new IdIndicada;
new Estrellas;
new MaximoEstrellas;
    if(IsPlayerConnected(playerid))
    {
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))    return SendClientMessage(playerid, Rojo, "[Uso:] /Estrellas [Id/Nombre] [Cantidad]");
if(MaximoEstrellas < 0 || MaximoEstrellas > 6) return SendClientMessage(playerid, Rojo, "[Error] Minimo 0 maximo 6");


IdIndicada = ReturnUser(tmp);
tmp = strtok(cmdtext, idx);
Estrellas = strval(tmp);
    if(IsPlayerConnected(IdIndicada))
    {
        if(IdIndicada != INVALID_PLAYER_ID)
        {
            SetPlayerWantedLevel(IdIndicada, Estrellas);
            PlayerInfo[playerid][pEstrellas] =  Estrellas;
}
}
}
return 1;
}
return 0;
}

forward   MetenEnJail(playerid);
public  MetenEnJail(playerid)
{

new tmp[64];
format(tmp, sizeof(tmp), "Desconectaste con un nivel de %i estrellas", PlayerInfo[playerid][pEstrellas]);
SendClientMessage(playerid, 0xFF0000FF, tmp);
ResetPlayerWeapons(playerid);
PlayerInfo[playerid][pEnCarcel] = 1;
SetPlayerInterior(playerid, 0);
SetPlayerPos(playerid, 3058.5444,2999.5657,0.9986);
new Tiempo =    PlayerInfo[playerid][pEstrellas]    *=   600000;
PlayerInfo[playerid][pTiempo] = Tiempo ;
return 1;
}


forward   SacarDeLaCarcel();
public SacarDeLaCarcel()
{
new string[10];
    for(new i = 0; i < MAX_PLAYERS; i++)
{
if(PlayerInfo[i][pEnCarcel] > 0)
    {
if(PlayerInfo[i][pTiempo] > 0)  return PlayerInfo[i][pTiempo]--;
if(PlayerInfo[i][pTiempo] <= 0)
{
    PlayerInfo[i][pTiempo] = 0;
    PlayerInfo[i][pEnCarcel] = 0;
format(string, sizeof(string), "~g~Libre");
}
}
}
return 1;
}



strtok(string[],&idx,seperator = ' ')
{
new ret[128], i = 0, len = strlen(string);
while(string[idx] == seperator && idx < len) idx++;
while(string[idx] != seperator && idx < len)
{
    ret[i] = string[idx];
    i++;
idx++;
}
while(string[idx] == seperator && idx < len) idx++;
return ret;
}




ReturnUser(text[], playerid = INVALID_PLAYER_ID)
{
new pos = 0;
while (text[pos] < 0x21)
{
if (text[pos] == 0) return INVALID_PLAYER_ID;
pos++;
}
new userid = INVALID_PLAYER_ID;
if (IsNumeric(text[pos]))
{
userid = strval(text[pos]);
if (userid >=0 && userid < MAX_PLAYERS)
{
if(!IsPlayerConnected(userid))
{
userid = INVALID_PLAYER_ID;
}
else
{
return userid;
}
}
}
new len = strlen(text[pos]);
new count = 0;
new name[MAX_PLAYER_NAME];
for (new i = 0; i < MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
GetPlayerName(i, name, sizeof (name));
if (strcmp(name, text[pos], true, len) == 0)
{
if (len == strlen(name))
{
return i;
}
else
{
count++;
userid = i;
}
}
}
}
if (count != 1)
{
if (playerid != INVALID_PLAYER_ID)
{
if (count)
{
SendClientMessage(playerid, Rojo, "[Error] Muchos jugadores alrededor.");
}
else
{
SendClientMessage(playerid, Rojo, "[Error] Ningún jugador concordante.");
}
}
userid = INVALID_PLAYER_ID;
}
return userid;
}

IsNumeric(const string[])
{
for (new i = 0, j = strlen(string); i < j; i++)
{
if (string[i] > '9' || string[i] < '0') return 0;
}
return 1;
}