[Ajuda] Cofres e portas
#17

Eu peguei os valores que eu passei e eles realmente nгo funcionam.
Tentei calcular novos valores porйm nenhum deles funcionou corretamente exceto os que estгo na funзгo abaixo.
Estes valores funcionam se vocк criar o cofre e nгo alterar a posiзгo.
Porйm, se o fizer, fica fora de posiзгo.

Nгo sei o que estб errado nesta funзгo, se alguйm quiser resolver, fique a vontade.

Dependкncias: sscanf2, streamer, zcmd

obs: eu escrevo tudo em inglкs mesmo, nгo me julguem.

@EDIT

Consertei uma parte do cуdigo e adicionei uma funзгo para excluir os cofres criados.
Agora movimentar nгo faz com que a porta fique fora de posiзгo, mas rotacionar sim.


pawn Code:
#define MAX_SAFES 3

new
  safes[MAX_PLAYERS][MAX_SAFES] = {{INVALID_OBJECT_ID, ...}, ...},
  doors[MAX_PLAYERS][MAX_SAFES] = {{INVALID_OBJECT_ID, ...}, ...}
;

CMD:safe(playerid) {
  static a, b;
  for(a = 0, b = MAX_SAFES; a < b; a++) {
    if(safes[playerid][a] != INVALID_OBJECT_ID) continue;
    else {
      static Float:x, Float:y, Float:z, Float:ang, text[64];
      GetPlayerPos(playerid, x, y, z);
      GetPlayerFacingAngle(playerid, ang);
      x += 0.5; z += 0.3;
      safes[playerid][a] = CreateDynamicObject(19618, x, y, z, 0.0, 0.0, 0.0);
      EditDynamicObject(playerid, safes[playerid][a]);
      format(text, sizeof text, "Safe ID %02d created. Edit it's position.", a);
      return SendClientMessage(playerid, -1, text);
    }
  }
 
  return SendClientMessage(playerid, -1, "You can't create more safes.");
}

CMD:delsafe(playerid, params[]) {
  static n, s[4];
  if(!sscanf(params, "d", n)) {
    if(0 <= n <= MAX_SAFES-1) {
      DestroyDynamicObject(safes[playerid][n]);
      DestroyDynamicObject(doors[playerid][n]);
      safes[playerid][n] = INVALID_OBJECT_ID;
      doors[playerid][n] = INVALID_OBJECT_ID;
      static text[64];
      format(text, sizeof text, "Safe ID %02d destroyed.", n);
      return SendClientMessage(playerid, -1, text);
    } else return SendClientMessage(playerid, -1, "ID must be between 0 and 2");
  } else if(!sscanf(params, "s[4]", s)) {
    if(!strcmp(s, "all")) {
      static a, b;
      for(a = 0, b = MAX_SAFES; a < b; a++) {
        DestroyDynamicObject(safes[playerid][a]);
        DestroyDynamicObject(doors[playerid][a]);
        safes[playerid][a] = INVALID_OBJECT_ID;
        doors[playerid][a] = INVALID_OBJECT_ID;
      }
      return SendClientMessage(playerid, -1, "All safes destroyed.");
    } else return SendClientMessage(playerid, -1, "/delsafe all or /delsafe ID");
  } else return SendClientMessage(playerid, -1, "/delsafe all or /delsafe ID");
}

public OnPlayerEditDynamicObject(playerid, objectid, response, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz) {

  if(response == 1) {
    static a, b, text[64];
    for(a = 0, b = MAX_SAFES; a < b; a++) {
      if(objectid == safes[playerid][a]) {
        x -= 0.430419; y -= 0.220214;
        doors[playerid][a] = CreateDynamicObject(19619, x, y, z, rx, ry, rz);
        format(text, sizeof text, "Safe door ID %02d created.", a);
        return SendClientMessage(playerid, -1, text);
      }
    }
  }
 
  return 1;
}
Reply


Messages In This Thread
Cofres e portas - by YCharlieY - 28.10.2018, 19:57
Re: Cofres e portas - by ipsLuan - 28.10.2018, 20:00
Re: Cofres e portas - by YCharlieY - 28.10.2018, 20:04
Re: Cofres e portas - by ipsLuan - 29.10.2018, 12:48
Re: Cofres e portas - by YCharlieY - 29.10.2018, 19:55
Re: Cofres e portas - by HelderPT - 29.10.2018, 20:55
Re: Cofres e portas - by YCharlieY - 30.10.2018, 23:58
Re: Cofres e portas - by GSantana - 31.10.2018, 01:32
Re: Cofres e portas - by Ermanhaut - 31.10.2018, 01:46
Re: Cofres e portas - by GSantana - 31.10.2018, 02:27
Re: Cofres e portas - by Ermanhaut - 31.10.2018, 11:57
Re: Cofres e portas - by GSantana - 31.10.2018, 23:53
Re: Cofres e portas - by YCharlieY - 01.11.2018, 01:01
Re: Cofres e portas - by YCharlieY - 01.11.2018, 01:03
Re: Cofres e portas - by GSantana - 01.11.2018, 01:28
Re: Cofres e portas - by YCharlieY - 01.11.2018, 02:31
Re: Cofres e portas - by Ermanhaut - 01.11.2018, 05:27

Forum Jump:


Users browsing this thread: 2 Guest(s)