[Basic] Data Type - Forum
Counter-Strike Federation Welcome , Leecher | RSS | Saturday, 10 December 16
A Place Where Player Becomes Developer Home | Sign Up | Log In
[ New messages · Members · Forum rules · Search · RSS ]
Page 1 of 11
Forum » AMX Mod X » Scripting » Code Snippets/Tutorials » [Basic] Data Type
[Basic] Data Type
Grade: Commander DavidJrDate: Monday, 19 January 15, 3:00 PM | Message # 1
Commander
Clan: Executive
Experience: 2256
Status: Offline
Ada banyak data type untuk programing language seperti pada C++ ada char, int, float dan lain-lain. Pawn juga memiliki nya, tetapi hanya sedikit. Berikut data type nya.



Contoh penggunaan

Data type new
Code
new a

a = 5 + 2

client_print(0, print_chat, "Result: %d", a)


Output
Code
Result: 7


Data type float
Code
new Float:a

a = 1.0 + 3.0

client_print(0, print_chat, "Result: %f", a)


Output
Code
Result: 3.99999999


Data type bool
Code
new bool:a

a = 1

if (a == 1)
{
      client_print(0, print_chat, "Result: True")
}
else if (a == 0)
{
      client_print(0, print_chat, "Result: False")
}


Output
Code
Result: True


NB: nilai lebih besar dari 0 dianggap benar oleh bool, jika lebih kecil sama dengan 0 maka dianggap salah

Loh? Lalu? String kemana?
Untuk string khusus menggunakan array, contohnya:

Data type string
Code
new a[11]
format(a, 10, "Hello world")

client_print(0, print_chat, "Result: %s", a)


Output:
Code
Result: Hello world


array 11 adalah besar nya string yg dapat di tampung. Contoh:
Code
//Input
a[5]
format(a, 4, "Hello")

// structure
// a[0] = 'H'
// a[1] = 'e'
// a[2] = 'l'
// a[3] = 'l'
// a[4] = 'o'


Lalu, jika string lebih panjang dari size array nya bagaimana? Ya terpotong, coba lihat contoh berikut

Code
//Input
a[4]
format(a, 3, "Hello")

// structure
// a[0] = 'H'
// a[1] = 'e'
// a[2] = 'l'
// a[3] = 'l'


Output nya akan menjadi Hell

Sekian dari saya biggrin
Attachments: 1095943.png(3Kb)


posted via BlackBerry

Personal Site | CSF Website
 
Grade: Copral PredoDate: Monday, 19 January 15, 3:41 PM | Message # 2
Copral
Clan: Member
Experience: 16
Status: Offline
mantap vid (y) mudah dimengerti

Added (19 January 15, 2:41 PM)
---------------------------------------------
mantap vid (y) mudah dimengerti

 
Grade: Copral callmetoto2008Date: Monday, 19 January 15, 9:03 PM | Message # 3
Copral
Clan: Donator
Experience: 11
Status: Offline
More.. more.. kami butuh tambahan lagi mas  [TER];)
 
Grade: Commander DavidJrDate: Tuesday, 20 January 15, 8:32 AM | Message # 4
Commander
Clan: Executive
Experience: 2256
Status: Offline
Quote callmetoto2008 ()
More.. more.. kami butuh tambahan lagi mas [TER];)
Butuh tutor apa nih? wink


posted via BlackBerry

Personal Site | CSF Website
 
Forum » AMX Mod X » Scripting » Code Snippets/Tutorials » [Basic] Data Type
Page 1 of 11
Search:

Mirum
sample map