Raised This Month: $ Target: $400
 0% 

Hours trying, I had to ask for help..


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
TiToTal
Member
Join Date: Feb 2006
Old 03-04-2006 , 05:53   Hours trying, I had to ask for help..
Reply With Quote #1

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
Attached Files
File Type: sma Get Plugin or Get Source (carmod.sma - 615 views - 12.3 KB)
TiToTal is offline
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 03-04-2006 , 08:43  
Reply With Quote #2

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)    }
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
TiToTal
Member
Join Date: Feb 2006
Old 03-05-2006 , 01:27  
Reply With Quote #3

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 is offline
TiToTal
Member
Join Date: Feb 2006
Old 03-05-2006 , 05:54  
Reply With Quote #4

come on people... I spend hours, one day trying to make this work
and until now, nothing =(
TiToTal is offline
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 03-05-2006 , 09:07  
Reply With Quote #5

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
__________________
hello, i am pm
PM is offline
TiToTal
Member
Join Date: Feb 2006
Old 03-05-2006 , 09:33  
Reply With Quote #6

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...
TiToTal is offline
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 03-05-2006 , 10:30  
Reply With Quote #7

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
__________________
hello, i am pm
PM is offline
TiToTal
Member
Join Date: Feb 2006
Old 03-05-2006 , 11:18  
Reply With Quote #8

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

Thank you... you rox..
TiToTal is offline
Kirby07
Junior Member
Join Date: Feb 2006
Old 03-05-2006 , 18:46  
Reply With Quote #9

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?
Kirby07 is offline
Send a message via AIM to Kirby07
TiToTal
Member
Join Date: Feb 2006
Old 03-06-2006 , 08:53  
Reply With Quote #10

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..
try copying other codes and made yourself one... I made one myself, but it's kind mess, works, but it's little confusing....
TiToTal is offline
Reply



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

Forum Jump


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


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