SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 05/01/2019, 01:46 PM   #4091
Amads
Huge Clucker
 
Amads's Avatar
 
Join Date: Feb 2012
Location: Poland
Posts: 206
Reputation: 51
Default Re: Little coding questions - For general minor queries 5

PHP Code:
new Float:pos[3];
pos = {-888.6017,1515.5992,26.2831}; // like this? no
pos[3] = {-888.6017,1515.5992,26.2831}; // like this? hmm... no
pos[] = {-888.6017,1515.5992,26.2831}; // maybe this? hell no 
How in oblivion do I assign values to an array in this way?
Amads is offline   Reply With Quote
Old 05/01/2019, 09:44 PM   #4092
Nero_3D
High-roller
 
Nero_3D's Avatar
 
Join Date: Jun 2007
Location: Germany
Posts: 2,852
Reputation: 675
Default Re: Little coding questions - For general minor queries 5

Like Southclaw said but that doesn't stop you from using it
pawn Code:
new Float:pos[3];
static const Float: _pos[sizeof pos] = {-888.6017,1515.5992,26.2831}; // static is you use it locally
pos = _pos;
Nero_3D is offline   Reply With Quote
Old 06/01/2019, 08:35 PM   #4093
DomnulRafael
Little Clucker
 
Join Date: Feb 2018
Posts: 6
Reputation: 0
Default Re: Little coding questions - For general minor queries 5

how can i check the ground under me using ColAndreas? I am trying to make a horse system using setplayervelocity and i don't want the player flying around when he's on a clif and moves over it.. i'm looking in the include but i don't find a solution to it
DomnulRafael is offline   Reply With Quote
Old 21/01/2019, 12:23 PM   #4094
Nathan94
Little Clucker
 
Join Date: Mar 2015
Posts: 12
Reputation: 0
Default Re: Little coding questions - For general minor queries 5

Hello sampers, I was wondering what's the difference between "#define something 5" and "#define something (5)"?
Nathan94 is offline   Reply With Quote
Old 21/01/2019, 04:07 PM   #4095
RoboN1X
Huge Clucker
 
RoboN1X's Avatar
 
Join Date: Feb 2011
Location: Indonesia
Posts: 453
Reputation: 145
Default Re: Little coding questions - For general minor queries 5

Having the bracket makes the number definition more "strict", if i remember right if you define them without bracket, you can put it between strings as a constant, or probably also "mix" it with another numbers/defines especially in calculation, the bracket helps you give an error at compile time when you improperly uses it/accidentally mistyped it. It is just a practice...

(Sry replying from phone)
__________________
Need Help? Use Search, WIKI, and FAQ
RoboN1X is offline   Reply With Quote
Old 22/01/2019, 06:42 AM   #4096
SyS
High-roller
 
SyS's Avatar
 
Join Date: Oct 2015
Posts: 1,939
Reputation: 504
Default Re: Little coding questions - For general minor queries 5

Quote:
Originally Posted by Nathan94 View Post
Hello sampers, I was wondering what's the difference between "#define something 5" and "#define something (5)"?
If it's a single constant there is no difference.But if it was an expression for example
PHP Code:
#define EIGHT_PLUS_TWO 8+2 
and
PHP Code:
#define EIGHT_PLUS_TWO (8+2) 
are different.

lets see the first case
PHP Code:
#define EIGHT_PLUS_TWO 8+2
main(){
    new 
result EIGHT_PLUS_TWO;
    
ASSERT(20==result);//will fail as result is 18

the above one is expanded to
Code:
new result = 2 * EIGHT_PLUS_TWO = 2 * 8+2 = 16+2 = 18 as per operator precedence
But in the second case
PHP Code:
#define EIGHT_PLUS_TWO (8+2)
main(){
    new 
result EIGHT_PLUS_TWO;
    
ASSERT(20==result);//will pass as one in parentheses is evaluated first

is expanded to
Code:
result = 2 * EIGHT_PLUS_TWO = 2 * (8+2) = 2*(10) = 20 as per operator precedence
SyS is offline   Reply With Quote
Old 23/01/2019, 05:42 PM   #4097
Logic_
Banned
 
Join Date: Jun 2015
Posts: 1,506
Reputation: 305
Default Re: Little coding questions - For general minor queries 5

Hi,

I've a few questions related to MySQL.
  1. What's the BEST way to store player records (IP, admins, bans, etc)
  2. And, what's the best way to store configuration data in the database? Such as:

PHP Code:
CREATE TABLE IF NOT EXISTS "#TABLE_SERVER_CFG" (\
    `
weatherINTEGER, \
    `
timeINTEGER, \
    `
double_scoreINTEGER, \
    `
motdVARCHAR(100), \
    `
amotdVARCHAR(100)\

I don't think it's a good use of MySQL to store such information and I should use INI or CFG files. But, I wish to keep everything all-together in one database. And the data is supposed to be updated on server shutdown or during the runtime.
Logic_ is offline   Reply With Quote
Old 24/01/2019, 09:54 PM   #4098
CrypticSin
Little Clucker
 
CrypticSin's Avatar
 
Join Date: Jan 2019
Location: UK
Posts: 8
Reputation: 0
Default Re: Little coding questions - For general minor queries 5

Hello,

I've been adding vehicles to my samp server by using the samp debug however i've discovered there was an easier way to add cars and objects to my server and that is from fusez's map editor.

Now, if i add objects and cars to my map using fusez's map editor and when i save it how would i add the objects and cars used from that filterscript into my main server? Also would it completely erase the vehicles i've added by using the samp debug?
CrypticSin is offline   Reply With Quote
Old 06/02/2019, 09:47 PM   #4099
justinnater
Huge Clucker
 
justinnater's Avatar
 
Join Date: Jan 2011
Posts: 248
Reputation: 85
Default Re: Little coding questions - For general minor queries 5

Is there any json_decode function? Need to store a json array to an Array in pawn.
justinnater is offline   Reply With Quote
Old 08/02/2019, 02:33 PM   #4100
ComDuck
Big Clucker
 
ComDuck's Avatar
 
Join Date: Feb 2019
Posts: 82
Reputation: 12
Default Re: Little coding questions - For general minor queries 5

Quote:
Originally Posted by justinnater View Post
Is there any json_decode function? Need to store a json array to an Array in pawn.
https://forum.sa-mp.com/showthread.php?t=543919

Quite straightforward to use for something as simple as your request to be fair.
ComDuck 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 07:41 AM.


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