PDA

View Full Version : Multple Problems


QOOOOOOOOQ
10-08-2014, 22:56
Problem Uno:
The last PrintToChatAll() is not displayed, this means SortIntegers() has to be getting stuck (and thus if I put any more code after SortIntegers(), it would not be executed).

Code:

public Action:DisplayClientsInOrder(client, args)
{
PrintToChatAll("DEBUG: Creating array of players.");

new aOrderedPlayersList[CLIENTLIMIT+1];

for(new vWho = 1; vWho <= MaxClients; vWho++)
{
if(IsClientInGame(vWho)) // Client validity verified by being within 'for' parameters
aOrderedPlayersList[vWho] = GetClientUserId(vWho); // Client userID stored under the array index of client index
}

for(new test = 0; test <= MaxClients; test++) // Array starts at 1, but we check 0 anyway to make sure it's non-occupied
{
PrintToChatAll("DEBUG: aOrderedPlayersList[%d] = %d - Name = %N", test, aOrderedPlayersList[test], test);
}

SortIntegers(aOrderedPlayersList, MaxClients, Sort_Ascending); // Ordering array as smallest index at bottom and largest atop

PrintToChatAll("DEBUG: Player array sorted.");
}

Execution (in chat): (The plan is to display these names in an ordered panel, when I get there, bots will be excluded from display, so it does not matter if they show up here.)

DEBUG: Creating array of players.
DEBUG: aOrderedPlayersList[0] = 0 - Name = Console
DEBUG: aOrderedPlayersList[1] = 299 - Name = Bill
DEBUG: aOrderedPlayersList[2] = 200 - Name = QOOOOOOOOQ
DEBUG: aOrderedPlayersList[3] = 303 - Name = Zoey
DEBUG: aOrderedPlayersList[4] = 301 - Name = Louis
Logs:

LOG: Native "VFormat" reported: Client index 1 is invalid
LOG: Displaying call stack trace for plugin "ClientOrderDisplayer.smx":
LOG: [1] Line 139, G:\SourcePawn\sources\PreReady.sp::DisplayCli entsInOrder()
--------------------
Problem Dos:

Code:

public Action:Event_PlayerLeftStartArea(Handle:event , const String:name[], bool:broadcast)
{
new Float:fVel[3];

GetEntPropVector(client, Prop_Send, "m_vecVelocity", fVel); // Gather the client's vectors to accelerate them in reverse
NegateVector(fVel); // Reverses value of velocity
SetEntPropVector(client, Prop_Send, "m_vecVelocity", fVel);
}
Execution: (when a player triggers event)

The velocity switch is supposed to happen every time it is triggered, it is only triggered once, errors I assume, I simply want a player's velocity to be reversed on all 3 planes (so that he can never really leave start area).
Logs:

LOG: Native "GetEntPropVector" reported: Property "m_vecVelocity" not found (entity 2/player)
-
-
-
FYI: Yes, those are the complete error logs, the top combined with the bottom is all it displays in the file.

xf117
10-09-2014, 03:29
In the first one, you are calling GetClientName (by "%N") in your iteration, but you don't check if client is in game before that. You probably want to store the number of clients that are in your list, so higher numbers will not even get called.
If that's confusing, you can't just add additional IsClientInGame check in the second iteration.

public Action:DisplayClientsInOrder(client, args)
{
PrintToChatAll("DEBUG: Creating array of players.");

new aOrderedPlayersList[CLIENTLIMIT+1];
new count;

for(new vWho = 1; vWho <= MaxClients; vWho++)
{
if(IsClientInGame(vWho)) {// Client validity verified by being within 'for' parameters
aOrderedPlayersList[count] = GetClientUserId(vWho); // Client userID stored under the array index of client index
count++;
}
}

for(new test = 0; test < count; test++) // Array starts at 1, but we check 0 anyway to make sure it's non-occupied
{
PrintToChatAll("DEBUG: aOrderedPlayersList[%d] = %d - Name = %N", test, aOrderedPlayersList[test], GetClientOfUserId(aOrderedPlayersList[test]));
}

SortIntegers(aOrderedPlayersList, count, Sort_Ascending); // Ordering array as smallest index at bottom and largest atop

PrintToChatAll("DEBUG: Player array sorted.");
}

Dr. Greg House
10-09-2014, 04:47
Second:
It's a dataprop. Also you shouldn't play around with the velocity-props directly and rather use TeleportEntity for that.

QOOOOOOOOQ
10-10-2014, 04:36
Thanks, to you both, didn't realize what the second param even did for GetEntPropVector() anyways, why is changing velocity props directly bad?

Dr. Greg House
10-10-2014, 07:42
Because there are quite a few of them which will all be added up to a global velocity which will then be applied.