SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 23/04/2020, 01:59 AM   #4141
Nero_3D
High-roller
 
Nero_3D's Avatar
 
Join Date: Jun 2007
Location: Germany
Posts: 2,856
Reputation: 692
Default Re: Little coding questions - For general minor queries 5

Quote:
Originally Posted by Electrifying View Post
What _: Means? Why and when should I use it?
It is somewhat explained here -> https://wiki.sa-mp.com/wiki/Scripting:tags
But to make it short it is usually used to overwrite tags
pawn Code:
new MyTag: myvar;

if(_: myvar == 0) {
    print("yay");
}
Nero_3D is offline   Reply With Quote
Old 27/04/2020, 11:28 PM   #4142
Electrifying
Big Clucker
 
Join Date: Sep 2018
Location: Pernambuco
Posts: 172
Reputation: 2
Default Re: Little coding questions - For general minor queries 5

Does anyone here can send me the link of ps-format?
Is it still useful to this day?
Electrifying is offline   Reply With Quote
Old 27/04/2020, 11:53 PM   #4143
Nero_3D
High-roller
 
Nero_3D's Avatar
 
Join Date: Jun 2007
Location: Germany
Posts: 2,856
Reputation: 692
Default Re: Little coding questions - For general minor queries 5

Quote:
Originally Posted by Electrifying View Post
Does anyone here can send me the link of ps-format?
Is it still useful to this day?
Took me literally one search to find it, on the second last page of the main thread attached to this reply
Quote:
Originally Posted by RogueDrifter View Post
There you go guys enjoy it ^^
If it is useful, depends, packed strings are only useful if you plan to save a lot of long string globally and you want to save a bit of memory otherwise not
Nero_3D is offline   Reply With Quote
Old 23/05/2020, 04:22 PM   #4144
Calinut200
Big Clucker
 
Join Date: Jun 2016
Posts: 74
Reputation: 0
Default Re: Little coding questions - For general minor queries 5

how to rezolve?
PHP Code:
if(PlayerText:linia11 == strcmp("PLD_SLOT:r_69","LD_SLOT:r_69"))
 
