A website for every gema-assaultcube fan
 
HomeHome  CalendarCalendar  FAQFAQ  SearchSearch  MemberlistMemberlist  UsergroupsUsergroups  RegisterRegister  Log in  

Share | 
 

 Some useful scripts..

View previous topic View next topic Go down 
AuthorMessage
.VM|EnV



Messages : 17
Joined/Date d'inscription : 2015-07-19
Age : 21
Location/Localisation : Greece

PostSubject: Some useful scripts..   Mon Jul 20, 2015 8:20 am

I have in my scripts folder a really useful file: main.cfg.
So i am gonna share with you this file. Very Happy

Oh BTW you must install tools.cfg first Wink

Code:


//logic AND for 4 arguments
alias &&& [
  if (&& (&& $arg1 $arg2) (&& $arg3 $arg4)) [return 1;] [return 0;]
]

//representation of "abs(a-b)"
alias MaxMinusMin [
  if (> $arg1 $arg2) [return (- $arg1 $arg2)] [return (- $arg2 $arg1)]
]

//clear all timers (otherwise timers can fire events twice or more times)
resetsleeps;

alias mycn (findcn $curname); //My CN
alias lastDamageTime (systime);


//variables for all who was killed by me, and who killed me (and time of my death)
alias myKills [];
alias lastKiller "";
alias lastKillerTime 0;

//fast execution of scripts in scripts directory (click "Z" and you will get list of files in this dir)
newmenu scripts;
menudirlist "scripts" cfg [exec (concatword "scripts/" $arg1 ".cfg")]
bind z [showmenu scripts]

//every time when anybody connects to server I get my new CN
alias onConnect [
  alias mycn (findcn $curname)
];

//now onMessage is available (fires every time you got message from anybody)
//$arg1 - CN of writer
//$arg2 - message text
alias onMessage []
alias scanConsole [
  alias messageNamePos (strpos $conline ":");
  if (!= $messageNamePos -1) [
    alias messageName (substr $conline 0 $messageNamePos);
    alias messageCN (findcn $messageName);
    if (!= $messageCN -1) [
      onMessage $messageCN (substr $conline (+ $messageNamePos 1))
    ]
  ]
  sleep 100 scanConsole 1
]
scanConsole;


//every second I delete from list of my kills all who was killed more then 10 seconds ago.
//So, if anybody killed me and said "sorry" after 20 seconds, I will answer nothing
alias clearKills [
  if (&& (!= $lastKillerTime 0) (> (- systime $lastKillerTime) 10)) [alias lastKiller ""]
  alias stNxtKilled (strpos $myKills ":");
  alias eNxtKilled (- (strpos $myKills "|K|") $stNxtKilled);
  alias killedName (substr $myKills 0 $stNxtKilled);
  alias killedTime (substr $myKills (+ $stNxtKilled 1) (- $eNxtKilled 1));
  if (&& (!= $eNxtKilled 0) (> (- (systime) $killedTime) 10)) [
    alias myKills (substr $myKills (+ (+ $stNxtKilled $eNxtKilled) 3));
  ]
  sleep 1000 clearKills 1;
]
clearKills;

//========================================================//
//                    ONMESSAGE ALIAS                    //
//========================================================//

//now onMessage is available (fires every time you got message from anybody)
//$arg1 - CN of writer
//$arg2 - message text
alias onMessage []
alias scanConsole [
  alias messageNamePos (strpos $conline ":");
  if (!= $messageNamePos -1) [
    alias messageName (substr $conline 0 $messageNamePos);
    alias messageCN (findcn $messageName);
    if (!= $messageCN -1) [
      onMessage $messageCN (substr $conline (+ $messageNamePos 1))
    ]
  ]
  sleep 100 scanConsole 1
]
scanConsole;



