Junior Member
Join Date: Nov 2012
Location: Thailand
|
11-17-2012
, 10:21
Re: [EXTENSION] SHVector with example usage
|
#38
|
Actually i have add both code is first page, But still be right this please help.
Quote:
[SM] Unable to load extension "shvector.ext": Older Metamod version required, probably 1.4.x (10 < 14)
[SM] Unable to load plugin "RPGx.smx": Required extension "SHVector Extension" file("shvector.ext") not running
|
This is my shvector.inc
Quote:
#if defined _shvector_included
#endinput
#endif
#define _shvector_included
#include <sourcemod>
#include <shvector>
public Plugin:myinfo =
{
name = "SHVector Test",
author = "PimpinJuice",
description = "Testing out the SHVector extension",
version = "1.0.0.0",
url = "http://pimpinjuice.net/"
};
public OnPluginStart()
{
// Create a vector
new Handle:shVec=SHVectorCreate(TYPE_CELL); // supports int,float,bool, and handle
SHVectorInsert_Cell(shVec,ITER_BACK,2.5); // Put 2.5 at the back of the vector, size should now be 1.
PrintToServer("The size of the vector is now %d",SHVectorSize_Cell(shVec));
// Lets add an int and a bool
SHVectorInsert_Cell(shVec,ITER_BACK,5);
SHVectorInsert_Cell(shVec,ITER_BACK,true);
// Right now the vector reads 2.5,5,true, in that order, but I want it to say true,5,2.5
SHVectorSwap_Cell(shVec,0,2);
// Lets see our full vector and our size
PrintToServer("size: %d\n0 == %d\n1 == %d\n2 == %f",SHVectorSize_Cell(shVec),SHVectorAt_Cell( shVec,0),SHVectorAt_Cell(shVec,1),SHVectorAt_ Cell(shVec,2));
// Lets give our system the memory back
SHVectorFree_Cell(shVec);
}
#include <core>
#define TYPE_CELL 0
#define TYPE_STRING 1
#define ITER_FRONT 0
#define ITER_BACK 1
/**
* Creates a SHVector
* @param type The type of vector to create (TYPE_CELL or TYPE_STRING)
* @return The SHVector handle of the result
*/
native Handle:SHVectorCreate(type=TYPE_CELL);
/**
* Frees the vector from the memory
* @param vector The vector to free from the memory
* @noreturn
*/
native SHVectorFree_Cell(Handle:vector);
native SHVectorFree_String(Handle:vector);
/**
* Gets the vector value at the provided position
* @param vector The vector to use
* @param pos The position in the vector to get the value of
* @return The value
*/
native any:SHVectorAt_Cell(Handle:vector,pos);
native SHVectorAt_String(Handle:vector,pos,String:st oreto[],maxlen);
/**
* Sets the vector value at the provided position
* @param vector The vector to use
* @param pos The position in the vector to set the value of
* @param value The value to set as
* @return Returns 0 if there was a failure
*/
native SHVectorSetAt_Cell(Handle:vector,pos,any:valu e);
native SHVectorSetAt_String(Handle:vector,pos,String :value[]);
/**
* Clear the whole vector provided
* @param vector The vector to use
* @noreturn
*/
native SHVectorClear_Cell(Handle:vector);
native SHVectorClear_String(Handle:vector);
/**
* Is the vector empty?
* @param vector The vector to use
* @return Returns true if the vector is empty
*/
native bool:SHVectorIsEmpty_Cell(Handle:vector);
native bool:SHVectorIsEmpty_String(Handle:vector);
/**
* Swap the contents of two pos's in a vector
* @param vector The Vector to use
* @param pos1 One of the pos's
* @param pos2 The other pos
* @return Returns 0 if there was a failure
*/
native SHVectorSwap_Cell(Handle:vector,pos1,pos2);
native SHVectorSwap_String(Handle:vector,pos1,pos2);
/**
* Insert a new item into a vector
* @param vector The vector to use
* @param where Where to put the item (ITER_FRONT or ITER_BACK)
* @param value The value to insert
* @return Returns 0 if there was a failure
*/
native SHVectorInsert_Cell(Handle:vector,where,any:v alue);
native SHVectorInsert_String(Handle:vector,where,Str ing:value[]);
/**
* Erase an item from the vector
* @param vector The vector to use
* @param pos The position to delete from the vector
* @return Returns 0 if there was a failure
*/
native SHVectorErase_Cell(Handle:vector,pos);
native SHVectorErase_String(Handle:vector,pos);
/**
* The amount of items in the vector
* @param vector The vector to use
* @return Returns the amount of items in the vector
*/
native SHVectorSize_Cell(Handle:vector);
native SHVectorSize_String(Handle:vector);
/**
* @endsection
*/
/**
* Do not edit below this line!
*/
public Extension:__ext_shvector =
{
name = "SHVector Extension",
file = "shvector.ext",
#if defined AUTOLOAD_EXTENSIONS
autoload = 1,
#else
autoload = 0,
#endif
#if defined REQUIRE_EXTENSIONS
required = 1,
#else
required = 0,
#endif
};
|
Last edited by Mechanisms; 11-17-2012 at 10:21.
|
|