warning 213tag mismatchexpected tag "PlayerText"but found none ("_"
Calinut200 is offline   Reply With Quote
Old 24/06/2020, 04:46 AM   #4145
SkyFlare
Huge Clucker
 
SkyFlare's Avatar
 
Join Date: Apr 2015
Location: NZ
Posts: 221
Reputation: 43
Default Re: Little coding questions - For general minor queries 5

How to make unbreakable atm machines/objects?, this example isnt working below
Code:
DynamicAtms[atmid][ObjectID] = CreateDynamicObject(DynamicAtms[atmid][ModelID], DynamicAtms[atmid][PosX], DynamicAtms[atmid][PosY], DynamicAtms[atmid][PosZ], 0.0, 0.0, 0.0, 0, 0, -1, 100.0);
	SetDynamicObjectMaterialText(DynamicAtms[atmid][ObjectID],0,"None",50," Arial",24,0,0,0,1);
would be nice to know how this works, thanks in advance.
__________________
Purchasable Scripting Services Available, Inbox me with your Requests.
My Project Progress Tracker
My Work
Link
Information
S-Store System V2 LinkIngame Store in Dialogs
SkyFlare is offline   Reply With Quote
Old 21/07/2020, 03:20 PM   #4146
Alpays
Little Clucker
 
Join Date: Jun 2020
Location: Turkey
Posts: 10
Reputation: 0
Default Re: Little coding questions - For general minor queries 5

what is the difference between

new Float:TDMSpawn[][] =
{
{1,1,1,1},
{1,1,1,1)
}

and

new Float:TDMSpawn[2][4] =
{
{1,1,1,1},
{1,1,1,1)
}
Alpays is offline   Reply With Quote
Old 21/07/2020, 05:45 PM   #4147
RoboN1X
Huge Clucker
 
RoboN1X's Avatar
 
Join Date: Feb 2011
Location: Indonesia
Posts: 453
Reputation: 145
Smile Re: Little coding questions - For general minor queries 5

Quote:
Originally Posted by Alpays View Post
what is the difference between

new Float:TDMSpawn[][] =
{
{1,1,1,1},
{1,1,1,1)
}

and

new Float:TDMSpawn[2][4] =
{
{1,1,1,1},
{1,1,1,1)
}
The first one will have the compiler calculate the array size based on the initializer, thus it will technically becomes [2][4]. It is only possible if the initial values are declared, so you cant just have:
Code:
new Float:TDMSpawn[][];
The second will have fixed amount array size as you specified, which is [2][4]... giving [1][3] will result error because the array size mismatch and giving more like [3][5] will result a warning because the array must be fully initialized.
Since the array size is explicit, you can declare without initial value, so you can have:
Code:
new Float:TDMSpawn[2][4];
which will have all 0 for initial values.

Note that it is possible to have
Code:
new Float:TDMSpawn[][4] =
{
{1,1,1,1},
{1,1,1,1}
}
In case you will be adding more tdm spawn rows in the initializer but dont want to accidentally change the column size
Code:
new Float:TDMSpawn[][4] =
{
{1,1,1,1},
{1,1,1,1},
{1,1,1,1} // ok
}
Code:
new Float:TDMSpawn[][4] =
{
{1,1,1,1},
{1,1,1,1},
{1,1,1} // error
}

Check out the pawn-lang.pdf documentation
__________________
Need Help? Use Search, WIKI, and FAQ
RoboN1X is offline   Reply With Quote
Old 22/07/2020, 08:44 PM   #4148
Dignity
High-roller
 
Dignity's Avatar
 
Join Date: May 2013
Location: Belgium
Posts: 1,661
Reputation: 1211
Default Re: Little coding questions - For general minor queries 5

What would be the most efficient way of removing dynamic objects attached to a vehicle, for ANY vehicle?


I've got more than 10,000 objects easily in my server, so a loop is not ideal...

The only "true" way to consider all objects is by hooking CreateObject, storing the value in a variable and then looping through it, using Streamer_GetIntData to match the vehicle ID and then remove it however considering the amount of objects I have this would end up being very laggy and bad for server performance...


Any alternatives?
Dignity is offline   Reply With Quote
Old 25/07/2020, 02:49 PM   #4149
coool
Gangsta
 
coool's Avatar
 
Join Date: Feb 2013
Location: Republic of Pakistan
Posts: 637
Reputation: 64
Default Re: Little coding questions - For general minor queries 5

Quote:
Originally Posted by Dignity View Post
What would be the most efficient way of removing dynamic objects attached to a vehicle, for ANY vehicle?


I've got more than 10,000 objects easily in my server, so a loop is not ideal...

The only "true" way to consider all objects is by hooking CreateObject, storing the value in a variable and then looping through it, using Streamer_GetIntData to match the vehicle ID and then remove it however considering the amount of objects I have this would end up being very laggy and bad for server performance...


Any alternatives?
PHP Code:
new AttachedObjects[MAX_VEHICLES][100];
hook AttachObjectToVehicle()
{
    new 
free_slot;
    for (
free_slot 0free_slot sizeof AttachedObjects[vehicled]; free_slot++)
        if (
AttachedObjects[vehicled][free_slot] == 0) break; 
    
AttachedObjects[vehicleid][free_slot] = objectid;
}

DestroyObjectsAttachedToVehicle(vehicleid)
{
    for (new 
isizeof AttachedObjects[vehicleid]; i++)
        
DestroyObject(AttachedObjects[vehicleid][i])

What do you think about this alternative? This loops over only the objects attached to a vehicle.
__________________
coool is offline   Reply With Quote
Old 02/08/2020, 01:49 PM   #4150
Dignity
High-roller
 
Dignity's Avatar
 
Join Date: May 2013
Location: Belgium
Posts: 1,661
Reputation: 1211
Default Re: Little coding questions - For general minor queries 5

Quote:
Originally Posted by coool View Post
PHP Code:
new AttachedObjects[MAX_VEHICLES][100];
hook AttachObjectToVehicle()
{
    new 
free_slot;
    for (
free_slot 0free_slot sizeof AttachedObjects[vehicled]; free_slot++)
        if (
AttachedObjects[vehicled][free_slot] == 0) break; 
    
AttachedObjects[vehicleid][free_slot] = objectid;
}

DestroyObjectsAttachedToVehicle(vehicleid)
{
    for (new 
isizeof AttachedObjects[vehicleid]; i++)
        
DestroyObject(AttachedObjects[vehicleid][i])

What do you think about this alternative? This loops over only the objects attached to a vehicle.
Looks good. I thought of doing it in a similar fashion but not using the same loop... this saved me some headache thanks a lot.
Dignity is offline   Reply With Quote
Reply

Thread Tools
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to make a soldier aotumaticly be general when the general dies ? AlbanianGuy Scripting Help 35 13/05/2012 03:35 PM
Minor problem Desert Help Archive 4 17/03/2010 06:24 PM
Counting with mysql queries actiwe Help Archive 2 26/02/2010 02:36 PM
SQL queries using GROUP BY Dabombber Help Archive 1 05/10/2009 07:47 PM


All times are GMT. The time now is 12:00 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.