AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Hours trying, I had to ask for help.. (https://forums.alliedmods.net/showthread.php?t=24878)

TiToTal 03-04-2006 05:53

Hours trying, I had to ask for help..
 
1 Attachment(s)
well, I am trying to change one little thing in one plugin... (attached)
(this plugin is for The Specialists mod)

there are these lines: (I think you have to focus only at them)

Quote:

if(save == 1 || equal(save1, "1")) {
get_cvar_string("rp_carsfile",szFilename,63)
if (!file_exists(szFilename)) return PLUGIN_HANDLED

new message[64]
format(message, 63, "amx_makecar %s %i %i %i 0", itemname, origin[0], origin[1], origin[2])
write_file(szFilename,message,-1)
}


and I would like to change it for something like this: (I tried and it didn't work properly)

Quote:

if(save == 1 || equal(save1, "1")) {
get_cvar_string("rp_carsfile",szFilename,63)
if (!file_exists(szFilename)) return PLUGIN_HANDLED

new message[64]
format(message, 63, "amx_makecar car_viper %i %i %i %i", origin[0], origin[1], origin[2], angles[0])
write_file(szFilename,message,-1)
}

Well, when I put this second code, it doesn't put in the fourth "%i" the value of the angle...

I just want to know how to "%i" gets the right angle value..

please help me... =) I spend all the night with it, and I didn't get it working :cry:

Xanimos 03-04-2006 08:43

try something like
Code:
   if(save == 1 || equal(save1, "1")) {       get_cvar_string("rp_carsfile",szFilename,63)       if (!file_exists(szFilename)) return PLUGIN_HANDLED       new message[64]       format(message, 63, "amx_makecar %s %i %i %i Angles{ %f , %f , %f }", itemname, origin[0], origin[1], origin[2] , angles[0] , angles[1] , angles[2])       write_file(szFilename,message,-1)    }

TiToTal 03-05-2006 01:27

Quote:

Originally Posted by Suicid3
try something like
Code:
   if(save == 1 || equal(save1, "1")) {       get_cvar_string("rp_carsfile",szFilename,63)       if (!file_exists(szFilename)) return PLUGIN_HANDLED       new message[64]       format(message, 63, "amx_makecar %s %i %i %i Angles{ %f , %f , %f }", itemname, origin[0], origin[1], origin[2] , angles[0] , angles[1] , angles[2])       write_file(szFilename,message,-1)    }

I think it wont work as I need... because this part of the script only write down in carsfile.ini these informations: origin[0], origin[1], origin[2] and the other information should be only one value that determines to where the car is pointing...

I know that when the cript loads the four car informations (3 origins and 1 angle) it loads correctly, I know this bexause I changed manually the fourth value (the angle one) in carsfile.ini and there was the car looking at the right direction...

look what contains in the carsfile.ini

Code:

; CAR SPAWNS HERE
amx_makecar car_polambo -980 -3146 -259 0
amx_makecar car_polambo -980 -3015 -259 0
amx_makecar car_polambo -980 -2887 -259 0

these 3 cars are pointing to... I don't know, its North I think...

but if I change one of these, for example to:
"amx_makecar car_polambo -980 -3015 -259 90"
I know that the car will be at the same place, but turned 90 degrees...

(Sorry my english again, maybe its not clear for you guys understand)

TiToTal 03-05-2006 05:54

come on people... I spend hours, one day trying to make this work :cry:
and until now, nothing =(

PM 03-05-2006 09:07

I, I guess that your problem is that you are using %i for the angles[0] variable while angles is an array of floating point numbers. This should give you some weird values.

Try changing the fourth %i to %f

edit:

also, note that angles[0] is pitch, angles[1] is yaw and angles[2] is roll. I think at least.

This shows which is which I guess: http://www.dform.com/gif/dirhead.gif

TiToTal 03-05-2006 09:33

Quote:

Originally Posted by PM
I, I guess that your problem is that you are using %i for the angles[0] variable while angles is an array of floating point numbers. This should give you some weird values.

Try changing the fourth %i to %f

edit:

also, note that angles[0] is pitch, angles[1] is yaw and angles[2] is roll. I think at least.

This shows which is which I guess: http://www.dform.com/gif/dirhead.gif

Thank you... it may explain why I was getting numbers like: -29073264 lol... ^^

EDIT: IT WORKED... THANKYOU THANKYOU THANKYOU =D

IT WAS SO SIMPLE... ARGH... Its what happen when you star codding without studing it before, lol... THANKYOU MAN I LOVE YOU =D

I gave you all karma I could, lol...

PM 03-05-2006 10:30

In case you are interested in the technical details...

"Normal" integer variables can only store whole numbers.

Let's start with unsigned numbers. Unsigned means that the number doesn't have a sign - it's always positive. You don't really have these in Pawn IIRC but that's a different thing. In AMX Mod X, a variable is either 32 or 64 bit, depending on the architecture you run on.

Anyway, with unsigned numbers, the variable simply contains the binary representation of the number it holds. For the decimal number 9, this would be 1001 for example. 7 would be 111. And so on. If you need to be able to store negative numbers as well, you usually reserve one bit for "sign"; usually the most significant bit; if this bit is 1, the number is negative. There are more used methods of storing negative integers; the most widely used one is the "two's complement" thing, I guess google will help you on these.

Anyway, you can compute the decimal value of a binary number by doing:
bit0 * 1 + bit1 * 2 + bit2 * 4 + bit3 * 8 + bit4 * 16 + bit5 * 32 + ...

bit0 is the LSB, least significant bit, which you usually draw on the far right. ie. the number 13 would be stored like this in a 8 bit number:
00001101
this is: 1*1 + 0*2 + 1*4 + 1*8 + 0*16 + ... = 1 + 4 + 8 = 13


If you want to store numbers with decimal points, you have to pick a different storage method. Usually people use either fixed point numbers or floating point numbers. For some reason I associate fixed point numbers with banking software and such; in the PC and graphics world they're very rare.

So, fixed point numbers store the whole part and the rest. ie. 13.37 would be stored as two separate numbers: 13 and 37. Floating point numbers, on the other hand, store the "mantissa" and the exponent. ie. they store 1337 as a whole and then tell you where to place the decimal point.

Usually, computers use the "IEEE 754" standard for floating point numbers; for 32 bit numbers, it specifies 1 bit for sign, 8 bits for the exponent and 23 bits for mantissa. So if you store a floating point number and then interprete it as a "normal" integer, you will get weird, usually big results (big because the exponent is stored in the highest 9 bits (following the sign), so when it is non-zero, your binary number will get some pretty big value).

I hope I could clarify this :)

TiToTal 03-05-2006 11:18

Nice... I got it... at least the idea... it's very nice the way it works. Thanks for the explanation... :D it shows the logic in something I would never find alone :lol:

Thank you... you rox.. :D

Kirby07 03-05-2006 18:46

Hey what is the command in the sql for carmod as items? I have spent soo much time trying out different things and looking? Can anyone help me?

TiToTal 03-06-2006 08:53

Quote:

Originally Posted by Kirby07
Hey what is the command in the sql for carmod as items? I have spent soo much time trying out different things and looking? Can anyone help me?

You can't just add one line in the sql to make car as items... I understood your question, but I think you haven't made it clear enough. Not even everyone here know you're referring to TSRP.. :roll:
try copying other codes and made yourself one... I made one myself, but it's kind mess, works, but it's little confusing.... :wink:


All times are GMT -4. The time now is 20:13.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.