Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - S.L.C

Pages: [1] 2 3
1
Script Discussion / Re: onPlayerCrouchChange is bugged ?!
« on: October 10, 2014, 01:22:30 pm »
By the looks of it the callback function is implemented in C++ but wasn't attached to the event. Therefore the function is never called to forward the event to the script. The following code is never executed:
Code: [Select]
function onPlayerCrouchChange( i_player, state )
{
print( "Player " + i_player.Name + " is " + (state ? "crouched" : "standing") );
}

2
Script Discussion / Re: What does ".Immunity" do?
« on: October 08, 2014, 01:04:49 pm »
Apparently it's using Bit Fields to enable certain immunity flags/options for those entities. But nobody posted any information on what those bit fields actually turn off or turn on. You might have to ask someone with access to the actual source code or has some knowledge about them.

3
Script Releases / Re: Changeskin, paint - commands
« on: October 07, 2014, 11:53:53 pm »
You could take advantage of the GetSkinID() function from the latest plug-in update:
Code: [Select]
if ( cmd == "skin" )
{
if ( !player.IsSpawned ) MessagePlayer( "You have to be spawned to use this command.", player );
else if ( !text ) MessagePlayer( "Syntax, /" + cmd + " <TAG>", player );
else {
local skin_id = GetSkinID(text);
if (skin_id < 0) MessagePlayer( "Could not identify the specified skin tag.", player );
else {
player.Skin = skin_id;
MessagePlayer( "Skin changed to: " + GetSkinName( player.Skin ), player );
}
}
}

By short-tag I mean you don't have to use the full skin name. All you need is a few key letters to help identify the skin. Like "tv" for [To]mmy [V]ercetti. For example you could do: /skin ha3 ([Ha]tian 3/C). You can also use the full name if you want to. Even other symbols or different case. The search strips symbols and is case insensitive.

Quote from: Bitbucket
It's a small function to retrieve the skin id from the name. The function should (theoretically) work for both full names or simple short tags.
Example of short tags where every item in the list point to the same id:
  • Candy Suxx
  • Cas
  • Cax
They all point to Candy Suxx

  • Garbage man 1
  • Garbage man a
  • Gm1
  • Gma
  • Ga1
  • Gaa
They all point to Garbage man 1

As long as the short tag doesn't interfere with another name then it tries to be as simple as possible.

The search doesn't care about trailing spaces, case sensitivity or non-alphanumeric symbols:
  • ------Lo*%ve F&ist^374
  • l--------Fd
  • LoD
  • Love 4
They all point to Love Fist 4/D

You can also use a, b, c, d ... instead of 1, 2, 3, 4 because some IDs share the same skin name and precise numeric identification wouldn't be accurate.

4
General Discussion / Re: VC:MP Is Stale
« on: October 03, 2014, 09:18:23 am »
Well there has been enough "work and time" to make a VCMP RP Server possible due to the amount of time the MP mod has been around. DMing is the most boring mode in any game.

Well... If you're familiar with the the saying:


Then I challenge you to script a game mode that will entertain you and it's better then what everyone else created. Maybe then you'll see why there's only DM :D

5
Script Discussion / Re: How to use transactions with the SQLite module?
« on: September 21, 2014, 09:29:00 pm »
I can't reproduce the issue.

http://i.imgur.com/V8tVK0a.png

Weird thing is that it started to work for me too after rebooting my computer. I'm curious what caused this earlier :-\ I might look deeper into it tomorrow and maybe see why this was happening. The database wasn't opened by other software for me to think that the file was locked. So there must be some other reason.

6
Script Discussion / Re: How to use transactions with the SQLite module?
« on: September 21, 2014, 04:38:47 pm »
No. Just hangs at the query function which includes the COMMIT command. Which results in the database being unaffected by the query and the script execution simply dies/hangs at that function with no other output whatsoever. The server doesn't crash or anything else but simply stops executing Squirrel code.

7
It's understandable for the physics engine to do these kind of glitches. Especially if the speed non-standard and somewhat exaggerated. Simply put: Due to the excessive speed that wasn't expected by the game engine, the physics component of the game failed to calculate the collision in time, which is why the vehicle got through the building as if there was no collision at all.

EDIT:
The physics engine doesn't implement CCD (Continuous Collision Detection)

8
Script Discussion / How to use transactions with the SQLite module?
« on: September 21, 2014, 04:50:16 am »
I need to be able to use transactions in my scripts however the server hangs when I commit. Extending the code on my previous thread here I have the following.

Creating the database structure:
Code: [Select]
// Make sure that the database has the Streaks table
Exec(@"CREATE TABLE IF NOT EXISTS [Streaks] (
[Message] VARCHAR(128)  NOT NULL
)");

