hlmod.hu
https://hlmod.hu/

AngelScript
https://hlmod.hu/viewtopic.php?f=61&t=24414
Oldal: 1 / 2

Szerző:  DeteCT0R [2016.03.26. 12:06 ]
Hozzászólás témája:  AngelScript

Talan itt az ideje bevezetni Angelscriptet is. Svencoop mar regota hasznalja mapkhoz es szerverhez is hasznalhato :D Talan egyszer bekerul 1.6-ba is. Bar inkabb hasonlit C++ hoz mint pawnhoz.

Bar csak en foglalkozok svencoopal de azis goldscr enginhez tartozik :D


  1. CCVar@ g_pHideChat;
  2. CCVar@ g_pSilence;
  3. CCVar@ g_pTrailSize;
  4. CCVar@ g_pTrailDuration;
  5. CCVar@ g_pTrailAlpha;
  6. CScheduledFunction@ g_pThinkFunc = null;
  7. dictionary g_PlayerTrails;
  8. array<string> g_PlayerIDInfo;
  9. int g_TrailSpriteIndex;
  10.  
  11. int oldTrailSize;
  12. float oldTrailDuration;
  13. int oldTrailAlpha;
  14. void PluginInit()
  15. {
  16.     g_Module.ScriptInfo.SetAuthor("Zode");
  17.     g_Module.ScriptInfo.SetContactInfo("Zodemon @ Svencoop forums");
  18.    
  19.     g_Hooks.RegisterHook(Hooks::Player::ClientSay, @ClientSay);
  20.     g_Hooks.RegisterHook( Hooks::Player::ClientDisconnect, @ClientDisconnect );
  21.    
  22.     @g_pHideChat =      CCVar("hidechat", false, "Hide player chat when executing trail command",  ConCommandFlag::AdminOnly);
  23.     @g_pSilence =       CCVar("silence", false, "Silent plugin - only print to user instead of everybody", ConCommandFlag::AdminOnly);
  24.     @g_pTrailSize =     CCVar("trailsize", 8, "(1-255) trail size", ConCommandFlag::AdminOnly);
  25.     @g_pTrailDuration = CCVar("trailduration", 4.0f, "(float 0.1-25.5) trail duration (in seconds)", ConCommandFlag::AdminOnly);
  26.     @g_pTrailAlpha =    CCVar("trailalpha", 200, "(1-255) trail alpha", ConCommandFlag::AdminOnly);
  27. }
  28.  
  29. void TrailSizeCheck()
  30. {
  31.     if(g_pTrailSize.GetInt() <= 0)
  32.     {
  33.         g_pTrailSize.SetInt(1);
  34.         g_Game.AlertMessage( at_console, "Trail size cant be less than 1, setting cvar to 1");
  35.     }
  36.     if(g_pTrailSize.GetInt() > 255)
  37.     {
  38.         g_pTrailSize.SetInt(255);
  39.         g_Game.AlertMessage( at_console, "Trail size cant be more than 255, setting cvar to 255");
  40.     }
  41.    
  42.     if(oldTrailSize != g_pTrailSize.GetInt())
  43.     {
  44.         resetTrails();
  45.         oldTrailSize = g_pTrailSize.GetInt();
  46.     }
  47. }
  48.  
  49. void TrailDurationCheck()
  50. {
  51.     if(g_pTrailDuration.GetFloat() <= 0.0f )
  52.     {
  53.         g_pTrailDuration.SetFloat(0.1f);
  54.         g_Game.AlertMessage( at_console, "Trail duration cant be less than 0.1, setting cvar to 0.1");
  55.     }
  56.     if(g_pTrailDuration.GetFloat() > 25.5f)
  57.     {
  58.         g_pTrailDuration.SetFloat(25.5f);
  59.         g_Game.AlertMessage( at_console, "Trail duration cant be more than 25.5, setting cvar to 25.5");
  60.     }
  61.  
  62.     if(oldTrailDuration != g_pTrailDuration.GetFloat())
  63.     {
  64.         resetTrails();
  65.         oldTrailDuration = g_pTrailDuration.GetFloat();
  66.     }
  67. }
  68.  
  69. void TrailAlphaCheck()
  70. {
  71.     if(g_pTrailAlpha.GetInt() <= 0)
  72.     {
  73.         g_pTrailAlpha.SetInt(1);
  74.         g_Game.AlertMessage( at_console, "Trail alpha cant be less than 1, setting cvar to 1");
  75.     }
  76.     if(g_pTrailAlpha.GetInt() > 255)
  77.     {
  78.         g_pTrailAlpha.SetInt(255);
  79.         g_Game.AlertMessage( at_console, "Trail alpha cant be more than 255, setting cvar to 255");
  80.     }
  81.  
  82.     if(oldTrailAlpha != g_pTrailAlpha.GetInt())
  83.     {
  84.         resetTrails();
  85.         oldTrailAlpha = g_pTrailAlpha.GetInt();
  86.     }
  87. }
  88.  
  89. class PlayerTrailData
  90. {
  91.     int id;
  92.     Vector color;
  93.     bool restart;
  94. }
  95.  
  96. void MapInit()
  97. {
  98.     g_TrailSpriteIndex = g_Game.PrecacheModel("sprites/zbeam3.spr");
  99.  
  100.     g_PlayerTrails.deleteAll();
  101.    
  102.     g_PlayerIDInfo.resize(0); // clear up array, thanks solokiller!
  103.    
  104.     if(g_pThinkFunc !is null) { g_Scheduler.RemoveTimer(g_pThinkFunc); }
  105.    
  106.     @g_pThinkFunc = g_Scheduler.SetInterval("trailThink", 0.3f);
  107.    
  108.         //lmao couldnt figure out callbacks for ccvars
  109.     TrailSizeCheck();
  110.     TrailDurationCheck();
  111.     TrailAlphaCheck();
  112. }
  113.  
  114. HookReturnCode ClientSay(SayParameters@ pParams)
  115. {  
  116.     CBasePlayer@ pPlayer = pParams.GetPlayer();
  117.     const CCommand@ pArguments = pParams.GetArguments();
  118.     bool bSilent = g_pSilence.GetBool();
  119.    
  120.     int iTrailSize = g_pTrailSize.GetInt();
  121.     int iTrailDuration = int(g_pTrailDuration.GetFloat()*10);
  122.     int iTrailAlpha = g_pTrailAlpha.GetInt();
  123.    
  124.     //lmao couldnt figure out callbacks for ccvars
  125.     TrailSizeCheck();
  126.     TrailDurationCheck();
  127.     TrailAlphaCheck();
  128.    
  129.     if(pArguments.ArgC() >=2)
  130.     {
  131.         if(pArguments.Arg(0) == "trail")
  132.         {
  133.             pParams.ShouldHide = g_pHideChat.GetBool();
  134.            
  135.             if(pArguments.Arg(1) == "off") // turn off trail
  136.             {
  137.                 if(bSilent)
  138.                 {
  139.                     g_PlayerFuncs.ClientPrint(pPlayer, HUD_PRINTTALK, "[Trail] You no longer have a trail.");
  140.                 }else{
  141.                     g_PlayerFuncs.ClientPrintAll(HUD_PRINTTALK, "[Trail] " + pPlayer.pev.netname + " no longer has a trail.");
  142.                 }
  143.                
  144.                 removeTrail(pPlayer);
  145.                
  146.             }else{  // handle colors   
  147.                 // ewww elseif nest
  148.                 if(pArguments.Arg(1) == "red")
  149.                 {
  150.                     if(bSilent)
  151.                     {
  152.                         g_PlayerFuncs.ClientPrint(pPlayer, HUD_PRINTTALK, "[Trail] You now have a red trail.");
  153.                     }else{
  154.                         g_PlayerFuncs.ClientPrintAll(HUD_PRINTTALK, "[Trail] " + pPlayer.pev.netname + " now has a red trail.");
  155.                     }
  156.                    
  157.                     addTrail(pPlayer, iTrailSize, iTrailDuration, iTrailAlpha, Vector(255,0,0));
  158.                 }else if(pArguments.Arg(1) == "orange")
  159.                 {
  160.                     if(bSilent)
  161.                     {
  162.                         g_PlayerFuncs.ClientPrint(pPlayer, HUD_PRINTTALK, "[Trail] You now have an orange trail.");
  163.                     }else{
  164.                         g_PlayerFuncs.ClientPrintAll(HUD_PRINTTALK, "[Trail] " + pPlayer.pev.netname + " now has an orange trail.");
  165.                     }
  166.                    
  167.                     addTrail(pPlayer, iTrailSize, iTrailDuration, iTrailAlpha, Vector(255,128,0));
  168.                 }else if(pArguments.Arg(1) == "yellow")
  169.                 {
  170.                     if(bSilent)
  171.                     {
  172.                         g_PlayerFuncs.ClientPrint(pPlayer, HUD_PRINTTALK, "[Trail] You now have an yellow trail.");
  173.                     }else{
  174.                         g_PlayerFuncs.ClientPrintAll(HUD_PRINTTALK, "[Trail] " + pPlayer.pev.netname + " now has an yellow trail.");
  175.                     }
  176.                    
  177.                     addTrail(pPlayer, iTrailSize, iTrailDuration, iTrailAlpha, Vector(255,255,0));
  178.                 }else if(pArguments.Arg(1) == "lime")
  179.                 {
  180.                     if(bSilent)
  181.                     {
  182.                         g_PlayerFuncs.ClientPrint(pPlayer, HUD_PRINTTALK, "[Trail] You now have a lime trail.");
  183.                     }else{
  184.                         g_PlayerFuncs.ClientPrintAll(HUD_PRINTTALK, "[Trail] " + pPlayer.pev.netname + " now has a lime trail.");
  185.                     }
  186.                    
  187.                     addTrail(pPlayer, iTrailSize, iTrailDuration, iTrailAlpha, Vector(128,255,0));
  188.                 }else if(pArguments.Arg(1) == "green")
  189.                 {
  190.                     if(bSilent)
  191.                     {
  192.                         g_PlayerFuncs.ClientPrint(pPlayer, HUD_PRINTTALK, "[Trail] You now have a green trail.");
  193.                     }else{
  194.                         g_PlayerFuncs.ClientPrintAll(HUD_PRINTTALK, "[Trail] " + pPlayer.pev.netname + " now has a green trail.");
  195.                     }
  196.                
  197.                     addTrail(pPlayer, iTrailSize, iTrailDuration, iTrailAlpha, Vector(0,255,0));
  198.                 }else if(pArguments.Arg(1) == "turquoise")
  199.                 {
  200.                     if(bSilent)
  201.                     {
  202.                         g_PlayerFuncs.ClientPrint(pPlayer, HUD_PRINTTALK, "[Trail] You now have a turquoise trail.");
  203.                     }else{
  204.                         g_PlayerFuncs.ClientPrintAll(HUD_PRINTTALK, "[Trail] " + pPlayer.pev.netname + " now has a turquoise trail.");
  205.                     }
  206.                    
  207.                     addTrail(pPlayer, iTrailSize, iTrailDuration, iTrailAlpha, Vector(0,255,200));
  208.                 }else if(pArguments.Arg(1) == "cyan")
  209.                 {
  210.                     if(bSilent)
  211.                     {
  212.                         g_PlayerFuncs.ClientPrint(pPlayer, HUD_PRINTTALK, "[Trail] You now have a cyan trail.");
  213.                     }else{
  214.                         g_PlayerFuncs.ClientPrintAll(HUD_PRINTTALK, "[Trail] " + pPlayer.pev.netname + " now has a cyan trail.");
  215.                     }
  216.                    
  217.                     addTrail(pPlayer, iTrailSize, iTrailDuration, iTrailAlpha, Vector(0,128,255));
  218.                 }else if(pArguments.Arg(1) == "blue")
  219.                 {
  220.                     if(bSilent)
  221.                     {
  222.                         g_PlayerFuncs.ClientPrint(pPlayer, HUD_PRINTTALK, "[Trail] You now have a blue trail.");
  223.                     }else{
  224.                         g_PlayerFuncs.ClientPrintAll(HUD_PRINTTALK, "[Trail] " + pPlayer.pev.netname + " now has a blue trail.");
  225.                     }
  226.                    
  227.                     addTrail(pPlayer, iTrailSize, iTrailDuration, iTrailAlpha, Vector(0,0,255));
  228.                 }else if(pArguments.Arg(1) == "purple")
  229.                 {
  230.                     if(bSilent)
  231.                     {
  232.                         g_PlayerFuncs.ClientPrint(pPlayer, HUD_PRINTTALK, "[Trail] You now have a purple trail.");
  233.                     }else{
  234.                         g_PlayerFuncs.ClientPrintAll(HUD_PRINTTALK, "[Trail] " + pPlayer.pev.netname + " now has a purple trail.");
  235.                     }
  236.                    
  237.                     addTrail(pPlayer, iTrailSize, iTrailDuration, iTrailAlpha, Vector(128,0,255));
  238.                 }else if(pArguments.Arg(1) == "pink")
  239.                 {
  240.                     if(bSilent)
  241.                     {
  242.                         g_PlayerFuncs.ClientPrint(pPlayer, HUD_PRINTTALK, "[Trail] You now have a pink trail.");
  243.                     }else{
  244.                         g_PlayerFuncs.ClientPrintAll(HUD_PRINTTALK, "[Trail] " + pPlayer.pev.netname + " now has a pink trail.");
  245.                     }
  246.                    
  247.                     addTrail(pPlayer, iTrailSize, iTrailDuration, iTrailAlpha, Vector(255,0,255));
  248.                 }else if(pArguments.Arg(1) == "white")
  249.                 {
  250.                     if(bSilent)
  251.                     {
  252.                         g_PlayerFuncs.ClientPrint(pPlayer, HUD_PRINTTALK, "[Trail] You now have a white trail.");
  253.                     }else{
  254.                         g_PlayerFuncs.ClientPrintAll(HUD_PRINTTALK, "[Trail] " + pPlayer.pev.netname + " now has a white trail.");
  255.                     }
  256.                    
  257.                     addTrail(pPlayer, iTrailSize, iTrailDuration, iTrailAlpha, Vector(255,255,255));
  258.                 }else{
  259.                     if(bSilent)
  260.                     {
  261.                         g_PlayerFuncs.ClientPrint(pPlayer, HUD_PRINTTALK, "[Trail] No such color.");
  262.                     }else{
  263.                         if(g_pHideChat.GetBool() == false)
  264.                         {
  265.                         g_PlayerFuncs.ClientPrintAll(HUD_PRINTTALK, "[Trail] No such color.");
  266.                         }else{
  267.                         g_PlayerFuncs.ClientPrint(pPlayer, HUD_PRINTTALK, "[Trail] No such color.");
  268.                         }
  269.                     }
  270.                 }
  271.             }
  272.             return HOOK_HANDLED;
  273.         }
  274.     }
  275.     return HOOK_CONTINUE;
  276. }
  277.  
  278. HookReturnCode ClientDisconnect(CBasePlayer@ pPlayer)
  279. {
  280.     string szSteamId = g_EngineFuncs.GetPlayerAuthId( pPlayer.edict() );
  281.     if(g_PlayerTrails.exists(szSteamId))
  282.     {
  283.         g_PlayerTrails.delete(szSteamId);
  284.         g_PlayerIDInfo.removeAt(g_PlayerIDInfo.find(szSteamId));
  285.     }
  286.    
  287.     return HOOK_CONTINUE;
  288. }
  289.  
  290. void trailThink()
  291. {
  292.         //lmao couldnt figure out callbacks for ccvars
  293.     TrailSizeCheck();
  294.     TrailDurationCheck();
  295.     TrailAlphaCheck();
  296.    
  297.     // check vel difference
  298.     for(uint i = 0; i < g_PlayerIDInfo.length(); i++)
  299.     {
  300.         PlayerTrailData@ data = cast<PlayerTrailData@>(g_PlayerTrails[g_PlayerIDInfo[i]]);
  301.         CBasePlayer@ pPlayer = g_PlayerFuncs.FindPlayerByIndex(data.id);
  302.        
  303.         Vector tempVel = pPlayer.pev.velocity;
  304.         bool tempBool = false;
  305.        
  306.         if(tempVel.x == 0 && tempVel.y == 0 && tempVel.z == 0) { data.restart = true; }
  307.  
  308.         if(data.restart)
  309.         {
  310.             if(tempVel.x >= 2) { tempBool = true; }
  311.             if(tempVel.y >= 2) { tempBool = true; }
  312.             if(tempVel.z >= 2) { tempBool = true; }
  313.         }
  314.        
  315.         if(tempBool)
  316.         {
  317.             data.restart = false;
  318.             int pID = g_EntityFuncs.EntIndex(pPlayer.edict());
  319.             killMsg(pID);
  320.             trailMsg(pPlayer, g_pTrailSize.GetInt(), int(g_pTrailDuration.GetFloat()*10), g_pTrailAlpha.GetInt(), data.color);
  321.         }
  322.     }
  323. }
  324.  
  325. void resetTrails()
  326. {
  327.     for(uint i = 0; i < g_PlayerIDInfo.length(); i++)
  328.     {
  329.         PlayerTrailData@ data = cast<PlayerTrailData@>(g_PlayerTrails[g_PlayerIDInfo[i]]);
  330.         CBasePlayer@ pPlayer = g_PlayerFuncs.FindPlayerByIndex(data.id);
  331.        
  332.         killMsg(data.id);
  333.         trailMsg(pPlayer, g_pTrailSize.GetInt(), int(g_pTrailDuration.GetFloat()*10), g_pTrailAlpha.GetInt(), data.color);
  334.     }
  335. }
  336.  
  337. void addTrail(CBasePlayer@ pPlayer, int trailSize, int trailDuration, int trailAlpha, Vector color)
  338. {
  339.     string szSteamId = g_EngineFuncs.GetPlayerAuthId( pPlayer.edict() );
  340.     if(g_PlayerTrails.exists(szSteamId))
  341.     {
  342.         PlayerTrailData@ data = cast<PlayerTrailData@>(g_PlayerTrails[szSteamId]);
  343.         int pID = g_EntityFuncs.EntIndex(pPlayer.edict());
  344.         data.color = color;
  345.         data.restart = false;
  346.        
  347.         killMsg(pID); // set trail
  348.         trailMsg(pPlayer, trailSize, trailDuration, trailAlpha, color);
  349.     }else{
  350.         PlayerTrailData data; // add trail
  351.         data.id = g_EntityFuncs.EntIndex(pPlayer.edict());
  352.         data.color = color;
  353.         data.restart = false;
  354.    
  355.         g_PlayerIDInfo.insertLast(szSteamId);
  356.         g_PlayerTrails[szSteamId] = data;
  357.        
  358.         trailMsg(pPlayer, trailSize, trailDuration, trailAlpha, color);
  359.     }
  360. }
  361.  
  362. void trailMsg(CBasePlayer@ pPlayer, int trailSize, int trailDuration, int trailAlpha, Vector color)
  363. {
  364.     int pID = g_EntityFuncs.EntIndex(pPlayer.edict());
  365.     // send trail message
  366.     NetworkMessage message(MSG_BROADCAST, NetworkMessages::SVC_TEMPENTITY, null);
  367.         message.WriteByte(TE_BEAMFOLLOW);
  368.         message.WriteShort(pID);
  369.         message.WriteShort(g_TrailSpriteIndex);
  370.         message.WriteByte(trailDuration);
  371.         message.WriteByte(trailSize);
  372.         message.WriteByte(int(color.x));
  373.         message.WriteByte(int(color.y));
  374.         message.WriteByte(int(color.z));
  375.         message.WriteByte(trailAlpha);
  376.     message.End();
  377. }
  378.  
  379. void removeTrail(CBasePlayer@ pPlayer)
  380. {
  381.     string szSteamId = g_EngineFuncs.GetPlayerAuthId( pPlayer.edict() );
  382.     g_PlayerTrails.delete(szSteamId);
  383.     g_PlayerIDInfo.removeAt(g_PlayerIDInfo.find(szSteamId));
  384.     int pID = g_EntityFuncs.EntIndex(pPlayer.edict());
  385.     killMsg(pID);
  386. }
  387.  
  388. void killMsg(int id)
  389. {
  390.     // send kill trail message
  391.     NetworkMessage message(MSG_BROADCAST, NetworkMessages::SVC_TEMPENTITY, null);
  392.         message.WriteByte(TE_KILLBEAM);
  393.         message.WriteShort(id);
  394.     message.End();
  395.    
  396. }

