*This is basically a rip of avanchles code, I am only posting the code that applies to the problem.
Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#define MAXDOORS 999 // max amount of doors
new elecdoorX[3] = (2559, 2559, 2559)
new elecdoorY[3] = (-2119, -2119, -2119)
new elecdoorZ[3] = (-172, -172, -172)
new doorislocked[MAXDOORS]; // if door is locked
new doorhaskey[33][MAXDOORS]; // if player has key for door
new hackingstage[33]
new doorbuttonid[MAXDOORS]; // id of button entity for door (if it has one)
new doorbuttontarget[MAXDOORS][64]; // target of button entity for door (if it has one)
public hackdoor(id) {
new doorid, buttonid, buttonbody, isbutton;
get_user_aiming(id,buttonid,buttonbody,9999);
new origin[3], checkorigin[3], validpos;
get_user_origin(id,origin,3);
for(new i=0;i<sizeof(elecdoorX);i++) {
checkorigin[0] = elecdoorX[i];
checkorigin[1] = elecdoorY[i];
checkorigin[2] = elecdoorZ[i];
if(get_distance(origin,checkorigin) <= 30) {
validpos = 1;
}
}
if (validpos != 1) {
client_print(id,print_chat,"* [-Snort-] You are not near a door's electronic system.");
return PLUGIN_HANDLED
}
if(is_valid_ent(buttonid)) { // if valid ent
isbutton = is_button(buttonid);
}
else { // if invalid ent
client_print(id,print_chat,"* [-Snort-] You can only hack doors that use electronic devices");
return PLUGIN_HANDLED;
}
if(isbutton == 0) { // if not a button entity
client_print(id,print_chat,"* [-Snort-] Hack the electronic system, not the door itself.");
return PLUGIN_HANDLED;
}
// go through doors
for(new i=0;i<MAXDOORS;i++) {
if(doorbuttonid[i] == buttonid) { // if this button belongs to this door
doorid = i; // let us know
break;
}
}
// if no doors found
if(doorid == 0 || !is_valid_ent(doorid)) {
client_print(id,print_chat,"* [-Snort-] No locked doors belong to this button");
return PLUGIN_HANDLED;
}
if(doorid > MAXDOORS-1) { // if exceeds our array
client_print(id,print_chat,"* [-Snort-] ERROR: Too many entities");
return PLUGIN_HANDLED;
}
// if door is unlocked
if(doorislocked[doorid] == 0) {
client_print(id,print_chat,"* [-Snort-] This door does not require opening");
return PLUGIN_HANDLED;
}
client_print(id,print_chat,"* [-Snort-] You have begun hacking.")
hackingstage[id] = 1
starthackmode(id)
return PLUGIN_HANDLED;
}
public starthackmode(id) {
new doorid, buttonid, buttonbody, isbutton;
get_user_aiming(id,buttonid,buttonbody,9999);
if(is_valid_ent(buttonid)) { // if valid ent
isbutton = is_button(buttonid);
}
else { // if invalid ent
client_print(id,print_chat,"* [-Snort-] You moved away and are no longer hacking.");
client_print(id,print_chat,"* [-Snort-] You throw the laptop away to get rid of evidence.");
hackingstage[id] = 0
return PLUGIN_HANDLED;
}
if(isbutton == 0) { // if not a button entity
client_print(id,print_chat,"* [-Snort-] You moved away and are no longer hacking.");
client_print(id,print_chat,"* [-Snort-] You throw the laptop away to get rid of evidence.");
hackingstage[id] = 0
return PLUGIN_HANDLED;
}
// go through doors
for(new i=0;i<MAXDOORS;i++) {
if(doorbuttonid[i] == buttonid) { // if this button belongs to this door
doorid = i; // let us know
break;
}
}
// if no doors found
if(doorid == 0 || !is_valid_ent(doorid)) {
client_print(id,print_chat,"* [-Snort-] You moved away and are no longer hacking.");
client_print(id,print_chat,"* [-Snort-] You throw the laptop away to get rid of evidence.");
hackingstage[id] = 0
return PLUGIN_HANDLED;
}
if(doorid > MAXDOORS-1) { // if exceeds our array
client_print(id,print_chat,"* [-Snort-] You moved away and are no longer hacking.");
client_print(id,print_chat,"* [-Snort-] You throw the laptop away to get rid of evidence.");
hackingstage[id] = 0
return PLUGIN_HANDLED;
}
if ( (hackingstage[id] < 1 ) && ( hackingstage[id] != 10 ) ) {
new percentdone
percentdone = hackingstage[id] * 10
client_print(id,print_chat,"* [-Snort-] You are %s^% done hacking.",percentdone);
hackingstage[id] = hackingstage[id] + 1
set_task(3.0,"showhacklevel",id);
return PLUGIN_HANDLED
}
if (hackingstage[id] == 10) {
client_print(id,print_chat,"* [-Snort-] Hacking Successful.");
client_print(id,print_chat,"* [-Snort-] Your laptop has been traced.");
client_print(id,print_chat,"* [-Snort-] The local authorities have been warned.");
//warnmcpd(id)
hackingstage[id] = 0;
force_use(id,doorid);
return PLUGIN_HANDLED
}
client_print(id,print_chat,"* [-Snort-]hackingstage[id] = %s",hackingstage[id]);
return PLUGIN_HANDLED
}
As you can see, i even made a client_print that shows the hackingstage[id], but ingame it looks like
just... blank.
*Also, btw, avalanche i only put the [-Snort-] in the chat of the hacking messages, not any of the [door] stuff. Just like to reference that.*