All queries in one string:
Code: [Select]
// Insert the default values into the Streaks table
Exec(@"BEGIN;
INSERT INTO [Streaks] ([Message]) VALUES ('%s');
INSERT INTO [Streaks] ([Message]) VALUES ('%s');
INSERT INTO [Streaks] ([Message]) VALUES ('%s');
INSERT INTO [Streaks] ([Message]) VALUES ('%s');
INSERT INTO [Streaks] ([Message]) VALUES ('%s');
INSERT INTO [Streaks] ([Message]) VALUES ('%s');
INSERT INTO [Streaks] ([Message]) VALUES ('%s');
INSERT INTO [Streaks] ([Message]) VALUES ('%s');
INSERT INTO [Streaks] ([Message]) VALUES ('%s');
INSERT INTO [Streaks] ([Message]) VALUES ('%s');
INSERT INTO [Streaks] ([Message]) VALUES ('%s');
INSERT INTO [Streaks] ([Message]) VALUES ('%s');
INSERT INTO [Streaks] ([Message]) VALUES ('%s');
INSERT INTO [Streaks] ([Message]) VALUES ('%s');
INSERT INTO [Streaks] ([Message]) VALUES ('%s');
INSERT INTO [Streaks] ([Message]) VALUES ('%s');
INSERT INTO [Streaks] ([Message]) VALUES ('%s');
INSERT INTO [Streaks] ([Message]) VALUES ('%s');
INSERT INTO [Streaks] ([Message]) VALUES ('%s');
INSERT INTO [Streaks] ([Message]) VALUES ('%s');
INSERT INTO [Streaks] ([Message]) VALUES ('%s');
INSERT INTO [Streaks] ([Message]) VALUES ('%s');
INSERT INTO [Streaks] ([Message]) VALUES ('%s');
INSERT INTO [Streaks] ([Message]) VALUES ('%s');
INSERT INTO [Streaks] ([Message]) VALUES ('%s');
INSERT INTO [Streaks] ([Message]) VALUES ('%s');
COMMIT;",
@"%s got the taste of blood. Victim: %s Killstreak: %d",
@"%s starts to enjoy it. Victim: %s Killstreak: %d",
@"%s is feeling bold. Victim: %s Killstreak: %d",
@"%s wants to be heroic. Victim: %s Killstreak: %d",
@"%s just became fearless. Victim: %s Killstreak: %d",
@"%s feels the excitement. Victim: %s Killstreak: %d",
@"%s is a freak. Victim: %s Killstreak: %d",
@"%s went on a killing spree. Victim: %s Killstreak: %d",
@"%s is unstoppable. Victim: %s Killstreak: %d",
@"%s starts to dominate. Victim: %s Killstreak: %d",
@"%s is relentless. Victim: %s Killstreak: %d",
@"%s went on a rampage. Victim: %s Killstreak: %d",
@"%s is delusional. Victim: %s Killstreak: %d",
@"%s became a nemesis. Victim: %s Killstreak: %d",
@"%s is a monster. Victim: %s Killstreak: %d",
@"%s annihilates everything. Victim: %s Killstreak: %d",
@"%s is out of this world. Victim: %s Killstreak: %d",
@"%s massacred his opponents. Victim: %s Killstreak: %d",
@"%s became a savage. Victim: %s Killstreak: %d",
@"%s is a deamon. Victim: %s Killstreak: %d",
@"%s made a genocide. Victim: %s Killstreak: %d",
@"%s is a mass murderer. Victim: %s Killstreak: %d",
@"%s slaughtered all hopes. Victim: %s Killstreak: %d",
@"%s is immortal. Victim: %s Killstreak: %d",
@"%s reached divinity. Victim: %s Killstreak: %d",
@"%s is god-like. Victim: %s Killstreak: %d"
);

