Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums



(Advanced Search)

Forum Statistics
» Members: 6,513
» Latest member: Young Harmoni
» Forum threads: 2,235
» Forum posts: 12,037

Full Statistics

Online Users
There are currently 527 online users.
» 1 Member(s) | 523 Guest(s)
Bing, Yandex, Google, noise

Latest Threads
High-Precision Laser Weld...
Forum: General Discussions
Last Post: Young Harmoni
3 hours ago
» Replies: 0
» Views: 8
Interesting
Forum: Chat
Last Post: Gerty23461
6 hours ago
» Replies: 1
» Views: 21
I humor myself
Forum: Programming
Last Post: nami16504
Yesterday, 04:28 PM
» Replies: 5
» Views: 8,056
Command does not work in-...
Forum: Pawn Scripting
Last Post: PANZEHIR_
2024-11-23, 06:36 PM
» Replies: 0
» Views: 44
White Screen
Forum: Support
Last Post: Phat202146_real
2024-11-21, 02:50 PM
» Replies: 0
» Views: 44
I get error 021 using y_h...
Forum: Pawn Scripting
Last Post: daniscript18
2024-11-18, 11:34 PM
» Replies: 0
» Views: 61
Il reste des français sur...
Forum: French/Fran?ais
Last Post: tysanio
2024-11-18, 05:39 AM
» Replies: 2
» Views: 474
Object creation issues
Forum: Programming
Last Post: K1271
2024-11-15, 11:51 PM
» Replies: 0
» Views: 56
Is the SAMP Hosting the s...
Forum: General Discussions
Last Post: OperaGX
2024-11-14, 09:33 PM
» Replies: 0
» Views: 77
Run time error 19: "File ...
Forum: Pawn Scripting
Last Post: Rexey
2024-11-14, 03:50 AM
» Replies: 0
» Views: 65

 
  streamer object appear after using cmd gotoxyz
Posted by: Flint - 2020-10-03, 10:17 PM - Forum: Pawn Scripting - Replies (2)

Recently I started?gamemode from 0, I loaded the streamer plugin, I loaded the jobs section from DB, I did everything possible but I get Dynamic3dTextLabel and the pickup only if I use the / gotoxyz command to that job, I get spawn and not- it still appears to me even if my virtual world is still 0. I tried to change the streamer version but in vain, does anyone have the slightest idea what it can be?

sry for bad eng.



bug video:?https://youtu.be/Nko7SoXrH1o


  Sound in 0.3DL / Sonido en 0.3DL
Posted by: Daniel_Vilchez - 2020-10-03, 08:51 PM - Forum: Pawn Scripting - Replies (1)

[En espa?ol]

?Alguien sabe si es posible agregar sonidos personalizados para el SAMP 0.3DL?
O hacer que el usuario lo descargue los sonidos?al empezar y haya alguna funci?n para llamar al sonido

Cualquier respuesta relacionada con los sonidos en la versi?n 0.3DL me ser? ?til, gracias por leer


[En ingl?s]

Does anyone know if it is possible to add custom sounds for the SAMP 0.3DL?
Or have the user download the sounds at startup and there is some function to call the sound


Any answers related to sounds in version 0.3DL will be helpful to me, thanks for reading


Video Resident Evil Roleplay in the making
Posted by: Awide - 2020-10-03, 02:53 PM - Forum: Videos and Screenshots - Replies (6)

I like what I could make with FCNPC!



