13.02.2016, 11:49
Bom dia!!
Eu estou tendo problemas com um bug no localizador desse GPS que estб instalado no meu GM
O bug й quando o player estб localizando outro player com "/localizar [ ID ]", dai quando sai do servidor sem desligar o gps "/localizar off", ai o servidor nгo desliga o GPS automaticamente apуs deslogar, sendo que jб estб programado para desligar, e quando outro player entra com o mesmo ID que o cara saiu sem desligar o GPS, ai acontece o BUG do textdraw, localizando o outro player, assim aparecendo na tela "Ex: Distancia: 8547 m"
E quando tenta dar "/localizar off", diz que o GPS jб estб desligado
Lembrando que jб ta programado para desligar o GPS apуs deslogar do servidor
Eu estou tendo problemas com um bug no localizador desse GPS que estб instalado no meu GM
O bug й quando o player estб localizando outro player com "/localizar [ ID ]", dai quando sai do servidor sem desligar o gps "/localizar off", ai o servidor nгo desliga o GPS automaticamente apуs deslogar, sendo que jб estб programado para desligar, e quando outro player entra com o mesmo ID que o cara saiu sem desligar o GPS, ai acontece o BUG do textdraw, localizando o outro player, assim aparecendo na tela "Ex: Distancia: 8547 m"
E quando tenta dar "/localizar off", diz que o GPS jб estб desligado
Lembrando que jб ta programado para desligar o GPS apуs deslogar do servidor
Код:
public OnPlayerConnect(playerid)
{
GPSTimer[playerid] = 0;
HaveGPS[playerid] = false;
SendClientMessage(playerid, 0xFFFFFFAA, "Este servidor usa um sistema de GPS feito por Jefff (/gps)");
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
if(HaveGPS[playerid]) {
KillTimer(GPSTimer[playerid]);
HaveGPS[playerid] = false;
GPSTimer[playerid] = 0;
}
return 1;
}
Код:
#include <a_samp>
new GPSTimer[MAX_PLAYERS];
new bool:HaveGPS[MAX_PLAYERS];
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
stock GetDistanceBetweenPlayers(playerid,playerid2){
new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
new Float:dis;
GetPlayerPos(playerid,x1,y1,z1);
GetPlayerPos(playerid2,x2,y2,z2);
dis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
return floatround(dis);
}
forward GPSUpdate(playerid,playerid2);
public GPSUpdate(playerid,playerid2){
if(IsPlayerConnected(playerid2)){
new Float:Distnace;
Distnace = GetDistanceBetweenPlayers(playerid,playerid2);
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid2,X,Y,Z);
DisablePlayerCheckpoint(playerid);
SetPlayerCheckpoint(playerid,X,Y,Z,0.1);
new string[128];
format(string, sizeof(string), "~n~~n~~n~~n~~n~~n~~n~~n~~p~Distancia: ~w~%.1f ~y~m",Distnace);
GameTextForPlayer(playerid, string, 1100, 5);
if(Distnace <= 4.0) {
DisablePlayerCheckpoint(playerid);
KillTimer(GPSTimer[playerid]);
HaveGPS[playerid] = false;
GPSTimer[playerid] = 0;
}
}else{
DisablePlayerCheckpoint(playerid);
KillTimer(GPSTimer[playerid]);
HaveGPS[playerid] = false;
GPSTimer[playerid] = 0;
SendClientMessage(playerid, 0xFF0000AA, "GPS: N?o encontrado.");
}
return 1;
}
public OnFilterScriptInit()
{
print("\n* GPS by Jefff carregado...\n");
return 1;
}
public OnFilterScriptExit()
{
print("\n* GPS by Jefff desligado...\n");
return 1;
}
public OnPlayerConnect(playerid)
{
GPSTimer[playerid] = 0;
HaveGPS[playerid] = false;
SendClientMessage(playerid, 0xFFFFFFAA, "Este servidor usa um sistema de GPS feito por Jefff (/gps)");
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
if(HaveGPS[playerid]) {
KillTimer(GPSTimer[playerid]);
HaveGPS[playerid] = false;
GPSTimer[playerid] = 0;
}
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
if(HaveGPS[playerid]) {
KillTimer(GPSTimer[playerid]);
HaveGPS[playerid] = false;
GPSTimer[playerid] = 0;
}
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[64],tmp[64],idx;
cmd = strtok(cmdtext,idx);
if(!strcmp(cmd, "/Localizar", true))
{
tmp = strtok(cmdtext,idx);
if(!strlen(tmp)) return SendClientMessage(playerid, 0xFFFFFFAA, "Use: /Localizar [playerid / off]");
if(!strcmp(tmp, "off", true)) {
if(HaveGPS[playerid]) {
KillTimer(GPSTimer[playerid]);
HaveGPS[playerid] = false;
GPSTimer[playerid] = 0;
DisablePlayerCheckpoint(playerid);
SendClientMessage(playerid, 0xFFFF00AA, "GPS: Desligado.");
}else SendClientMessage(playerid, 0xFF0000AA, "GPS: Seu GPS est? desligado !");
return 1;
}
if(IsPlayerConnected(strval(tmp))) {
if(strval(tmp) != playerid) {
if(HaveGPS[playerid]) {
KillTimer(GPSTimer[playerid]);
HaveGPS[playerid] = false;
GPSTimer[playerid] = 0;
}
GPSTimer[playerid] = SetTimerEx("GPSUpdate", 500, true, "dd", playerid,strval(tmp));
HaveGPS[playerid] = true;
new str[128],nick[24];
GetPlayerName(strval(tmp),nick,24);
format(str,128,"GPS: Ligado, alvo: %s (ID: %d)",nick,strval(tmp));
SendClientMessage(playerid, 0xFFFF00AA, str);
}else SendClientMessage(playerid, 0xFF0000AA, "GPS: Use corretamente o seu GPS !");
}else SendClientMessage(playerid, 0xFF0000AA, "GPS: Alvo n?o encontrado(ID errado) !");
return 1;
}
return 0;
}


