Raised This Month: $32 Target: $400
 8% 

[TF2] Really Weird Errors


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mightydifferent
Junior Member
Join Date: Aug 2017
Location: mvm_rottenburg
Old 04-16-2019 , 20:44   [TF2] Really Weird Errors
Reply With Quote #1

Code:
1 | #include <sourcemod>
2 | #include <tf2attributes>
3 | #include <multicolors>
4 | #include <tf2>
5 | #include <tf2_stocks>
6 |  
7 | 
8 | enum Upgrade
9 | {
10 | 	String: name[255],
11 | 	cash,
12 | 	max,
13 | 	Float: upgrade,
14 | 	Float: start,
15 | 	weaponIndex
16 | }
17 | 
18 | enum CurrentAttribute {
19 | 	String:name[255] = "blank",
20 | 	Float:current = 0.0,
21 | 	_:weaponIndex = 0
22 | }
23 | 
24 | new attributes[6][10][Upgrade] = {
25 | {
26 | {"dmg taken from bullets reduced", 300, 3, -0.25, 1.0, 0},
27 | {"move speed bonus", 200, 3, 0.10, 1.0, 0},
28 | {"increased jump height", 100, 3, 0.20, 1.0, 0},
29 | {"damage bonus", 400, 4, 0.2, 1.0, 1},
30 | {"Reload time decreased", 250, 3, -0.20, 1.0, 1},
31 | {"fire rate bonus", 200, 4, -0.10, 1.0, 1},
32 | {"clip size bonus", 200, 4, 0.50, 1.0, 2},
33 | {"fire rate bonus", 200, 4, -0.10, 1.0, 2},
34 | {"heal on kill", 100, 4, 25.0, 0.0, 2},
35 | {"melee attack rate bonus", 200, 4, -0.10, 1.0, 3}
36 | },
37 | {
38 | {"dmg taken from bullets reduced", 300, 3, -0.25, 1.0, 0},
39 | {"dmg taken from fire reduced", 150, 3, -0.25, 1.0, 0},
40 | {"dmg taken from blast reduced", 300, 3, -0.25, 1.0, 0},
41 | {"rocket specialist", 200, 4, 0.20, 1.0, 1},
42 | {"Reload time decreased", 250, 3, -0.20, 1.0, 1},
43 | {"fire rate bonus", 200, 4, -0.10, 1.0, 1},
44 | {"Reload time decreased", 250, 3, -0.20, 1.0, 2},
45 | {"fire rate bonus", 100, 4, -0.10, 1.0, 2},
46 | {"heal on kill", 100, 4, 25.0, 0.0, 2},
47 | {"melee attack rate bonus", 200, 4, -0.10, 1.0, 3}
48 | },
49 | {
50 | {"dmg taken from bullets reduced", 300, 3, -0.25, 1.0, 0},
51 | {"dmg taken from blast reduced", 300, 3, -0.25, 1.0, 0},
52 | {"move speed bonus", 200, 3, 0.10, 1.0, 0},
53 | {"weapon burn dmg increased", 250, 4, 0.25, 1.0, 1},
54 | {"weapon burn time increased", 250, 4, 0.25, 1.0, 1},
55 | {"maxammo primary increased", 125, 3, 0.50, 1.0, 1},
56 | {"Reload time decreased", 250, 3, -0.20, 1.0, 2},
57 | {"fire rate bonus", 100, 4, -0.10, 1.0, 2},
58 | {"heal on kill", 100, 4, 25.0, 0.0, 2},
59 | {"melee attack rate bonus", 200, 4, -0.10, 1.0, 3}
60 | },
61 | {
62 | {"dmg taken from bullets reduced", 300, 3, -0.25, 1.0, 0},
63 | {"dmg taken from blast reduced", 300, 3, -0.25, 1.0, 0},
64 | {"health regen", 200, 5, 2.0, 0.0, 0},
65 | {"damage bonus", 500, 4, 0.2, 1.0, 1},
66 | {"Reload time decreased", 250, 3, -0.20, 1.0, 1},
67 | {"fire rate bonus", 200, 4, -0.10, 1.0, 1},
68 | {"damage bonus", 500, 4, 0.2, 1.0, 2},
69 | {"Reload time decreased", 250, 3, -0.20, 1.0, 2},
70 | {"heal on kill", 200, 4, 25.0, 0.0, 2},
71 | {"melee attack rate bonus", 200, 4, -0.10, 1.0, 3}
72 | },
73 | {
74 | {"dmg taken from blast reduced", 300, 3, -0.25, 1.0, 0},
75 | {"health regen", 200, 5, 2.0, 0.0, 0},
76 | {"move speed bonus", 200, 3, 0.10, 1.0, 0},
77 | {"projectile penetration", 400, 3, 1.0, 0.0, 1},
78 | {"heal on kill", 100, 4, 25.0, 0.0, 1},
79 | {"maxammo primary increased", 125, 3, 0.50, 1.0, 1},
80 | {"heal on kill", 100, 4, 25.0, 0.0, 2},
81 | {"Reload time decreased", 250, 3, -0.20, 1.0, 2},
82 | {"fire rate bonus", 100, 4, -0.10, 1.0, 2},
83 | {"melee attack rate bonus", 200, 4, -0.10, 1.0, 3}
84 | },
85 | {
86 | {"health regen", 200, 5, 2.0, 0.0, 0},
87 | {"move speed bonus", 200, 3, 0.10, 1.0, 0},
88 | {"dmg taken from bullets reduced", 300, 3, -0.25, 1.0, 0},
89 | {"fire rate bonus", 200, 4, -0.10, 1.0, 1},
90 | {"ubercharge rate bonus", 300, 4, 0.25, 1.0, 2},
91 | {"uber duration bonus", 250, 3, 2.0, 0.0, 2},
92 | {"overheal expert", 250, 4, 1.0, 0.0, 2},
93 | {"healing mastery", 250, 4, 1.0, 0.0, 2},
94 | {"canteen specialist", 200, 3, 1.0, 0.0, 2},
95 | {"melee attack rate bonus", 200, 4, -0.10, 1.0, 3}
96 | }
97 | }
98 | 
99 | new clientAttributes[64][10][CurrentAttribute];
100 | 
101 | public OnPluginStart()
102 | {
103 | 	HookEvent("mvm_pickup_currency", Cash_Bonus);
104 | 	HookEvent("mvm_begin_wave", New_Round);
105 | 	HookEvent("post_inventory_application", Event_Inventory);
106 | 	HookEvent("mvm_mission_complete", Reset_Attributes);
107 | }
108 | 
109 | public Action:Reset_Attributes(Event:event, String:evname[], bool:dontBroadcast)
110 | {
111 | 	for(new client = 1; client <= MaxClients; client++)
112 | 	{
113 | 		if (IsClientConnected(client) && IsFakeClient(client)) {
114 | 			DeleteAttributes(client)
115 | 		}
116 | 	}
117 | }
118 | 
119 | public Action:Cash_Bonus(Event:event, String:evname[], bool:dontBroadcast)
120 | {
121 | 	for(new client = 1; client <= MaxClients; client++)
122 | 	{
123 | 		if (IsClientConnected(client) && IsFakeClient(client)) {
124 | 			new Float:adding = (3.2 * event.GetInt("currency")) + GetCash(client);
125 | 			SetCash(client, adding);
126 | 			LogAction(-1, -1, "Added %d to all bots", adding);
127 | 		}
128 | 	}
129 | }
130 | 
131 | public Action:Event_Inventory(Event:event, String:evname[], bool:dontBroadcast)
132 | {
133 | 	new client = GetClientOfUserId(event.GetInt("userid"));
134 | 	if (client < 1)
135 | 	{
136 | 		return Plugin_Continue;
137 | 	}
138 | 	if (IsClientInGame(client) && IsPlayerAlive(client) && GetClientTeam(client) == 2 && IsClientConnected(client) && IsFakeClient(client))
139 | 	{
140 | 		LoadAttributes(client);
141 | 	}
142 | 	return Plugin_Continue;
143 | }
144 | 
145 | public Action:New_Round(Event:event, String:evname[], bool:dontBroadcast)
146 | {
147 | 	for(new client = 1; client <= MaxClients; client++)
148 | 	{
149 | 		if (IsClientConnected(client) && IsFakeClient(client)) {
150 | 			while(GetCash(client) >= GetClassMinCredits(client)) {
151 | 				new i = GetRandomInt(0, sizeof(attributes)-1);
152 | 				new j = GetRandomInt(0, sizeof(attributes[])-1);
153 | 				BuyUpgrade(client, attributes[i][j])
154 | 			}
155 | 		}
156 | 	}
157 | }
158 | 
159 | public OnClientDisconnect(client)
160 | {
161 | 	DeleteAttributes(client);
162 | }
163 | 
164 | 
165 | stock LoadAttributes(client) {
166 | 	//get used slots
167 | 	for(new index = 0; index < 10; index++)
168 | 	{
169 | 		if (!strcmp(clientAttributes[client][index][name], "blank")) {
170 | 			TF2Attrib_SetByName(GetWeaponSlot(clientAttributes[client][index][weaponIndex], clientAttributes[client][index][name], clientAttributes[client][index][current]));
171 | 		}
172 | 	}
173 | }
174 | 
175 | stock DeleteAttributes(client) {
176 | 	//get used slots
177 | 	for(new index = 0; index < 10; index++)
178 | 	{
179 | 		clientAttributes[client][index][name] = "blank";
180 | 		clientAttributes[client][index][current] = 0.0;
181 | 		clientAttributes[client][index][weaponIndex] = 0;
182 | 	}
183 | }
184 | 
185 | stock BuyUpgrade(client, attribute) {
186 | 	new index = GetIndexOfAttributesByName(attribute) 
187 | 	if (GetCash(client) < attribute[cost]) {
188 | 
189 | 		//determine if next upgrade is above max
190 | 		if (clientAttributes[client][index][current] + attribute[upgrade] <= (Float(attribute[max]) * attribute[upgrade]) + attribute[start]) {
191 | 			clientAttributes[client][index][current] = clientAttributes[client][index][current] + attribute[upgrade]
192 | 		}
193 | 		SetCash(client, GetCash(client) - attribute[cost])
194 | 		LogAction(-1, -1, "'%L' buying %s", client, attribute[name]);
195 | 	}
196 | }
197 | 
198 | stock SetCash(client, iAmount)
199 | {
200 | 	if(iAmount < 0) iAmount = 0;
201 | 	SetEntProp(client, Prop_Send, "m_nCurrency", iAmount);
202 | }
203 | 
204 | stock GetCash(client)
205 | {
206 | 	return GetEntProp(client, Prop_Send, "m_nCurrency");
207 | }
208 | 
209 | stock GetWeaponSlot(client, index) {
210 | 	if (index == 0) {
211 | 		return client
212 | 	} else {
213 | 		return GetPlayerWeaponSlot(client, index-1);
214 | 	}
215 | }
216 | 
217 | stock GetClassAttributeSlot(client) {
218 | 	new TFClassType:PlayerClass = TF2_GetPlayerClass(client);
219 | 	switch(PlayerClass) {
220 | 		case TFClass_Scout: return 0;
221 | 		case TFClass_Soldier: return 1;
222 | 		case TFClass_Pyro: return 2;
223 | 		case TFClass_DemoMan: return 3;
224 | 		case TFClass_Heavy: return 4;
225 | 		case TFClass_Medic: return 5;
226 | 	}
227 | 	return -1;
228 | }
229 | 
230 | stock GetClassMinCredits(client) {
231 | 	new TFClassType:PlayerClass = TF2_GetPlayerClass(client);
232 | 	switch(PlayerClass) {
233 | 		case TFClass_Scout: return 100;
234 | 		case TFClass_Soldier: return 100;
235 | 		case TFClass_Pyro: return 100;
236 | 		case TFClass_DemoMan: return 200;
237 | 		case TFClass_Heavy: return 100;
238 | 		case TFClass_Medic: return 200;
239 | 	}
240 | 	return -1;
241 | }
242 | 
243 | 
244 | stock GetIndexOfAttributesByName(client, attribute) {
245 | 	for(new index = 0; index < 10; index++)
246 | 	{
247 | 		if (strcmp(clientAttributes[client][index][name], attribute[name])) {
248 | 			return index;
249 | 		}
250 | 	}
251 | 	new index = RawGetIndexOfAttributesByName(client, "")
252 | 	if (index == -1) {
253 | 		LogAction(-1, -1, "FATAL: GetIndexOfAttributesByName couldn't find the attribute name and couldn't find a blank space..");
254 | 	} else {
255 | 		clientAttributes[client][index][current] = attribute[start]
256 | 		clientAttributes[client][index][weaponIndex] = attribute[weaponIndex]
257 | 	}
258 | }
259 | 
260 | stock RawGetIndexOfAttributesByName(client, attributeName) {
261 | 	for(new index = 0; index < 10; index++)
262 | 	{
263 | 		if (strcmp(clientAttributes[client][index][name], attributeName)) {
264 | 			return index;
265 | 		}
266 | 	}
267 | 	return -1;
268 | }
these are the errors
PHP Code:
// a.sp(152) : error 001: expected token: "]", but found "-identifier-"
// a.sp(152) : warning 215: expression has no effect
// a.sp(152) : error 001: expected token: ";", but found "]"
// a.sp(152) : error 029: invalid expression, assumed zero
// a.sp(152) : fatal error 190: too many error messages on one line 