Szerző:  The Peace [2016.03.26. 12:15 ]
Hozzászólás témája:  Re: AngelScript

És ez pontosan mire is szolgálna az 1.6 világban? :D

Szerző:  DeteCT0R [2016.03.26. 12:16 ]
Hozzászólás témája:  Re: AngelScript

Idézet:
Talan egyszer bekerul 1.6-ba is.

Szerző:  kiki [2016.03.28. 17:38 ]
Hozzászólás témája:  Re: AngelScript

DeteCT0R írta:
Talan itt az ideje bevezetni Angelscriptet is. Svencoop mar regota hasznalja mapkhoz es szerverhez is hasznalhato :D Talan egyszer bekerul 1.6-ba is. Bar inkabb hasonlit C++ hoz mint pawnhoz.

Bar csak en foglalkozok svencoopal de azis goldscr enginhez tartozik :D



Nem néz ki bonyolultnak. Melyik fórumrészre gondoltad? Csinálnál leírásokat, letöltéseket, meg töltenél fel pluginokat, akkor lehet róla szó.

Szerző:  DeteCT0R [2016.03.28. 18:08 ]
Hozzászólás témája:  Re: AngelScript

Nemtudom hova sorolni meg nekem is uj ugy ahogy svencoop is de azt tudom hogy mapscriptkent is lehet hasznalni svencoopba.