Queries executed individually:
Code: [Select]
// Insert the default values into the Streaks table
Exec(@"BEGIN;");
Exec(@"INSERT INTO [Streaks] ([Message]) VALUES ('%s');", @"%s got the taste of blood. Victim: %s Killstreak: %d");
Exec(@"INSERT INTO [Streaks] ([Message]) VALUES ('%s');", @"%s starts to enjoy it. Victim: %s Killstreak: %d");
Exec(@"INSERT INTO [Streaks] ([Message]) VALUES ('%s');", @"%s is feeling bold. Victim: %s Killstreak: %d");
Exec(@"INSERT INTO [Streaks] ([Message]) VALUES ('%s');", @"%s wants to be heroic. Victim: %s Killstreak: %d");
Exec(@"INSERT INTO [Streaks] ([Message]) VALUES ('%s');", @"%s just became fearless. Victim: %s Killstreak: %d");
Exec(@"INSERT INTO [Streaks] ([Message]) VALUES ('%s');", @"%s feels the excitement. Victim: %s Killstreak: %d");
Exec(@"INSERT INTO [Streaks] ([Message]) VALUES ('%s');", @"%s is a freak. Victim: %s Killstreak: %d");
Exec(@"INSERT INTO [Streaks] ([Message]) VALUES ('%s');", @"%s went on a killing spree. Victim: %s Killstreak: %d");
Exec(@"INSERT INTO [Streaks] ([Message]) VALUES ('%s');", @"%s is unstoppable. Victim: %s Killstreak: %d");
Exec(@"INSERT INTO [Streaks] ([Message]) VALUES ('%s');", @"%s starts to dominate. Victim: %s Killstreak: %d");
Exec(@"INSERT INTO [Streaks] ([Message]) VALUES ('%s');", @"%s is relentless. Victim: %s Killstreak: %d");
Exec(@"INSERT INTO [Streaks] ([Message]) VALUES ('%s');", @"%s went on a rampage. Victim: %s Killstreak: %d");
Exec(@"INSERT INTO [Streaks] ([Message]) VALUES ('%s');", @"%s is delusional. Victim: %s Killstreak: %d");
Exec(@"INSERT INTO [Streaks] ([Message]) VALUES ('%s');", @"%s became a nemesis. Victim: %s Killstreak: %d");
Exec(@"INSERT INTO [Streaks] ([Message]) VALUES ('%s');", @"%s is a monster. Victim: %s Killstreak: %d");
Exec(@"INSERT INTO [Streaks] ([Message]) VALUES ('%s');", @"%s annihilates everything. Victim: %s Killstreak: %d");
Exec(@"INSERT INTO [Streaks] ([Message]) VALUES ('%s');", @"%s is out of this world. Victim: %s Killstreak: %d");
Exec(@"INSERT INTO [Streaks] ([Message]) VALUES ('%s');", @"%s massacred his opponents. Victim: %s Killstreak: %d");
Exec(@"INSERT INTO [Streaks] ([Message]) VALUES ('%s');", @"%s became a savage. Victim: %s Killstreak: %d");
Exec(@"INSERT INTO [Streaks] ([Message]) VALUES ('%s');", @"%s is a deamon. Victim: %s Killstreak: %d");
Exec(@"INSERT INTO [Streaks] ([Message]) VALUES ('%s');", @"%s made a genocide. Victim: %s Killstreak: %d");
Exec(@"INSERT INTO [Streaks] ([Message]) VALUES ('%s');", @"%s is a mass murderer. Victim: %s Killstreak: %d");
Exec(@"INSERT INTO [Streaks] ([Message]) VALUES ('%s');", @"%s slaughtered all hopes. Victim: %s Killstreak: %d");
Exec(@"INSERT INTO [Streaks] ([Message]) VALUES ('%s');", @"%s is immortal. Victim: %s Killstreak: %d");
Exec(@"INSERT INTO [Streaks] ([Message]) VALUES ('%s');", @"%s reached divinity. Victim: %s Killstreak: %d");
Exec(@"INSERT INTO [Streaks] ([Message]) VALUES ('%s');", @"%s is god-like. Victim: %s Killstreak: %d");
Exec(@"COMMIT;");

Both methods hang when I commit. I've tested the generated query string in other software and it works perfectly.

9
I know that it's supposed to be used on individual arguments instead of the entire query and I remember this from doing a wrapper in PHP based on MeekroDB  except for SQLite3 (now lost due to some hardware failure). But I've seen it used like that in some Squirrel code created by other members of this and the unofficial forum which made me believe this is how it's supposed to be used in Squirrel. Anyway, thanks for letting me know of the proper usage. I've learned my lesson. I shall never again let my self be miss leaded by incorrect code posted online :D

10
This is a partial implementation but you will find test cases for both ways (escaped and original) in the DB.Exec() function: Squirrel Code

This is the generated query without escaping: Unescaped SQLite query

And this is the generated query with escaping: Escaped SQLite query

I've posted the queries on Pastebin because of the limitation in the amount of characters a post can have. There's also a commented out implementation to save both queries in the DB.Exec() function.

EDIT:

There are a few bugs as a result of copy -> paste but you should ignore them.
Code: [Select]
// Line 104
else _Queue[level].pushback(query);
// Becomes
else _Queue[level].push(query);

// Line 164
else if (!::DisconnectSQL(_File)) return print("Unable to close handle for database: " + _File);
// Becomes:
else if (!::DisconnectSQL(_Handle)) return print("Unable to close handle for database: " + _File);

// etc.