Last edited by mightydifferent; 04-17-2019 at 19:56.
mightydifferent is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 04-16-2019 , 21:15   Re: [TF2] Really Weird Errors
Reply With Quote #2

sizeof(attributes[])

remove the i
Mitchell is offline
mightydifferent
Junior Member
Join Date: Aug 2017
Location: mvm_rottenburg
Old 04-17-2019 , 19:49   Re: [TF2] Really Weird Errors
Reply With Quote #3

Thanks-- Now i have these errors.. I don't know where even to start.
Could you at least walk me through them?

PHP Code:
// a.sp(19) : error 008: must be a constant expression; assumed zero
// a.sp(125) : warning 213: tag mismatch
// a.sp(153) : error 035: argument type mismatch (argument 2)
// a.sp(170) : error 092: number of arguments does not match definition
// a.sp(179) : error 047: array sizes do not match, or destination array is too small
// a.sp(186) : error 092: number of arguments does not match definition
// a.sp(187) : error 028: invalid subscript (not an array or too many subscripts): "attribute"
// a.sp(187) : warning 215: expression has no effect
// a.sp(187) : error 001: expected token: ";", but found "]"
// a.sp(187) : error 029: invalid expression, assumed zero
// a.sp(187) : fatal error 190: too many error messages on one line 

