was haltet ihr?
/edith: merke, erst testcompilen
Code:
/* Includes */
#include <adminlib>
/* Constants */
#define MAX_KOORDS 6
#define COOLDOWN 10
#define RANGE 50
/* Global Variables */
new g_Teleporters[MAX_KOORDS][3] = {
{19,3089,36},
{-1582,2505,68},
{2320,668,36},
{533,-445,57},
{498,-1218,100},
{-1211,1459,-156}
};
new g_Version[20] = "10.2.03 21:42";
new g_LastWarp[MAX_PLAYERS];
new g_Enabled;
/* Event Handler */
public plugin_init() {
plugin_registerinfo("DUSTWARP","WARP-Plugin for de_dust",g_Version);
plugin_registercmd("admin_warp", "admin_warp", ACCESS_MAP,"admin_warp <0|1>: Teleporter aktivieren/deaktivieren");
return PLUGIN_CONTINUE;
}
public warp(Timer,Repeat,HLUser,HLParam) {
new i,j,k;
new Origin[3];
new Vec[3];
new maxplayers=maxplayercount();
new Dead;
new Text[MAX_TEXT_LENGTH];
new Name[MAX_NAME_LENGTH];
new time = systemtime();
if(g_Enabled) {
typesay("WARP-MODUS!^n Die Teleporter sind eingeschaltet!",12,random(5) ? 250 : 10,random(5) ? 250 : 10,random(5) ? 250 : 10);
for(i=1;i<=maxplayers;i++) {
if(g_LastWarp[i] + COOLDOWN <= time) {
if(playerinfo(i,Name,MAX_NAME_LENGTH,_,_,_,Dead) && Dead == 0){
if(get_userorigin(Name,Origin[0],Origin[1],Origin[2]) == 1) {
for(j=0;j<MAX_KOORDS;j++){
diffvec(Origin,g_Teleporters[j],Vec);
if(veclen(Vec) <= RANGE) {
while((k = random(MAX_KOORDS)) != j) {}
teleport(Name,g_Teleporters[k][0],g_Teleporters[k][1]+30,g_Teleporters[k][2]);
g_LastWarp[i] = time;
snprintf(Text,MAX_TEXT_LENGTH,"%s hat sich von Teleporter %i zu Teleporter %i gewarpt",Name,j,k);
say(Text);
break;
}
}
}
}
}
}
set_timer("warp",1,0);
} else {
typesay("WARP-MODUS!^n Die Teleporter sind ausgeschaltet!",12,250,10,10);
}
return PLUGIN_CONTINUE;
}
/* Command Handler */
public admin_warp(HLCommand,HLData,HLUserName,UserIndex) {
new Data[MAX_DATA_LENGTH];
convert_string(HLData,Data,MAX_DATA_LENGTH);
if(!Data[0]) selfmessage("admin_warp <0|1>: Teleporter aktivieren/deaktivieren");
else if(Data[0] - 48 != g_Enabled) {
g_Enabled = Data[0] - 48;
snprintf(Data,MAX_DATA_LENGTH,"WARP-MODUS ist %s",g_Enabled ? "aktiviert" : "deaktiviert");
selfmessage(Data);
if(g_Enabled) set_timer("warp",1,0);
}
return PLUGIN_HANDLED;
}
/* Helper Functions */
stock diffvec(vec1[3],vec2[3],vec0[3]) { //Puts the diffenrece-vector of vec1 and vec2 in vec0.
new i;
for(i=0;i<3;i++) {
vec0[i] = vec1[i] - vec2[i];
}
}
stock veclen(vec[3]) { //Returns the length of a vector, multiplied with factor.
new i,j,k,l;
for(i=0;i<3;i++){
l = abs(vec[i]);
k = max(l,k);
j += l * l;
}
i = j;
while(j > k) {
j = (j + k) / 2;
k = i / j;
}
return j;
}
stock abs(num) { //Returns the positive value of num.
if(num > 0) {
return num;
}
return -num;
}