alias onKill [
  alias aTeam (curteam $arg1);
  alias bTeam (curteam $arg2);
  alias teams (curmodeattr team);
  alias killerpn (findpn $arg1);
  alias killedpn (findpn $arg2);
 
  //if anybody killed teammate
  if (&& (= $aTeam $bTeam) (= $teams 1)) [
    //if I was killed, but not by myself
    if (&& (= $mycn $arg2) (!= $mycn $arg1)) [
     voicecom imonyourteamman (concatword $killerpn ", you killed me, man!!!!")
      alias lastKiller $arg1;
      alias lastKillerTime (systime)
    ] [
    //If I killed anybody (teammate)
      if (&& (= $mycn $arg1) (!= $mycn $arg2)) [
        voicecom sorry (concatword $killedpn ", sorry! I didn't want to kill you.")
      ]
    ]
  ] [
   
    //if I killed enemy, I remember him for autoanswers
    if (= $mycn $arg1) [
      alias myKills (concatword $myKills $arg2 ":" (systime) "|K|");
    ]
  ]
];

alias onHit [
  alias aTeam (curteam $arg1); //Hiter team
  alias bTeam (curteam $arg2); //Hited team
  alias teams (curmodeattr team);
  alias hiterpn (findpn $arg1);
  alias hitedpn (findpn $arg2);
    //here I show damage on the screen. delete it if you don't need this.
    if (= $mycn $arg1) [
      if (|| (> (- (systime) $lastDamageTime) 2) (!= $lastHited $arg2)) [alias damage 0;]
      alias damage (+ $arg3 $damage);
      hudecho (c 1)(concat "damage:" $damage);
      alias lastDamageTime (systime);
      alias lastHited $arg2;
    ]
  ];

//Asks for help when I get the flag
alias onFlag [
  alias gpn (findpn $arg2)
  alias ate (curteam $arg2)
  if (&& (= $arg1 0) (= $mycn $arg2)) [voicecom coverme "I've got the flag! Help me please."]
  if (&&& (= $arg1 4) (= (curteam) $ate) (!= $arg2 $mycn) (= 1 1)) [voicecom goodjobteam (concat "Good job,"  $gpn) ]
  if (&&& (= $arg1 4) (= (curteam) $ate) (= $arg2 $mycn) (= 1 1)) [voicecom goodjobteam ]
]
Enjoy Cool


Last edited by .VM|EnV on Mon Jul 20, 2015 11:20 am; edited 1 time in total
Back to top Go down
View user profile
|HP|
Admin


Messages : 226
Joined/Date d'inscription : 2010-06-01

Gema stats
farthest jump: MAX

PostSubject: Re: Some useful scripts..   Mon Jul 20, 2015 10:12 am

cool thx
Back to top Go down
View user profile
.VM|EnV



Messages : 17
Joined/Date d'inscription : 2015-07-19
Age : 21
Location/Localisation : Greece

PostSubject: Re: Some useful scripts..   Mon Jul 20, 2015 10:25 am

No prob ^^
Back to top Go down
View user profile
Ced8665



Messages : 3
Joined/Date d'inscription : 2015-08-23

PostSubject: Re: Some useful scripts..   Sun Aug 23, 2015 11:39 am

Hum where are you find that? Very Happy
Back to top Go down
View user profile
JagArNoob!!!



Messages : 48
Joined/Date d'inscription : 2015-06-28
Age : 21
Location/Localisation : Rio de Janeiro - Brazil

Gema stats
farthest jump: almost 6 cubes

PostSubject: Re: Some useful scripts..   Sun Sep 20, 2015 10:40 am

nice
Back to top Go down
View user profile
Sponsored content




PostSubject: Re: Some useful scripts..   Today at 7:25 pm

Back to top Go down
 
Some useful scripts..
View previous topic View next topic Back to top 
Page 1 of 1
 Similar topics
-
» Translate the site
» Happy New Year everyone.
» Application - Lokked
» Hello and Help!
» Awesome (FREE) gun script!

Permissions in this forum:You cannot reply to topics in this forum
gema :: International :: Scripts-
Jump to: