Syncope.T-*
728x90


일단 이 파일은 Team Fortress 2 에 관한 내용으로 코딩 된 것.

초록색 - 선언에 관한것들
주황색 - 디파인 ( 상수 선언 )
빨간색 - 함수 호출

#include <sourcemod>
#include <sdktools>
#include <tf2_stocks>
#include <tf2>

#define MAXTRAILSPRITE 50
#define MAXHATMODEL 20

new givetrail[128]; // 트레일이 현재 켜져있는지에 관한 개인변수입니다.


#pragma semicolon 1

new beamfollowentity[64][18];

public OnPluginStart()
{
  HookEvent("player_spawn", EventSpawn);
  HookEvent("player_death", EventDeath);
  RegConsoleCmd("say", Command_say);
  RegConsoleCmd("say_team", Command_say);

}

public OnClientPutInServer(Client)
{
 CreateTimer(5.0, Load, Client);
}
public Action:Load(Handle:Timer, any:Client)
{
 givetrail[Client] = 0;
}


public Action:Command_say(Client, args)
{
/*
 decl String:text[192];
 if(GetCmdArgString(text, sizeof(text))<1)
 {
  return Plugin_Continue;
 }
 new startidx;
 if(text[strlen(text)-1]=='"')
 {
  text[strlen(text)-1] = '\0';
  startidx = 1;
 }
 decl String:message[8];
 BreakString(text[startidx], message, sizeof(message));
 new TFClassType:class = TF2_GetPlayerClass(Client);
 if (class != TFClass_Spy)
 {
  if (strcmp(message, "!트레일켜기", false) == 0)
  {
   createbeamfollow(Client); // !트레일켜기 라고 입력하면 이 함수로 이동합니다.
  }
  if (strcmp(message, "!트레일끄기", false) == 0)
  {
   deletebeamfollow(Client); !트레일끄기 라고 입력하면 이 함수로 이동합니다.
  }
 }
 else PrintToChat(Client, "\x04[Duck]\x03 스파이는 이용하실수가 없습니다.");
*/

 new String:Msg[256];
 GetCmdArgString(Msg, sizeof(Msg));
 Msg[strlen(Msg)-1] = '\0';

 if(StrEqual(Msg[1], "!트레일켜기", false))
 {
  new TFClassType:class = TF2_GetPlayerClass(Client);
  if (class != TFClass_Spy)
  {
   createbeamfollow(Client);
   givetrail[Client] = 1;
  }
 }
 if(StrEqual(Msg[1], "!트레일끄기", false))
 {
  new TFClassType:class = TF2_GetPlayerClass(Client);
  if (class != TFClass_Spy)
  {
   deletebeamfollow(Client);
   givetrail[Client] = 0;
  }
 }
 
 return Plugin_Continue; 
}

public EventSpawn(Handle:Event, const String:Name[], bool:Broadcast)
{
 new Client = GetClientOfUserId(GetEventInt(Event, "userid"));
 function_PlayerSpawn(Client);

}

public function_PlayerSpawn(Client)
{
 new TFClassType:class = TF2_GetPlayerClass(Client);
 if (class != TFClass_Spy)
 {
  if (givetrail[Client] == 1)
  {
   createbeamfollow(Client);
  }
  else PrintToChat(Client, "\x04[Duck]\x03 언제든지 트레일을 !트레일켜기 ,!트레일끄기  로 껏다 켰다 하실수 있습니다");
 }
}

public EventDeath(Handle:Event, const String:Name[], bool:Broadcast)
{

 decl Client;

 Client = GetClientOfUserId(GetEventInt(Event, "userid"));
 
 deletebeamfollow(Client);

}

public OnClientDisconnect(Client)
{
 deletebeamfollow(Client);
}

