Menu

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.

Show posts Menu

Messages - Xmair

#16
You generally don't want to query 3 times if you are querying from the same table. What could you do instead is select multiple columns in a single query. It is also good practice to escape any input you take from the user to prevent SQL injection.

The main problem you are facing right now is that you are not retrieving the column data for the query. QuerySQL doesn't return just the result but an object which contains information about the query. Ideally, something like this would be a half-decent approach:

local accDetails = QuerySQL(db, format("SELECT IP, UID, UID2 FROM Accounts WHERE Name = '%s', escapeSQLString(plr)));
if (accDetails == null) // handle invalid nickname
else {
    QuerySQL(db, format("INSERT INTO TempBans (Name, UID, UID2, IP, Time, ExpireTime, TimeExpireRatio, Admin, Reason) VALUES ('%s', '%s', '%s', '%s', %i, %i, %s, %s, %s)", escapeSQLString(plr), GetSQLColumnData(accDetails, 1), GetSQLColumnData(accDetails, 2), GetSQLColumnData(accDetails, 0), time(), calc, expire, player.Name, escapeSQLString(reason)));
}
#17
Quote from: habi on May 19, 2023, 04:47 PMi disagree

If you use function FindPlayer in console, each time it appears you are getting a new instance. So the property will be false.

This is the same problem why 'false' is printed on console after spawning:
QuoteCPlayer.rawnewmember("SpawnProtection", false);

function onPlayerSpawn(player) {
    player.SpawnProtection = true;
    player.Immunity = 31;
    MessagePlayer("You have spawn protection for five seconds", player);
    NewTimer("TurnOffSpawnProtection", 5000, 1, player.ID);
}
 
function TurnOffSpawnProtection(player) {
    if ((player = FindPlayer(player)) != null) {
        print(player.SpawnProtection);
      player.SpawnProtection = false;
        player.Immunity = 0;
    }
}


I did not know of the official plugin's behavior in this regard. In SqMod we have a much better and decent approach to this whole idea, we are provided with a "Data" member of every instance (which is basically a table). One more reason to just shift :-X
#18
There's another way to do this:

CPlayer.rawnewmember("<member name>", <default val>);

Quote from: http://squirrel-lang.org/doc/squirrel3.htmlrawnewmember(key,val,[attrs],[bstatic])

sets/adds the slot 'key' with the value 'val' and attributes 'attrs'.If bstatic is true the slot will be added as static. If the slot does not exists , it will be created. It doesn't invoke any metamethod.

Ultimately, all of the code written above could be changed to a simple:

CPlayer.rawnewmember("SpawnProtection", false);

function onPlayerSpawn(player) {
    player.SpawnProtection = true;
    player.Immunity = 31;
    MessagePlayer("You have spawn protection for five seconds", player);
    NewTimer("TurnOffSpawnProtection", 5000, 1, player.ID);
}
   
function TurnOffSpawnProtection(player) {
    if ((player = FindPlayer(player)) != null) {
        player.SpawnProtection = false;
        player.Immunity = 0;
    }
}
#19
I will fix it in a few days and reupload it.
#20
Quote from: M4Goku on Jul 14, 2022, 02:44 PMits crashing help me and plz verify me on discord.
skill issue
#21
Yes. There is a limit on both, the XML objects and custom objects. Although none of the limits are documented anywhere.
#22
Quote from: UncleRus on Apr 01, 2022, 11:20 AM
Quote from: habi on Apr 01, 2022, 10:37 AMThey are sqmod plugins, which may be downloaded at
https://discord.gg/JMcXBa3
Quote from: . on Aug 23, 2016, 11:12 PMBinaries can be found here: https://discord.gg/JMcXBa3
Habi in this channel i find 64 bits but i need 32 bits
I don't think SqMod officially supports 32 bit anymore.
#23
Off-Topic General / Re: Need a plugin
Mar 06, 2022, 03:16 PM
Quote from: MRSK143 on Mar 06, 2022, 06:26 AMBruh... then can you make it again or provide its source code plz?
I lost the source code and I don't have any interest or time to spare for VCMP. Sorry.
#24
Off-Topic General / Re: Need a plugin
Mar 06, 2022, 05:52 AM
Don't have it anymore
#25
Community Plugins / Re: Whitelist plugin
Feb 26, 2022, 11:17 AM
Quote from: habi on Feb 26, 2022, 10:56 AMInclude every .h file inside main.h and at last including main.h in every .cpp.
.. what
#26
Quote from: Chicken on Feb 21, 2022, 12:17 PMI probably understand, is it possible to get the server name by sending a data packet whose protocol is UDP and whose format is byte set 32+strlen to the server IP and port?
Yes it is possible to get the server name by sending a UDP dgram packet. However I don't think you understand how to parse the result properly so I would suggest you to just use premade code. Fleka did something a few years ago: https://forum.vc-mp.org/?topic=5530.msg39171#msg39171

One small thing to note is you should try changing the magic to 'VCMP' instead of 'MP04' since back when I was coding a browser, some servers wouldn't work if you used 'MP04' as magic.
#27
I don't really understand what you really mean but if you want to make something such as a server browser, here's what you need to do:

Firstly, you make a GET request to a master list URL (I usually use https://master.thijn.ovh/). This returns a JSON array of servers. You are provided with each announced server's IP, port and official status.

Afterwards, you loop through the server list received from the master list and you send a UDP packet to each of them. There's more information about this in the following wiki page:
http://wiki.thijn.ovh/index.php?title=Query_Mechanism

The page is pretty self explanatory but if you still face issues, you can always use a reference such as:
https://github.com/BigETI/SAMPLauncherNET/blob/master/SAMPLauncherNET/Source/SAMPLauncherNET/Core/Server.cs
#28
Change the file ending to LF (\n)
#29
Script Showroom / Re: Set Grapics Command!
Oct 05, 2021, 06:26 PM
Quote from: Jutt on Oct 05, 2021, 05:33 PMkhud banai hai -- translated: made it myself
No offense but it clearly shows lmao
#30
Script Showroom / Re: Set Grapics Command!
Oct 02, 2021, 09:35 AM
big brain code