Raised This Month: $ Target: $400
 0% 

PAWN Objects


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 04-22-2012 , 13:52   PAWN Objects
Reply With Quote #1

Now.....i'm aware that pawn is a non-object oriented scripting language. So the closest thing you can get to that is either an array, including all the variables within the object, or a series of well documented variables.

Going along with the array way of doing things:

Code:
new object[3][34]
new i_obID = id
new sz_obName[32] = get_user_name(id)
new sz_obSteamID[34] = get_user_authid(id)

object[0] = i_obID
object[1] = sz_obName
object[2] = sz_obSteamID
Mind you this isn't exact code, i'm aware passing the ID can get me all this, i'm just using it all as the easiest example for those who aren't fully aware how objects in C++/Java work.

I suppose it all boils down to how to properly utilize a hanging(fringed} matrix....but pawn is so weird to me, and i'm out of proper practice with other languages.

i think it looks pretty, but when compiling the compiler throws errors like "array size do not match; or destination size too small"

Last edited by Liverwiz; 04-22-2012 at 13:54.
Liverwiz is offline
ProIcons
Senior Member
Join Date: Jan 2009
Location: Greece - Salonica
Old 04-22-2012 , 14:03   Re: PAWN Objects
Reply With Quote #2

try use this
new object[10][100];
__________________
function rb return $regsubex($$1-,/(.)/g,$+($chr(2) $+ $chr(3),$r(2,15),$chr(2),\1))
ProIcons is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 04-22-2012 , 14:36   Re: PAWN Objects
Reply With Quote #3

just attempted your concept of large array sizes:
PHP Code:
new object[4][64]
object[0][0] = id
object
[1][] = "ThatOneGuy" 
and threw me an error: invalid expression; assumed zero
referencing the "object[1][] " line
Liverwiz is offline
ProIcons
Senior Member
Join Date: Jan 2009
Location: Greece - Salonica
Old 04-22-2012 , 14:40   Re: PAWN Objects
Reply With Quote #4

yes this can caused because you didn't specify anything on the 2nd dimmension of the array.

Try object[1]="ThatOneGuy";
__________________
function rb return $regsubex($$1-,/(.)/g,$+($chr(2) $+ $chr(3),$r(2,15),$chr(2),\1))
ProIcons is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 04-22-2012 , 14:43   Re: PAWN Objects
Reply With Quote #5

I could have sworn that didn't work when i tried it earlier.....but it compiled. Much thanks! will edit if i have any more problems when actually releasing it into the code i'm working on.

[EDIT] actually....while i have your attention:
why is it the compiler doesn't like this
Code:
 const sz_command[] = "screenshot", i_ssCount = 32
is the 'const' declaration just a fancy way of making you hate your life?

Last edited by Liverwiz; 04-22-2012 at 14:48.
Liverwiz is offline
ProIcons
Senior Member
Join Date: Jan 2009
Location: Greece - Salonica
Old 04-22-2012 , 14:52   Re: PAWN Objects
Reply With Quote #6

new const sz_command[] = { "Screenshot" };

A working example is,

PHP Code:
new const HitPlaceStrings[][] = { "Generic","Head","Chest","Stomach","LeftArm","RightArm","LeftLeg","RightLeg" };
new const 
WeaponNames[][] = { 
    
"","P228 Compact","Shield","Schmidt Scout","He Grenade","XM1014 M4","C4 Bomb Explosive","Ingram MAC-10","Steyr AUG A1","Smoke Grenade","Dual Elite Berettas",
    
"FiveseveN","UMP 45","SG-550 Auto-Sniper","IMI Galil","Famas","USP .45 ACP Tactical","Glock 18C","AWP Magnum Sniper","MP5 Navy","M249 Para Machinegun",
    
"M3 Super 90","M4A1 Carbine","Schmidt TMP","G3SG1 Auto-Sniper","FlashBang","Desert Eagle .50 AE","SG-552 Commando","AK-47 Kalashnikov","Knife","ES P90" };
new const 
WeaponShortNames[][] = { 
    
"""weapon_p228""0""weapon_scout""weapon_hegrenade""weapon_xm1014""weapon_c4""weapon_mac10","weapon_aug""weapon_smokegrenade""weapon_elite"
    
"weapon_fiveseven""weapon_ump45""weapon_sg550","weapon_galil""weapon_famas""weapon_usp""weapon_glock18""weapon_awp""weapon_mp5navy""weapon_m249",
    
"weapon_m3""weapon_m4a1""weapon_tmp""weapon_g3sg1""weapon_flashbang""weapon_deagle""weapon_sg552","weapon_ak47""weapon_knife""weapon_p90" }; 
__________________
function rb return $regsubex($$1-,/(.)/g,$+($chr(2) $+ $chr(3),$r(2,15),$chr(2),\1))

Last edited by ProIcons; 04-22-2012 at 14:53.
ProIcons is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 04-22-2012 , 15:04   Re: PAWN Objects
Reply With Quote #7

its all about that 'new' qualifier..... grumble.....

however....thanks, man!
Liverwiz is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-22-2012 , 15:32   Re: PAWN Objects
Reply With Quote #8

Quote:
Originally Posted by Liverwiz View Post
Code:
new object[3][34]
new i_obID = id
new sz_obName[32] = get_user_name(id)
new sz_obSteamID[34] = get_user_authid(id)

object[0] = i_obID
object[1] = sz_obName
object[2] = sz_obSteamID
You are trying to assign a scalar to an array. I'm sure you can see that that can't be correct .

Also, you can't assign an array sized 32 to an array sized 34, IIRC. They have to be the same size. So, it is generally recommended to never assign arrays with "=" but to instead use copy().
__________________

Last edited by fysiks; 04-22-2012 at 15:35.
fysiks is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 04-22-2012 , 16:58   Re: PAWN Objects
Reply With Quote #9

Quote:
Originally Posted by fysiks View Post
Also, you can't assign an array sized 32 to an array sized 34, IIRC. They have to be the same size. So, it is generally recommended to never assign arrays with "=" but to instead use copy().
but using copy() in that manner makes for such ambiguous code....

and if you can't put a 32bit array in a 34, how would you propose to set up a fringed matrix? where there's isn't always the same number of columns in each row. or vise versa.

refer to the visual example below....

Code:
[00 01 02 03 04]
[10 11 12]
[20 21 22 23]
Liverwiz is offline
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 04-22-2012 , 18:16   Re: PAWN Objects
Reply With Quote #10

Quote:
Originally Posted by Liverwiz View Post
but using copy() in that manner makes for such ambiguous code....

and if you can't put a 32bit array in a 34, how would you propose to set up a fringed matrix? where there's isn't always the same number of columns in each row. or vise versa.

refer to the visual example below....

Code:
[00 01 02 03 04]
[10 11 12]
[20 21 22 23]
Don't think that's possible. I think the closest you could get to something like that is setting up a matrix with the maximum rows and columns that you would need, and then add ridiculous values to the spots that you want to be "empty" (just in case 0 is significant to you), so that you know which cell is not a "part" of the matrix. Or you could do something similar but create another 1-D matrix that holds the amount of columns in each row of the matrix and leave the empty cells as 0.
__________________
Quote:
Originally Posted by DarkGod View Post
nikhilgupta generates his plugins using sheer awesome.
If you like my work, please
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
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

Forum Jump


All times are GMT -4. The time now is 07:50.


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