Raised This Month: $51 Target: $400
 12% 

Solved help tp_player.smx Plug-ins optimize


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AK978
Senior Member
Join Date: Jun 2018
Old 01-23-2020 , 02:55   help tp_player.smx Plug-ins optimize
Reply With Quote #1

help tp_player.smx Plug-ins optimize.

for(new i = 1;i <= MaxClients; i++) many.
Attached Files
File Type: sp Get Plugin or Get Source (tp_player.sp - 92 views - 3.2 KB)

Last edited by AK978; 01-23-2020 at 05:35.
AK978 is offline
JeremyDF93
Junior Member
Join Date: Dec 2019
Old 01-23-2020 , 04:44   Re: help tp_player.smx Plug-ins optimize
Reply With Quote #2

I'm not 100% sure what you wanted done because your post has no information on what your problem is, so I just re-wrote the whole thing to be more "optimized"
PHP Code:
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>
#include <sdktools>

public void OnPluginStart() {
  
LoadTranslations("common.phrases");

  
RegConsoleCmd("sm_tp2"ConCmd_Teleport);
}

public 
Action ConCmd_Teleport(int clientint args) {
  if (
IsValidClient(client)) {
    
Menu_DisplayTeleport(client);
  }

  return 
Plugin_Handled;
}

void Menu_DisplayTeleport(int client) {
  
Menu menu = new Menu(Menu_HandleTeleport);
  
menu.SetTitle("選擇傳送玩家");

  
int clients AddTeamToMenu(menuclient);
  if (
clients == 0) {
    
PrintToChat(client"%t""No matching clients");
    
delete menu;
    return;
  }

  
menu.Display(clientMENU_TIME_FOREVER);
}

public 
int Menu_HandleTeleport(Menu menuMenuAction actionint clientint item) {
  if (
action == MenuAction_Select) {
    
char info[32];
    
menu.GetItem(iteminfosizeof(info));
    
int target GetClientOfUserId(StringToInt(info));

    if (!
IsValidClient(target)) {
      
PrintToChat(client"%t""Player no longer available");
    } else {
      
Menu_DisplayConfirm(targetclient);
    }
  }
}

void Menu_DisplayConfirm(int clientint origin) {
  
Menu menu = new Menu(Menu_HandleConfirm);
  
menu.SetTitle("是否接受玩家的傳送");

  
char origin_id[12];
  
IntToString(GetClientUserId(origin), origin_idsizeof(origin_id));
  
menu.AddItem(origin_id"Yes");
  
menu.AddItem(origin_id"No");

  
menu.Display(clientMENU_TIME_FOREVER);
}

public 
int Menu_HandleConfirm(Menu menuMenuAction actionint clientint item) {
  if (
action == MenuAction_Select) {
    
char origin_id[32];
    
menu.GetItem(itemorigin_idsizeof(origin_id));
    
int origin GetClientOfUserId(StringToInt(origin_id));

    if (!
IsValidClient(origin)) return;
    if (!
IsValidClient(client)) return;

    if (
item == 0) { // 0 = Yes, 1 = No
      
float origin_pos[3], client_pos[3];
      
GetClientAbsOrigin(originorigin_pos);
      
client_pos[0] = origin_pos[0];
      
client_pos[1] = origin_pos[1];
      
client_pos[2] = (origin_pos[2] + 73);

      
TeleportEntity(clientclient_posNULL_VECTORNULL_VECTOR);
      
PrintToChat(origin"玩家 %N 傳送成功"client);
    } else {
      
PrintToChat(origin ,"玩家 %N 拒絕你的傳送要求"client);
    }
  }
}

stock bool IsValidClient(int client) {
  if (
client <= || client MaxClients) return false;
  if (!
IsClientInGame(client)) return false;

  return 
true;
}

stock int AddTeamToMenu(Menu menuint client) {
  
int num_clients;
  
char user_id[12], name[MAX_NAME_LENGTH];

  for (
int i 1<= MaxClientsi++) {
    if (
== client) continue;
    if (!
IsValidClient(i)) continue;
    if (!
IsPlayerAlive(i)) continue;
    if (
IsFakeClient(i)) continue;
    if (
GetClientTeam(i) != GetClientTeam(client)) continue;

    
IntToString(GetClientUserId(i), user_idsizeof(user_id));
    
GetClientName(inamesizeof(name));
    
menu.AddItem(user_idname);

    
num_clients++;
  }

  return 
num_clients;

Please consider donating if this helped you!
Attached Files
File Type: sp Get Plugin or Get Source (tp_player.sp - 86 views - 2.9 KB)
__________________
Find my work helpful? Please consider donating. - Discord: Kiwi#7534

Last edited by JeremyDF93; 01-23-2020 at 05:21.
JeremyDF93 is offline
AK978
Senior Member
Join Date: Jun 2018
Old 01-23-2020 , 05:34   Re: help tp_player.smx Plug-ins optimize
Reply With Quote #3

thank for you help.
have other donate method?

Last edited by AK978; 01-23-2020 at 05:35.
AK978 is offline
JeremyDF93
Junior Member
Join Date: Dec 2019
Old 01-23-2020 , 06:05   Re: help tp_player.smx Plug-ins optimize
Reply With Quote #4

Quote:
Originally Posted by AK978 View Post
thank for you help.
have other donate method?
No problem! PM or message me on Discord (Kiwi#7534) if you need any more help!
I do have bitcoin: 37Qxcj2S7UYbqmhUxB2ndFUrK73Ct6DQh3
__________________
Find my work helpful? Please consider donating. - Discord: Kiwi#7534
JeremyDF93 is offline
AK978
Senior Member
Join Date: Jun 2018
Old 01-23-2020 , 06:17   Re: help tp_player.smx Plug-ins optimize
Reply With Quote #5

Do you have a bank account? I use transfer.
AK978 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:29.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode