Syncope.T-*
Published 2011. 12. 8. 20:21
[12] 장풍예제 Steam/Sourcemod
728x90



//인클루드문장
#include <sourcemod>
#include <sdktools>
#include <cstrike>
#include "sdkhooks"

//문법정의
#pragma semicolon 1

//칼빵에 어느정도의 데미지를 추가할 것인가(음수로하면 데미지가 줄어듬, 그러나 추천하지 않음(그렇게 해서 실제 공력이 음수가 되면 체가 도로 차게되니까))
#define KNIFEDAMAGEINC 7000

//장풍의 세기는 어느정도로 할 것인가
#define KNIFEKNOCKBACKSCALE 1000.5545671

//장풍을 쓸때 날 소리의 이름 예시 : "npc/turret_floor/alarm.wav"
//다운로드설정도 이 플러그인이 해 주니까 이건 sm_downloader설정 필요 없음 파일만 제대로 지정해주면 되요
new const String:KNIFESOUND[] = "ambient/explosions/explode_7.wav";

//화면 중앙 텍스트의 구조는 (firststring)(공격자이름)(middlestring)(목표이름)(laststring)이다. 각 요소 사이에 빈칸을 넣지 않으므로 스스로 고려해서 빈칸도 넣어줘야한다
new const String:firststring[64] = "시원한 한방! ";
new const String:middlestring[64] = " --> ";
new const String:laststring[64] = " 퍼퍼퍼퍼펑";

public OnMapStart(){
 
 PrecacheSound(KNIFESOUND);
 decl String:file3[64];
 Format(file3, 63, "sound/%s", KNIFESOUND);
 AddFileToDownloadsTable(file3);
 
}

public OnClientPutInServer(client){
 
 SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamageHook);
 
}

stock bool:IsClientConnectedIngameAlive(client){
 
 if(client > 0 && client <= MaxClients){
 
  if(IsClientConnected(client) == true){
    
   if(IsClientInGame(client) == true){
     
    if(IsPlayerAlive(client) == true && IsClientObserver(client) == false){
     
     return true;
     
    }else{
     
     return false;
     
    }
    
   }else{
    
    return false;
    
   }
   
  }else{
     
   return false;
     
  }
  
 }else{
  
  return false;
 
 }
 
}

//클라이언트 상태 체크 2개를 한꺼번에 해주는 함수
//클라이언트가 게임 안에 있는지까지 검사한다.
stock bool:IsClientConnectedIngame(client){
 
 if(client > 0 && client <= MaxClients){
 
  if(IsClientConnected(client) == true){
   
   if(IsClientInGame(client) == true){
   
    return true;
    
   }else{
    
    return false;
    
   }
   
  }else{
     
   return false;
     
  }
  
 }else{
  
  return false;
  
 }
 
}

//데미지 판정을 위한 처리
public Action:OnTakeDamageHook(client, &attacker, &inflictor, &Float:damage, &damagetype){

 if(attacker == 0){
 
  
  
 }else if(IsClientConnectedIngame(client) && IsClientConnectedIngame(attacker)){
 
  decl String:s_Weapon[32];
  GetEdictClassname(inflictor, s_Weapon, 32);
  
  if(!StrEqual(s_Weapon, "player")){
    
   return Plugin_Continue;
    
  }else{
   
   if(GetClientTeam(client) == GetClientTeam(attacker)){
    
    return Plugin_Continue;
    
   }
    
   GetClientWeapon(attacker, s_Weapon, 32); 
   
   if(StrEqual(s_Weapon, "weapon_knife")){
    
    if(GetClientTeam(client)  == 2)
    {
    decl Float:clientposition[3], Float:targetposition[3], Float:vector[3];
    
    GetClientEyePosition(attacker, clientposition);
    GetClientEyePosition(client, targetposition);
    
    MakeVectorFromPoints(clientposition, targetposition, vector);
    NormalizeVector(vector, vector);
    ScaleVector(vector, KNIFEKNOCKBACKSCALE);
    
    TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, vector);
    
    EmitSoundToAll(KNIFESOUND ,SOUND_FROM_WORLD,SNDCHAN_AUTO,SNDLEVEL_NORMAL,SND_NOFLAGS,SNDVOL_NORMAL,SNDPITCH_NORMAL,-1,clientposition,NULL_VECTOR,true,0.0);
    
    damage += KNIFEDAMAGEINC;
    
    decl String:clientname[64], String:attackername[64];
    
    GetClientName(client, clientname, 64);
    GetClientName(attacker, attackername, 64);
    
    PrintCenterTextAll("%s%s%s%s%s", firststring, attackername, middlestring, clientname, laststring);
    
    return Plugin_Changed;
    }
   }
   
  }
  
 }
 
 return Plugin_Continue;
 
}

profile

Syncope.T-*

@Syncope

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

profile on loading

Loading...