11
Oh well, it seems that the problem wasn't how the database was created. I've went with a weird way of making sure that the database is actually an SQLite3 database using:
Code: [Select]
// ------------------------------------------------------------------------------------------------
local g_Empty_DB = [83, 81, 76, 105, 116, 101, 32, 102, 111, 114, 109, 97, 116, 32, 51, 0, 4, 0, 1, 1, 0, 64, 32, 32, 0, 0, 0, 2, 0, 0, 0, 2,
0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,
0, 45, 226, 40, 13, 0, 0, 0, 0, 4, 0, 0, 3, 173, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 83, 41, 41, 1, 95, 116, 97, 98, 108, 101, 99, 114, 101, 97, 116, 105,
111, 110, 95, 116, 97, 98, 108, 101, 99, 114, 101, 97, 116, 105, 111, 110, 95, 116, 97, 98, 108, 101, 2, 67, 82, 69, 65, 84, 69, 32, 84, 65,
66, 76, 69, 32, 99, 114, 101, 97, 116, 105, 111, 110, 95, 116, 97, 98, 108, 101, 32, 40, 116, 109, 112, 32, 73, 78, 84, 69, 71, 69, 82, 41,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];

function OpenDatabase(path)
{
// Make sure that a database file was specified and that it's a valid path
if (typeof path != "string") return print("Unknown or missing database location. Operation will be aborted.");
// Create a simple variable to hold our file handle
local f = null;
// Try to open the database as a simple file to see if it exists
try
{
// Trying to open the file for read opperations throws an error if it doesn't exist
f = file(path, "r");
} catch (e) {
// Now try to open the file for write operations and create one since we failed above
f = file(path, "w");
// Make sure that the file could be opened in the previous operation
if (f == null) return print("Could not load or create the database file: " + path);
// Initialize and empty SQLite3 database
foreach (b in g_Empty_DB) f.writen(b, 'b');
// Save and close the newlly create file
f.flush();
f.close();
}
// Now we know that the file exists and can be loaded so let's close it
if (f != null) f.close();
// Try to open the file as an SQLite3 database now
local handle = ConnectSQL(path);
// Check if the previous operation succeeded and notify someone in case of failure
if (handle == null) return print("Unable to open the SQLite database from: " + path);
// The database was opened successfully and the operation is complete
else return handle;
}

OpenDatabase("test.db");

But the whole problem started with escapeSQLString() which added some extra symbols in my query resulting in an invalid query. Wasn't until I made sure that the database is actually an SQLite3 one that I actually took a closer look at my escaped query.

The IDE/Studio/Editor that I was using would load the database as an SQLite2 database and would fail at the "IF NOT EXISTS" part of the query. Which is why it couldn't warn me about those extra symbols in rest of the query. This thread can now be closed. Sorry for bothering anyone  :)

12
Description
When the ConnectSQL function is called on a database that doesn't exists then it tries to create one. The thing is that it's creating an SQLite2 database instead of an SQLite3 one.

Reproducible
Always

What you were doing when the bug happened
I was trying to create a table using "CREATE TABLE IF NOT EXISTS" and I noticed it doesn't work. Always fails with the message "Error while executing query: near "NOT": syntax error". Mainly because SQLite2 doesn't support "IF NOT EXISTS".

What you think caused the bug
I'm not sure at the moment because the module code seems to be correct. Probably an SQLite issue but just to be sure.

In whatever IDE/Studio/Editor I load the database it shows as an SQLite2 database. And if I create the database manually as an SQLite3 database then my queries work.

13
Script Releases / Re: [Snippet]Player Fps
« on: September 20, 2014, 04:55:31 am »
foreach

Code: [Select]
'foreach' '(' [index_id','] value_id 'in' exp ')' stat
Executes a statement for every element contained in an array, table, class, string or generator. If exp is a generator it will be resumed every iteration as long as it is alive; the value will be the result of 'resume' and the index the sequence number of the iteration starting from 0.
   
Code: [Select]
local a=[10,23,33,41,589,56]
foreach(idx,val in a)
    print("index="+idx+" value="+val+"\n");
//or
foreach(val in a)
    print("value="+val+"\n");

Similar to iterators in standard C++ or the new range based for loop in C++11.


Array

push(val)

appends the value ‘val’ at the end of the array

Similar to push_back() in std::vector or related containers in C++.


References taken from Squirrel 3.0 Reference Manual

14
Ok. Thanks for the confirmation. I will review my code to comply with this limitation.

15
Description
I'm trying to use the player instance as the key inside a table, but when the player leaves the server the player instance isn't pointing to the same thing it was previously pointing in the table.

Reproducible
Always

What you were doing when the bug happened
N/A

What you think caused the bug
I'm not sure if this is a feature of the module and not a bug. If this is not expected behavior then I'll look for a bug.

Code that can reproduce the issue that I'm having:
Code: [Select]
local t_Players = {}

function onPlayerJoin(i_player)
{     
t_Players[i_player] <- null;

print("OnJoin slot search result: " + t_Players.rawin(i_player).tostring());
}

function onPlayerPart(i_player, reason)
{
print("OnPart slot search result: " + t_Players.rawin(i_player).tostring());
}

Screenshot of the console output:

Pages: [1] 2 3