10.04.2013, 09:52
Quote:
My issue was another, but thanks.
But now I would like to use the strfind function, that in C++ and GDK don't exists. So... how I can modify this code to work properly? pawn Code:
|
Quote:
pawn Code:
|
pawn Code:
#include <algorithm>
#include <string>
#include <map>
std::map<std::string,unsigned int> Vehicles;
void InitVehicleNames()
{
//for consistency use only lowercase, or uppercase, but not both
Vehicles["landstalker"] = 400;
Vehicles["bravura"] = 401;
//....
}
unsigned int GetVehicleIdFromName(std::string name)//returns 0 when not found
{
//uncomment if you want case-insensetive compare
//std::string lowername(name);
//std::transform(name.begin(), name.end(), name.begin(), ::tolower);
if(Vehicles.find(name) != Vehicles.end())
return Vehicles[name];//change 'name' to 'lowername' for case insensetive compare
return 0;
}