AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   demo recorder (https://forums.alliedmods.net/showthread.php?t=135820)

outsiderlv 08-20-2010 02:23

demo recorder
 
PHP Code:

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "auto demo recorder"
#define VERSION "2.0 updated"
#define AUTHOR "outsider"

public plugin_init() {
    
register_plugin(PLUGIN,VERSION,AUTHOR)
}

public 
client_putinserver(id) {
    
set_task(5.0,"record_demo",id)
    return 
PLUGIN_CONTINUE
}

public 
record_demo(id) {
    new 
servername[65];
    new 
demoname[16];
    
    
get_user_name(0,servername,64);
    if(
servername == "JB.RETRY.LV JAILBREAK 47/48p") {
        
demoname "jb_retry_lv";
        } else if(
servername == "HNS.RETRY.LV HIDE AND SEEK 47/48p") {
        
demoname "hns_retry_lv";
        } else if(
servername == "BB.RETRY.LV BASE BUILDER 47/48p") {
        
demoname "bb_retry_lv";
        } else if(
servername == "DD2.RETRY.LV DUST 2 LAND 47/48p") {
        
demoname "dd2_retry_lv";
        } else if(
servername == "CS.RETRY.LV PUBLIC 47/48p") {
        
demoname "cs_retry_lv";
        } else if(
servername == "ZM.RETRY.LV ZM+WAR3 47/48p") {
        
demoname "zm_retry_lv";
        } else if(
servername == "DR.RETRY.LV DEATHRUN 47/48p") {
        
demoname "dr_retry_lv";
        } else if(
servername == "SURF.RETRY.LV SURF 47/48p") {
        
demoname "surf_retry_lv";
        } else {
        
demoname "retry_lv";
    }
    
    new 
name[35];
    
get_user_name(id,name,34); 
    
    new 
userip[20]
    
get_user_ip(id,userip,19);
    
    new 
serverip[20]
    
get_user_ip(0,serverip,19);
    
    
client_cmd(id,"stop;record %s",demoname)
    
client_print(id,print_center,"Recording to %s started...",demoname)
    
client_print(id,print_chat,"Serveris: %s (%s)",servername,serverip)
    
client_print(id,print_chat,"Niks: %s | IP: %s",name,userip)
    return 
PLUGIN_CONTINUE


When i compile:
PHP Code:

Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c1997-2006 ITB CompuPhaseAMX Mod X Team

Error
: Array must be indexed (variable "servername"on line 22
Error
: Array must be indexed (variable "servername"on line 24
Error
: Array must be indexed (variable "servername"on line 26
Error
: Array must be indexed (variable "servername"on line 28
Error
: Array must be indexed (variable "servername"on line 30
Error
: Array must be indexed (variable "servername"on line 32
Error
: Array must be indexed (variable "servername"on line 34
Error
: Array must be indexed (variable "servername"on line 36

8 Errors
.
Could not locate output file C:\Documents and Settings\Boss\Desktop\Plugins\scripting\retryrecorddemo.amx (compile failed). 


nikhilgupta345 08-20-2010 02:34

Re: demo recorder
 
When comparing arrays you must use either contain, containi, equal, or equali. The i at the end makes it case-insensitive, so if you want exact name with case sensitive, don't put the i, otherwise if it doesn't matter, leave the i.

So:

Code:

if(servername == "JB.RETRY.LV JAILBREAK 47/48p")



->

Code:

if(equali(servername,"JB.RETRY.LV JAILBREAK 47/48p"))



And change all of them btw.

outsiderlv 08-20-2010 02:34

Re: demo recorder
 
Thanks. BTW, is there any way to check if smthn contains some text (ex. HNS.RETRY.LV) so i dont have to check full name?

nikhilgupta345 08-20-2010 02:48

Re: demo recorder
 
That's what contain is for.
Code:

if(containi(servername, "HNS.RETRY.LV")
{
//do something
}

Also, i just looked at ur full code, and I'm just wondering, if you're calling the task every 5 seconds when they are put in the server, and their name is w/e (HNS.RETRY.LV) or w/e, it will keep stopping and starting the demo over and over and over again won't it?

outsiderlv 08-20-2010 03:31

Re: demo recorder
 
PHP Code:

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "auto demo recorder"
#define VERSION "2.0 updated"
#define AUTHOR "outsider"

new servername[65];
new 
demoname[16];
new 
bool:user_demo_recorder[35] = false;

public 
plugin_init() {
    
register_plugin(PLUGIN,VERSION,AUTHOR)
    
set_task(4.0,"server");
}

public 
client_putinserver(id) {
    
set_task(5.0,"record_demo",id)
    return 
PLUGIN_CONTINUE
}

public 
server() {
    
get_user_name(0,servername,64);
    if(
equali(servername,"JB.RETRY.LV JAILBREAK 47/48p")) {
        
demoname "jb_retry_lv";
        } else if(
equali(servername,"HNS.RETRY.LV HIDE AND SEEK 47/48p")) {
        
demoname "hns_retry_lv";
        } else if(
equali(servername,"BB.RETRY.LV BASE BUILDER 47/48p")) {
        
demoname "bb_retry_lv";
        } else if(
equali(servername,"DD2.RETRY.LV DUST 2 LAND 47/48p")) {
        
demoname "dd2_retry_lv";
        } else if(
equali(servername,"CS.RETRY.LV PUBLIC 47/48p")) {
        
demoname "cs_retry_lv";
        } else if(
equali(servername,"ZM.RETRY.LV ZM+WAR3 47/48p")) {
        
demoname "zm_retry_lv";
        } else if(
equali(servername,"DR.RETRY.LV DEATHRUN 47/48p")) {
        
demoname "dr_retry_lv";
        } else if(
equali(servername,"SURF.RETRY.LV SURF 47/48p")) {
        
demoname "surf_retry_lv";
        } else {
        
demoname "retry_lv";
    }
}

public 
record_demo(id) {
    if(
user_demo_recorder[id]) {
        return 
PLUGIN_HANDLED;
    }
    new 
name[35];
    
get_user_name(id,name,34); 
    
    new 
userip[20]
    
get_user_ip(id,userip,19);
    
    new 
serverip[20]
    
get_user_ip(0,serverip,19);
    
    
client_cmd(id,"stop;record %s",demoname)
    
client_print(id,print_center,"Recording to %s started...",demoname)
    
client_print(id,print_chat,"Serveris: %s (%s)",servername,serverip)
    
client_print(id,print_chat,"Niks: %s | IP: %s",name,userip)
    
user_demo_recorder[id] = true;
    return 
PLUGIN_CONTINUE


Is this better? And how can i avoid the shitty checking? :D

nikhilgupta345 08-20-2010 04:03

Re: demo recorder
 
Hmm, can u record from the actual server? get_user_name 0 i think get's the hostname right? So I don't think that the server can record unless u have HLTV. :(

Unless u have a player in the server just sitting there like a bot but an actual player who is recording?

So this is what I would do, I'd make it only check once, when the client enters the server, so you don't have a task.

Basically what this does if a person enters and their name is HNS......TV or w/e, it will send the command "record %s", demoname to them obviously not that exact command but w/e. So the person that is recording must be you or someone that you have access to their steam files and stuff. Then it will save the demo to their cstrike folder. Only downfall is that if they get kicked or soemthing, it won't stop recording. :(

So this is what I got.

Untested:
Code:

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "auto demo recorder"
#define VERSION "2.0 updated"
#define AUTHOR "outsider"

new servername[65];
new demoname[16];

public plugin_init() {
    register_plugin(PLUGIN,VERSION,AUTHOR)
}

public client_putinserver(id) {
    server(id)
    return PLUGIN_CONTINUE
}

public server(id) {
    get_user_name(id,servername,64);
    if(equali(servername,"JB.RETRY.LV JAILBREAK 47/48p")) {
        demoname = "jb_retry_lv";
        record_demo(id)
        } else if(equali(servername,"HNS.RETRY.LV HIDE AND SEEK 47/48p")) {
    demoname = "hns_retry_lv";
    record_demo(id)
        } else if(equali(servername,"BB.RETRY.LV BASE BUILDER 47/48p")) {
    demoname = "bb_retry_lv";
    record_demo(id)
        } else if(equali(servername,"DD2.RETRY.LV DUST 2 LAND 47/48p")) {
    demoname = "dd2_retry_lv";
    record_demo(id)
        } else if(equali(servername,"CS.RETRY.LV PUBLIC 47/48p")) {
    demoname = "cs_retry_lv";
    record_demo(id)
        } else if(equali(servername,"ZM.RETRY.LV ZM+WAR3 47/48p")) {
    demoname = "zm_retry_lv";
    record_demo(id)
        } else if(equali(servername,"DR.RETRY.LV DEATHRUN 47/48p")) {
    demoname = "dr_retry_lv";
    record_demo(id)
        } else if(equali(servername,"SURF.RETRY.LV SURF 47/48p")) {
    demoname = "surf_retry_lv";
    record_demo(id)
        } else {
    demoname = "retry_lv";
    record_demo(id)
    }
}

public record_demo(id) {
    new name[35];
    get_user_name(id,name,34);
   
    new userip[20]
    get_user_ip(id,userip,19);
   
    new serverip[20]
    get_user_ip(0,serverip,19);
   
    client_cmd(id,"stop;record %s",demoname)
    client_print(id,print_center,"Recording to %s started...",demoname)
    client_print(id,print_chat,"Serveris: %s (%s)",servername,serverip)
    client_print(id,print_chat,"Niks: %s | IP: %s",name,userip)
    return PLUGIN_CONTINUE
}


outsiderlv 08-20-2010 04:15

Re: demo recorder
 
Check my code again. Everything is finu but i need to call the record only 1 time for each player.

Rosenstein 08-20-2010 07:15

Re: demo recorder
 
Why don't you use Auto Demo Recorder
Also, 47/48p is not supported.

SpeeDeeR 08-20-2010 07:25

Re: demo recorder
 
I must say that get_user_name(0) doesnt get the hostname.

xPaw 08-20-2010 07:44

Re: demo recorder
 
Quote:

Originally Posted by SpeeDeeR (Post 1276576)
I must say that get_user_name(0) doesnt get the hostname.

I must say that you're wrong.

Anyway, his server is non-steam.


All times are GMT -4. The time now is 21:53.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.