Last edited by mightydifferent; 04-17-2019 at 20:53.
mightydifferent is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 04-19-2019 , 10:56   Re: [TF2] Really Weird Errors
Reply With Quote #4

That isn't how enums work, you can't give them default values like that, the enum is the array indexes, not values.

A good number of the later errors is because BuyUpgrade takes an integer as the 2nd param, but you're giving it an array.
__________________

Last edited by asherkin; 04-19-2019 at 10:58.
asherkin is offline
mightydifferent
Junior Member
Join Date: Aug 2017
Location: mvm_rottenburg
Old 04-20-2019 , 16:32   Re: [TF2] Really Weird Errors
Reply With Quote #5

Quote:
Originally Posted by asherkin View Post
That isn't how enums work, you can't give them default values like that, the enum is the array indexes, not values.

A good number of the later errors is because BuyUpgrade takes an integer as the 2nd param, but you're giving it an array.
Thank you, that explains a lot. I got rid of a major portion of the errors, but I have a question:
What type do I specify as an argument for a stock function if I have a multi type array?

If I have: (example, sorry for errors)

PHP Code:
enum itemContent 

    
StringitemName[128], 
    
StringitemDesc[255], 
    
boolusable
    
levelReq 
}; 

new 
itemInfo[2][itemContent] =  

    {
"Example Item""Example Description"false0}, 
    {
"Test Item""Test Description"true10
}; 

stock GetStartingItemName(<what do i put here>:startingItem) {
     return 
startingItem[itemName]


public 
OnPluginStart()
{
    new 
String:info[] = GetStartingItem(itemInfo[0]);


Last edited by mightydifferent; 04-20-2019 at 16:39.
mightydifferent 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 08:11.


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