stock createbeamfollow(Client)
{
 deletebeamfollow(Client);
 
 decl Float:Clientposition[3]; // 위치값 저장 소수 변수

 for(new i = 0; i < 6; i++) // for을 6번 돌려서 새로고침을 6번 함.
 {
  GetClientAbsOrigin(Client, Clientposition); // 플레이어 위치 구하기
  Clientposition[2] = Clientposition[2] + 10.0; // z(높이) 축으로 +10 정도하면 꼬리뼈 정도로 옴.

  new String:positionstring[128], String:colorstring[128];

  Format(positionstring, 128, "%f %f %f", Clientposition[0], Clientposition[1], Clientposition[2]);

  Format(colorstring, 128, "%d %d %d %d", GetRandomInt(0, 255), GetRandomInt(0, 255), GetRandomInt(0, 255), 255);

  beamfollowentity[Client][i] = CreateEntityByName("env_spritetrail"); // env_spritetrail 엔티티 생성.
  DispatchKeyValue(beamfollowentity[Client][i],"Origin", positionstring); // 위치는 아까 꼬리뼈
  DispatchKeyValue(beamfollowentity[Client][i], "lifetime", "1.5"); // 1.5초간 지속
  DispatchKeyValue(beamfollowentity[Client][i], "startwidth", "13.0"); // 처음 두께
  DispatchKeyValue(beamfollowentity[Client][i], "endwidth", "3.0"); // 끝 두께
  DispatchKeyValue(beamfollowentity[Client][i], "spritename", "materials/sprites/smoke.vmt"); // 트레일 이미지
  DispatchKeyValue(beamfollowentity[Client][i], "renderamt", "255"); // 빛값
  DispatchKeyValue(beamfollowentity[Client][i], "rendercolor", colorstring); // 색
  DispatchKeyValue(beamfollowentity[Client][i], "rendermode", "5"); // 렌더모드
  DispatchSpawn(beamfollowentity[Client][i]);

  SetEntPropFloat(beamfollowentity[Client][i], Prop_Send, "m_flTextureRes", 0.05);
  SetEntPropFloat(beamfollowentity[Client][i], Prop_Data, "m_flSkyboxScale", 1.0);

  new String:steamid2[64];

  GetClientAuthString(Client, steamid2, 64);
  DispatchKeyValue(Client, "targetname", steamid2);
  SetVariantString(steamid2);
  AcceptEntityInput(beamfollowentity[Client][i], "SetParent"); // 스팀아이디를 이용한 targetname 즉, 트레일 고유값을 스팀번호로 이용해 붙여넣음
// -> 이 효과는 개인마다 트레일을 가지게 해 줌. 즉 누가 한명쓰면 다른사람의 트레일이 없어지거나 하는 현상이 사라짐.
 }
}


stock deletebeamfollow(Client){
 
  for(new i = 0; i < 6; i++){
  
   if(IsValidEntity(beamfollowentity[Client][i]) && beamfollowentity[Client][i] != 0){ // 아까 개인마다 트레일 가지게해준 값이 존재한다면
   
    new String:entityclass[128];
   
    GetEdictClassname(beamfollowentity[Client][i], entityclass, sizeof(entityclass)); // 그 값을 찾아서
   
    if(StrEqual(entityclass, "env_spritetrail")){ // 값의 이름이 env_spritetrail 이면
   
     AcceptEntityInput(beamfollowentity[Client][i], "Kill"); // 제거
     beamfollowentity[Client][i] = 0; // 그 변수는 초기화.
    
    }
   
   }
  // 아래는 위와 효과는 동일. 그러나 배열이 다름.
   if(IsValidEntity(beamfollowentity[Client][i + 6]) && beamfollowentity[Client][i + 6] != 0){
   
    new String:entityclass[128];
   
    GetEdictClassname(beamfollowentity[Client][i + 6], entityclass, sizeof(entityclass));
   
    if(StrEqual(entityclass, "env_spritetrail")){
   
     AcceptEntityInput(beamfollowentity[Client][i + 6], "Kill");
     beamfollowentity[Client][i + 6] = 0;
    
    }
   
   }
   
  }
 
}

profile

Syncope.T-*

@Syncope

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!

profile on loading

Loading...