gema
Would you like to react to this message? Create an account in a few clicks or log in to continue.


A website for every gema-assaultcube fan
 
HomeHome  Latest imagesLatest images  SearchSearch  RegisterRegister  Log in  

 

 Some useful scripts..

Go down 
4 posters
AuthorMessage
.VM|EnV




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

Some useful scripts.. Empty
PostSubject: Some useful scripts..   Some useful scripts.. EmptyMon 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
|HP|
Admin
|HP|


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

Gema stats
farthest jump: MAX

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

cool thx
Back to top Go down
.VM|EnV




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

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

No prob ^^
Back to top Go down
Ced8665




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

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

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

JagArNoob!!!


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

Gema stats
farthest jump: almost 6 cubes

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

nice
Back to top Go down
Sponsored content





Some useful scripts.. Empty
PostSubject: Re: Some useful scripts..   Some useful scripts.. Empty

Back to top Go down
 
Some useful scripts..
Back to top 
Page 1 of 1
 Similar topics
-
» Grid / Random mapmodel scripts for coop

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