Raised This Month: $51 Target: $400
 12% 

[EXTENSION] SHVector with example usage


Post New Thread Reply   
 
Thread Tools Display Modes
Mitchell
~lick~
Join Date: Mar 2010
Old 11-17-2012 , 12:01   Re: [EXTENSION] SHVector with example usage
Reply With Quote #41

Quote:
Originally Posted by Mechanisms View Post
Really don't know please complete shvector.inc.
It is outdated, use adt_array. ask for help in the scripting section.
Mitchell is offline
Mechanisms
Junior Member
Join Date: Nov 2012
Location: Thailand
Old 11-17-2012 , 13:02   Re: [EXTENSION] SHVector with example usage
Reply With Quote #42

Quote:
Originally Posted by Mitchell View Post
It is outdated, use adt_array. ask for help in the scripting section.
Yes, How to do that? I have no C++ basic
Mechanisms is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 11-17-2012 , 15:21   Re: [EXTENSION] SHVector with example usage
Reply With Quote #43

For people who want to port code from shvector to adt_array, here's how the commands map to adt_array:

PHP Code:
// Handle:vector = SHVectorCreate(TYPE_CELL);
new Handle:array = CreateArray();

// Handle:vector = SHVectorCreate(TYPE_STRING);
new Handle:array = CreateArray(ByteCountToCells(64)); // for 64 character strings

// SHVectorFree_Cell(vector);
// SHVectorFree_String(vector);
CloseHandle(array);

// new value = SHVectorAt_Cell(vector, pos);
new value GetArrayCell(array, pos);

// new Handle:value = SHVectorAt_Cell(vector, pos);
new Handle:value Handle:GetArrayCell(array, pos);
// GetArrayFloat also exists

decl String:myString[64];
// SHVectorAt_String(vector, pos, myString, sizeof(myString));
GetArrayString(array, posmyStringsizeof(myString));

// SHVectorSetAt_Cell(vector, pos, value);
SetArrayCell(array, posvalue)
PushArrayCell(array, value); // To add new items to the end of the array
//SetArrayFloat and PushArrayFloat also exist

// SHVectorSetAt_String(vector, pos, value);
SetArrayString(array, posvalue);
PushArrayString(array, value); // To add new items to the end of the array

// SHVectorClear_Cell(vector);
// SHVectorClear_String(vector)
ClearArray(array);

// if (SHVectorIsEmpty_Cell(vector))
// if (SHVectorIsEmpty_String(vector))
if (GetArraySize(array) == 0)

// SHVectorSwap_Cell(vector, pos1, pos2)
// SHVectorSwap_String(vector, pos1, pos2)
SwapArrayItems(array, pos1pos2)

// SHVectorInsert_Cell(vector, where, value);
InsertArrayCell(array, wherevalue)
// InsertArrayFloat also exists

// SHVectorInsert_String(vector, where, value);
InsertArrayString(array, wherevalue);

// SHVectorErase_Cell(vector, pos);
// SHVectorErase_String(vector, pos)
RemoveFromArray(array, pos);

// SHVectorSize_Cell(vector)
// SHVectorSize_String(vector)
GetArraySize(vector
Keep in mind that you can't SetArrayCell or SetArrayString to cells that don't exist... you can ResizeArray(array, 30) to resize the array to have 30 elements (for example) which will create new, empty values in the array is smaller than 30 (or get rid of elements past pos 29 if larger than 30). You can also ShiftArrayUp(array, pos) to create a new empty value in the middle of an array at position pos
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 11-17-2012 at 15:28.
Powerlord is offline
Mechanisms
Junior Member
Join Date: Nov 2012
Location: Thailand
Old 11-18-2012 , 05:51   Re: [EXTENSION] SHVector with example usage
Reply With Quote #44

Quote:
Originally Posted by Powerlord View Post
For people who want to port code from shvector to adt_array, here's how the commands map to adt_array:

PHP Code:
// Handle:vector = SHVectorCreate(TYPE_CELL);
new Handle:array = CreateArray();

// Handle:vector = SHVectorCreate(TYPE_STRING);
............................ 
Keep in mind that you can't SetArrayCell or SetArrayString to cells that don't exist... you can ResizeArray(array, 30) to resize the array to have 30 elements (for example) which will create new, empty values in the array is smaller than 30 (or get rid of elements past pos 29 if larger than 30). You can also ShiftArrayUp(array, pos) to create a new empty value in the middle of an array at position pos
OK, I'll try but you can explain some question?
1.
Code:
/**
*
*
*
*/
What it mean? like a Open function { when end then } or just comment?

2. In your code if i want to use just coppy then edit?
Quote:
new Handle:array = CreateArray();
Edit Array , pos , where , value?
so how can i know that should be what or looking in my console?

Thanks for Asnwer

PS. Sorry for my bad english

Last edited by Mechanisms; 11-18-2012 at 05:52.
Mechanisms is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 11-18-2012 , 07:44   Re: [EXTENSION] SHVector with example usage
Reply With Quote #45

1. /* starts a comment and */ ends it.

2. I'm clueless as to what you're trying to ask here.
bl4nk is offline
Mechanisms
Junior Member
Join Date: Nov 2012
Location: Thailand
Old 11-18-2012 , 10:14   Re: [EXTENSION] SHVector with example usage
Reply With Quote #46

Quote:
Originally Posted by bl4nk View Post
1. /* starts a comment and */ ends it.

2. I'm clueless as to what you're trying to ask here.
I mean what thing i must to use for RPGx!

Code:
https://forums.alliedmods.net/showthread.php?p=493552
Thanks for helps.

Last edited by Mechanisms; 11-18-2012 at 10:15.
Mechanisms 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 19:31.


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