You are not logged in.

Dear visitor, welcome to sourceserver.info. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

Newbie'

Professional

  • "Newbie'" started this thread

Posts: 580

Location: Zuhause

wcf.user.option.userOption53: Nein

  • Send private message

1

Tuesday, December 3rd 2013, 1:40pm

VIP Funktion etwas erweitern

Hallo,

Vor etwa 3x Wochen hat FluxX mir folgendes Plugin privat gegen Bezahlung erstellt.

Spoiler Spoiler

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>

#define PLUGIN_VERSION "1.1"

new Handle:g_hCVWeaponSlotPrim;
new Handle:g_hCVWeaponSlotSec;
new Handle:g_hCVWeaponSlotMelee;

new Handle:g_hReFillTimer[MAXPLAYERS+1] = INVALID_HANDLE;

new bool:g_bIsDonor[MAXPLAYERS+1] = {false, ...};

public Plugin:myinfo = 
{
	name = "[TF2] Vip Ammo",
	author = "Newbie'",
	description = "",
	version = PLUGIN_VERSION,
	url = "http://steamcommunity.com/id/_Newbie_"
}

public OnPluginStart()
{
	new Handle:hVersion = CreateConVar("sm_giveammo_version", PLUGIN_VERSION, "Give Ammo Version", FCVAR_PLUGIN|FCVAR_NOTIFY|FCVAR_REPLICATED|FCVAR_DONTRECORD);
	if(hVersion != INVALID_HANDLE)
	{
		SetConVarString(hVersion, PLUGIN_VERSION);
		HookConVarChange(hVersion, OnConVarVersionChange);
	}
	
	g_hCVWeaponSlotPrim = CreateConVar("sm_giveammo_prim", "1", "Add clip on weaponslot primary?", FCVAR_PLUGIN);
	g_hCVWeaponSlotSec = CreateConVar("sm_giveammo_sec", "1", "Add clip on weaponslot secondary?", FCVAR_PLUGIN);
	g_hCVWeaponSlotMelee = CreateConVar("sm_giveammo_melee", "0", "Add clip on weaponslot melee?", FCVAR_PLUGIN);
	
	HookEvent("player_spawn", Event_OnPlayerSpawn);
}

public OnConVarVersionChange(Handle:convar, const String:oldValue[], const String:newValue[])
{
	SetConVarString(convar, PLUGIN_VERSION);
}

public OnClientPostAdminCheck(client)
{
	if(CheckCommandAccess(client, "donor_ammo_flag", ADMFLAG_RESERVATION, true))
		g_bIsDonor[client] = true;
	else
		g_bIsDonor[client] = false;
}

public OnClientDisconnect(client)
{
	g_bIsDonor[client] = false;
	g_hReFillTimer[client] = INVALID_HANDLE;
}

public Action:Event_OnPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
	new client = GetClientOfUserId(GetEventInt(event, "userid"));
	
	if(g_bIsDonor[client])
		g_hReFillTimer[client] = CreateTimer(0.5, TimerReFillWeapon, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
}

public Action:TimerReFillWeapon(Handle:timer, any:data)
{
	new client = GetClientOfUserId(data);
	
	g_hReFillTimer[client] = INVALID_HANDLE;
	
	new iWeaponSlotAmmount = -1;
	
	if(GetConVarBool(g_hCVWeaponSlotPrim))
		++iWeaponSlotAmmount;
	if(GetConVarBool(g_hCVWeaponSlotSec))
		++iWeaponSlotAmmount;
	if(GetConVarBool(g_hCVWeaponSlotMelee))
		++iWeaponSlotAmmount;
	
	new weapon = -1;
	for (new i = 0; i <= iWeaponSlotAmmount; i++)
	{
		if ((weapon = GetPlayerWeaponSlot(client, i)) != -1)
		{
			ReFillWeapon(client, weapon);
		}
	}
}

ReFillWeapon(client, weapon)
{
	decl String:sWeaponName[64];
	
	GetEdictClassname(weapon, sWeaponName, sizeof(sWeaponName));
	
	if(StrEqual(sWeaponName, "tf_weapon_jar_milk"))
		return;
	else if(StrEqual(sWeaponName, "tf_weapon_lunchbox_drink"))
		return;
	else if(StrEqual(sWeaponName, "tf_weapon_cleaver"))
		return;
	else if(StrEqual(sWeaponName, "tf_weapon_lunchbox"))
		return;
	else if(StrEqual(sWeaponName, "tf_weapon_jar"))
		return;
	
	new iPrimaryAmmoType = GetEntProp(weapon, Prop_Send, "m_iPrimaryAmmoType");
	new iSecondaryAmmoType = GetEntProp(weapon, Prop_Send, "m_iSecondaryAmmoType");

	new iAmmo1 = -1;
	new iAmmo2 = -1;

	if(iPrimaryAmmoType != -1)
	{
		if(StrEqual(sWeaponName, "tf_weapon_flamethrower") || StrEqual(sWeaponName, "tf_weapon_minigun"))
		{
			iAmmo1 = GetEntProp(client, Prop_Send, "m_iAmmo", _, iPrimaryAmmoType);
			
			if(iAmmo1 != -1)
			{
				new iNewAmmo1 = 300;
				SetEntProp(client, Prop_Send, "m_iAmmo", iNewAmmo1, _, iPrimaryAmmoType);
			}
		}
		else
		{
			iAmmo1 = GetEntProp(client, Prop_Send, "m_iAmmo", _, iPrimaryAmmoType);
			
			if(iAmmo1 != -1)
			{
				new iNewAmmo1 = 200;
				SetEntProp(client, Prop_Send, "m_iAmmo", iNewAmmo1, _, iPrimaryAmmoType);
			}
		}
	}
	if(iSecondaryAmmoType != -1)
	{
		if(StrEqual(sWeaponName, "tf_weapon_flamethrower") || StrEqual(sWeaponName, "tf_weapon_minigun"))
		{
			iAmmo2 = GetEntProp(client, Prop_Send, "m_iAmmo", _, iSecondaryAmmoType);
			
			if(iAmmo2 != -1)
			{
				new iNewAmmo2 = 300;
				SetEntProp(client, Prop_Send, "m_iAmmo", iNewAmmo2, _, iSecondaryAmmoType);
			}
		}
		else
		{
			iAmmo2 = GetEntProp(client, Prop_Send, "m_iAmmo", _, iSecondaryAmmoType);
			
			if(iAmmo2 != -1)
			{
				new iNewAmmo2 = 200;
				SetEntProp(client, Prop_Send, "m_iAmmo", iNewAmmo2, _, iSecondaryAmmoType);
			}
		}
	}
}

stock bool:IsValidClient(client)
{
	if(client < 1 || client > MaxClients)
		return false;
	if(!IsClientConnected(client))
		return false;
	return IsClientInGame(client);
}


Nun stellt sich mir in diesem nur ein kleines Problem, das Plugin ändert wie zu sehen ist die MaxAmmo aller Waffe im Spiel. Insofern die Anzeige über dem Standard Wert ist also über dem Wert was TF2 den Waffen normal an Ammo gibt ist es nicht möglich Ammo Packs und oder Metalschrott sowie fallengelassene Waffen aufzunehmen um eben damit die Munition wieder aufzustocken. FluxX selbst habe ich deswegen gefragt nur kommt er bei diesem Problem auch nicht weiter.

Deswegen würde ich euch gerne einmal fragen, man müsste doch normal nur die MaxAmmo von TF2 selbst überschreiben um dieses zu lösen hätte da wer eine Idee?

Würde mich über eine Antwort freuen.

MfG,
Newbie'