Szerző:  csongika [2016.03.28. 18:30 ]
Hozzászólás témája:  Re: AngelScript

Nem rossz :D :P

Szerző:  DeteCT0R [2016.03.30. 17:12 ]
Hozzászólás témája:  Re: AngelScript

kiki írta:
DeteCT0R írta:
Talan itt az ideje bevezetni Angelscriptet is. Svencoop mar regota hasznalja mapkhoz es szerverhez is hasznalhato :D Talan egyszer bekerul 1.6-ba is. Bar inkabb hasonlit C++ hoz mint pawnhoz.

Bar csak en foglalkozok svencoopal de azis goldscr enginhez tartozik :D



Nem néz ki bonyolultnak. Melyik fórumrészre gondoltad? Csinálnál leírásokat, letöltéseket, meg töltenél fel pluginokat, akkor lehet róla szó.

Minimalisan ertek hozza. Leiras is minimalis de megteszem amit lehet bar nemtudom hova lehet rakni :D

Szerző:  Akosch:. [2016.03.30. 17:58 ]
Hozzászólás témája:  Re: AngelScript

Esetleg, ha segítenek valamit:
http://codeplea.com/game-scripting-languages
http://www.angelcode.com/angelscript/sdk/docs/manual/index.html

Svencoopon kívül használható más goldsrc -s játékhoz?

Szerző:  kiki [2016.03.30. 18:27 ]
Hozzászólás témája:  Re: AngelScript

Akosch:. írta:
Esetleg, ha segítenek valamit:
http://codeplea.com/game-scripting-languages
http://www.angelcode.com/angelscript/sdk/docs/manual/index.html

Svencoopon kívül használható más goldsrc -s játékhoz?


Igaz, bár szerintem időt szánni rá felesleges.

Szerző:  DeteCT0R [2016.03.30. 19:54 ]
Hozzászólás témája:  Re: AngelScript

Half life talan. Nemvagyok biztos benne.

Csak azert ajanlottam mert Svencoop is gldscr jatek viszont ezelotti verziok csak modkent leteztek viszont az 5.0 verzio kijott steamra es amxx-et mar nem szereti ezert jott be az Angelscript.

Oldal: 1 / 2 Minden időpont UTC+02:00 időzóna szerinti
Powered by phpBB® Forum Software © phpBB Limited
https://www.phpbb.com/