Guest User

Untitled

a guest
Aug 15th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. void SendDeathMessage(int id, int victim, int health, int writesocket)
  2. {
  3.  
  4. buffer[position] = 19;
  5. position++;
  6. buffer[position] = id;
  7. position++;
  8. buffer[position] = victim;
  9. position++;
  10. buffer[position] = wpnid; //player[id].actualweapon
  11. position++;
  12. memcpy(buffer + position, &player[victim].x, sizeof(unsigned short));
  13. position+= sizeof(unsigned short);
  14. memcpy(buffer + position, &player[victim].y, sizeof(unsigned short));
  15. position += sizeof(unsigned short);
  16. memcpy(buffer + position, (unsigned short)240,sizeof(unsigned short));
  17. position += sizeof(unsigned short);
  18. buffer[position] = 1;
  19.  
  20. char sHealth[4];
  21. char sArmor[4]; //= player[id].health
  22. int sHealthLength = sprintf(sHealth,"%i",(int)player[id].health);
  23. int sArmorLength = sprintf(sArmor,"%i",(int)player[id].armor);
  24. int sNameLength = strlen(player[id].name);
  25.  
  26. int length = 4 + sNameLength + sHealthLength + sArmorLength; // 4 for a6 spaces
  27.  
  28. memcpy(buffer + position,(unsigned short)length,sizeof(unsigned short));
  29. position += sizeof(unsigned short);
  30.  
  31. buffer[position] = 'k';
  32. position+=1;
  33. buffer[position] = 166; //166 acts like string seperator
  34. position+=1;
  35. memcpy(buffer + position, &player[id].name, sNameLength);
  36. position+= sNameLength;
  37. buffer[position] = 166;
  38. position++;
  39. memcpy(buffer + position, &sHealth, sHealthLength);
  40. position+= sHealthLength;
  41. buffer[position] = 166;
  42. position++;
  43. memcpy(buffer + position, &sArmor, sArmorLength);
  44. position += sArmorLength;
  45. buffer[position] = 24;
  46. position++;
  47. buffer[position] = 2;
  48. position++;
  49. buffer[position] = 2;
  50. position++;
  51. memcpy(buffer+position, (unsigned short)20,sizeof(unsigned short));
  52. position += sizeof(unsigned short);
  53. buffer[position] = 118;
  54. position++;
  55. buffer[position] = 0;
  56. position++;
  57. buffer[position] = 0;
  58. position++;
  59. buffer[position] = 1;
  60. position++;
  61. buffer[position] = 0;
  62. position++;
  63. memcpy( buffer + position,(int)(player[victim].x / 32),4);
  64. position+=4;
  65. memcpy(buffer + position,(int)(player[victim].y / 32),4);
  66. position+=4;
  67. buffer[position] = 2;
  68. position++;
  69. buffer[position] = 7;
  70. position++;
  71. buffer[position] = 1;
  72. position++;
  73. }
Add Comment
Please, Sign In to add comment