[Video: https://www.youtube.com/watch?v=atjm8gIdu0I]


Question Vehicle Roleplay
Posted by: GeorgeXCarl - 2020-10-03, 05:16 AM - Forum: Pawn Scripting - Replies (1)

hello, i wanna ask if there's a script that when a player bump or crash?to wall they will automatically they eject to the vehicle if they vehicle has crashes to the wall with high speed


  Car Hacking
Posted by: yukie - 2020-10-02, 02:14 PM - Forum: Pawn Scripting - Replies (13)

Does anyone how to detect this kind of hack??



https://youtu.be/zbYB6rD-A0s


  Weapon Saving MySQL
Posted by: XoMoX - 2020-10-02, 10:44 AM - Forum: Tutorials - Replies (2)

Originated From Vince

Weapon Information



There are 13 different weapon slots and thus a player can theoretically hold up to 13 different weapons. In practice, though, this is usually more like 4 or 5.



[Image: 7Y1My.png]



This structure allows for a more compact view and allows for the use of aggregate functions such as COUNT(). This allows me to find out how many weapons each player has, how many players have an M4 or even the total amount of ammo currently circulating (for a specific weapon). This may all seem trivial but it is difficult, if not impossible, to achieve with your average non-normalized "weapon1, ammo1 ... weapon13, ammo13" approach.




From the above screenshot we can deduct that the player 1 has 3 weapons: a nite stick (id 3) with 1 ammo, a desert eagle (id 24) with 21 ammo and an M4 (id 31) with 266 ammo.



Creating The Table

userid is a reference to the player's unique ID which is stored in another table, along with their name, password, etc. Notice that phpMyAdmin conveniently makes the userid clickable if a foreign key exists. weaponid is simply the weaponid as is returned from functions like GetPlayerWeapon and GetPlayerWeaponData. ammo holds the ammunition associated with aforementioned weaponid.



[Image: 4m11mSS.png]



The options you need to edit are marked in yellow. Note that the type and attributes of the userid may differ in your case: this field needs to be declared with the exact same definition as your main userid. This may mean that you do not need to set that field to unsigned. The userid does need to be declared as an index though. It is neither a primary key, nor an unique key. For the weaponid we choose an unsigned tinyint since we're only dealing with non-negative numbers up to 46. The ammo is declared unsigned as well since there's no such thing as negative ammunition. Lastly, don't forget to set the engine to InnoDB. Click Save to create the table.



Setting Limits

You should've been brought to the structures tab of the table you just created. Navigate there if this isn't the case.

Before continuing, we will first impose some extra limits to avoid cluttering the table with useless data later on. Each player (userid) can only hold exactly one specific weapon (weaponid) at once. This is a PRIMARY?property (Everytable needs to have a PRIMARY key). Therefore, tick the checkboxes in front of userid and weaponid. Then click on the UNIQUE button underneath the table.



[Image: lROnnYA.png]



Creating the foreign key



You should've been brought back to the structures tab. Navigate there if this isn't the case. Underneath the structure definition you should see a link titled Relation view. Click this to be brought to the "relation creator".



[Image: 76QZOqP.png]



I'm creating a link to the id field in the table playerinfo in the database vcnr. Your table and database will be called differently. Select the proper ID. Note that for fields to show up in this list, they need to be defined as a key! We also want any changes made in the main table to be CASCADED into this table. Click Save. This concludes the table creation part in phpMyAdmin. Now back to Pawn.



Saving



For this table, we will only use SELECT, INSERT and DELETE queries. There will be no real UPDATE queries. Instead, we will only use a special insert query:



Code:
INSERT INTO ... ON DUPLICATE KEY UPDATE ...




This query will try to insert the data as normal. If this fails because the data already exists (duplicate key) it will instead perform an update. In our context this means that we will merely update the ammo if a weaponid is already present for a specific user.



Code:
[/color]

new

? ? weaponid,

? ? ammo;

? ?

for(new i; i < 13; i) // looping through all weapon slots (0 - 12)

{

? ? GetPlayerWeaponData(playerid, i, weaponid, ammo); // get weaponid and ammo



? ? if(!weaponid) continue; // don't insert if there's no weapon in this slot

? ?

? ? mysql_format(userDB, mysqlquery, sizeof(mysqlquery), "INSERT INTO player_weapons VALUES (%d, %d, %d) ON DUPLICATE KEY UPDATE ammo = %d;", PlayerInfo[playerid][pSQLID], weaponid, ammo, ammo);

? ? mysql_pquery(userDB, mysqlquery); // parallel queries

}



[color=#000000]}




The above snippet will insert or update all the weapons the player currently has. I am using parallel queries for speed: the order in which the inserts are performed isn't at all important. You will need to substitute the userid variable with your own. The same query can also be used stand-alone in other places. You can, for example, write a hook for GivePlayerWeapon which immediately performs an insert as soon as the weapon is given.



Loading



Now to retrieve this data and give the players their weapons back. Our standard select query;



Code:
SELECT weaponid, ammo FROM player_weapons WHERE userid = %d;



Code:
public OnLoadPlayerWeapons(playerid)

{

? ?

new

? ? ? ? rows,

? ? ? ? weaponid,

? ? ? ? ammo;

? ? cache_get_row_count(rows);

? ? for(new i; i < rows; i) // loop through all the rows that were found

? ? {

? ? ? ? cache_get_value_name_int(i, "weaponid", weaponid);

? ? ? ? cache_get_value_name_int(i, "ammo", ammo;

? ? ? ? if(!(0 <= weaponid <= 46)) // check if weapon is valid (should be)

? ? ? ? {

? ? ? ? ? ? printf("[info] Warning: OnLoadPlayerWeapons - Unknown weaponid '%d'. Skipping.", weaponid);

? ? ? ? ? ? continue;

? ? ? ? }

? ? ? ?

? ? ? ? GivePlayerWeapon(playerid, weaponid, ammo);

? ? }

? ? return;



}



Purging obsolete data



Whenever a weapon is taken away, do not forget to delete it from the database otherwise it will be returned to the player when they next join. You could write a hook for ResetPlayerWeapons. It may also be possible that weapons that have no ammo are left behind in the table. This doesn't affect anything in-game and can be cleaned up with a query (delete where ammo = 0) when the server starts, or on a cron job.


  Similar hexes
Posted by: Kwarde - 2020-10-02, 09:08 AM - Forum: Libraries - No Replies

This is more of a snippet than a library. However, it holds these functions (they all depend on each other):

has_alpha(color)
Checks if HEX (read: integer) input is RRGGBBAA. Does not work properly for other formats (except RRGGBB).
For example, AARRGG would return 0/false.

PHP Code:
if (has_alpha(0xFF0990AA))
{
??? print(
"I am alpha!");
}
else
{
??? print(
"I am merely a beta");
}
//Would print: I am alpha! 

strip_alpha(color)
Strips alpha from HEX if it has any (relies on has_alpha()). Like with has_alpha, inputting AARRGGBB would output AARRGG.
PHP Code:
new const colors[] = {
    
0xAFAFAF,
    
0x124356FF,
    
0xFF0990AA,
    
0x000001
};
for (new 
isizeof(colors); i)
{
    
printf("%x"strip_alpha(colors[i]));
}
/* Would output:
AFAFAF
124356
FF0990
1 //! No bits to shift and check for R and G in 0x000001. 

similar_hexes(hex_a, hex_b, difference = 150)
This checks if two hexes are alike color-wise.
Difference parameter can be used to increase or decrease the difference check in both colors.
Some colors might return false while they are pretty similar and some might return true while they aren't quite similar. Most of the tests I did turned out pretty okay, though.

PHP Code:
#define COLOR_RED 0xFF0000FF
if (similar_hexes(GetPlayerColor(playerid), COLOR_RED))
{
    print(
"Why are you so red?"); //Note that 0x880000FF (darkred) would return false


The functions:
PHP Code:
bool:has_alpha(color)
    return (
color >> 24 0x000000FF) ? true false;

strip_alpha(color)
    return (
has_alpha(color) ? ((((color >>> 24) & 0xFF) << 16) | (((color >>> 16) & 0xFF) << 8) | (((color >>> 8) & 0xFF))) : color);
    
similar_hexes(hex_ahex_bdifference 152)
{
    
hex_a strip_alpha(hex_a);
    
hex_b strip_alpha(hex_b);
    
    new 
R[2], G[2], B[2], diff[3];
    
R[0] = (hex_a >>> 16) & 0xFF;
    
G[0] = (hex_a >>> 8) & 0xFF;
    
B[0] = (hex_a) & 0xFF;
    
R[1] = (hex_b >>> 16) & 0xFF;
    
G[1] = (hex_b >>> 8) & 0xFF;
    
B[1] = (hex_b) & 0xFF;

    
diff[0] = floatround(difference 0.14);
    
diff[1] = floatround(difference 0.2);
    
diff[2] = floatround(difference 0.48);

    return
    (
        (
R[0] - diff[0] <= R[1] && R[1] <= R[0]  diff[0]) &&
        (
G[0] - diff[1] <= G[1] && G[1] <= G[0]  diff[1]) &&
        (
B[0] - diff[2] <= B[1] && B[1] <= B[0]  diff[2])
    );


Question TXD File
Posted by: GeorgeXCarl - 2020-10-01, 02:00 AM - Forum: Pawn Scripting - Replies (4)

Please help how can you can put the txd file in your server and can you give me the script how do i write it on my gamemode ? thanks... i'll rep you if helped


  Optimizing Looping All Streamer Objects
Posted by: JaKe Elite - 2020-09-30, 10:12 PM - Forum: Pawn Scripting - Replies (3)

Hi!?

It's my first time posting here but I would like to know is there any possibilities that I can optimize this code? It causes a huge lag spike in the server when used in a live server. It occurs when this loop is called when removing a furniture/land object or removing the entire furniture/land object.?(This also happens when the script has to reload the furniture/land object)

The lag can also be noticed?when deleting a house (which removes all the furniture in the process)

Things to know; My server has 16,000 objects so it is no surprise that the loop will check each single objects in the server.

I will be showing the functions (codes) that calls the loop:

PHP Code:
RemoveFurniture(objectid)
{
? ? if(
IsValidDynamicObject(objectid) && Streamer_GetExtraInt(objectidE_OBJECT_TYPE) == E_OBJECT_FURNITURE)
{
new
? ? ? ? 
id Streamer_GetExtraInt(objectidE_OBJECT_INDEX_ID);

? ? 
DeleteFurnitureObject(objectid);

? ? 
mysql_format(mysql_connectionqueryBuffersizeof(queryBuffer), "DELETE FROM furniture WHERE id = %i"id);
? ? 
mysql_tquery(mysql_connectionqueryBuffer);
}
}

DeleteFurnitureObject(objectid)
{
if(
IsValidDynamicObject(objectid) && Streamer_GetExtraInt(objectidE_OBJECT_TYPE) == E_OBJECT_FURNITURE)
{
? ? new 
Text3D:textid Text3D:Streamer_GetExtraInt(objectidE_OBJECT_3DTEXT_ID);

? ? ? ? if(
IsValidDynamic3DTextLabel(textid))
? ? ? ? {
? ? ? ? ? ? 
DestroyDynamic3DTextLabel(textid);
? ? ? ? }

? ? ? ? 
DestroyDynamicObject(objectid);
}
}

RemoveAllFurniture(houseid)
{
? ? if(
HouseInfo[houseid][hID] > 0)
{
? ? for(new 
0<= Streamer_GetUpperBound(STREAMER_TYPE_OBJECT); )
? ? {
? ? ? ? if(
IsValidDynamicObject(i) && Streamer_GetExtraInt(iE_OBJECT_TYPE) == E_OBJECT_FURNITURE && Streamer_GetExtraInt(iE_OBJECT_EXTRA_ID) == HouseInfo[houseid][hID])
? ? ? ? {
? ? ? ? ? ? 
DeleteFurnitureObject(i);
}
}

mysql_format(mysql_connectionqueryBuffersizeof(queryBuffer), "DELETE FROM furniture WHERE houseid = %i"HouseInfo[houseid][hID]);
mysql_tquery(mysql_connectionqueryBuffer);
}
}

ReloadFurniture(objectidlabels)
{
if(
IsValidDynamicObject(objectid) && Streamer_GetExtraInt(objectidE_OBJECT_TYPE) == E_OBJECT_FURNITURE)
{
? ? new
? ? ? ? 
id Streamer_GetExtraInt(objectidE_OBJECT_INDEX_ID);

? ? 
DeleteFurnitureObject(objectid);

? ? 
mysql_format(mysql_connectionqueryBuffersizeof(queryBuffer), "SELECT * FROM furniture WHERE id = %i"id);
? ? 
mysql_tquery(mysql_connectionqueryBuffer"SQL_LoadFurnitures""i"labels);
}
}

ReloadAllFurniture(houseid)
{
? ? if(
HouseInfo[houseid][hID] > 0)
{
? ? for(new 
0<= Streamer_GetUpperBound(STREAMER_TYPE_OBJECT); )
? ? {
? ? ? ? if(
IsValidDynamicObject(i) && Streamer_GetExtraInt(iE_OBJECT_TYPE) == E_OBJECT_FURNITURE && Streamer_GetExtraInt(iE_OBJECT_EXTRA_ID) == HouseInfo[houseid][hID])
? ? ? ? {
? ? ? ? ? ? 
DeleteFurnitureObject(i);
}
}

mysql_format(mysql_connectionqueryBuffersizeof(queryBuffer), "SELECT * FROM furniture WHERE houseid = %i"HouseInfo[houseid][hID]);
mysql_tquery(mysql_connectionqueryBuffer"SQL_LoadFurnitures""i"HouseInfo[houseid][hLabels]);
}


I will be editing this thread if more codes are needed.


Photo What's IsValidObject or IsObjectValid
Posted by: GeorgeXCarl - 2020-09-30, 05:20 AM - Forum: Pawn Scripting - Replies (2)

help with my scripting i don't know how to check if the object is spawned or not because the samp wiki is shutdown so i have no idea what to do with IsValidObject or IsObjectValid or something what it calls please give me an example for this