For some reason when writing my plugin in Source Pawn, the KeyValues file is not being created! This is my code:
Code:
static String:cpPath[PLATFORM_MAX_PATH];
public OnPluginStart()
{
CreateDirectory("addons/sourcemod/data/playerinfo", 511);
BuildPath(Path_SM, cpPath, sizeof(cpPath), "data/playerinfo/checkPoints.txt");
}
public cpMenuCallBack(Handle:menu3,MenuAction:action, Client, Position)
{
if(action == MenuAction_Select)
{
PrintToChat(Client, cpPath);
new String:Item[20];
GetMenuItem(menu3, Position, Item, sizeof(Item));
DisplayMenu(cpMenu,Client,MENU_TIME_FOREVER);
new Handle:cpDB = CreateKeyValues("CheckPoints");
decl String:steamID[30];
GetClientAuthString(Client, steamID, sizeof(steamID));
if(StrEqual(Item,"saveCP"))
{
new Float:tempMapLoc[3];
new Float:tempMapAng[3];
new String:tl1[20], String:tl2[20], String:tl3[20], String:ta1[20], String:ta2[20], String:ta3[20];
GetClientAbsOrigin(Client, tempMapLoc);
GetClientAbsAngles(Client, tempMapAng);
FloatToString(tempMapLoc[0], tl1, sizeof(tl1));
FloatToString(tempMapLoc[1], tl2, sizeof(tl2));
FloatToString(tempMapLoc[2], tl3, sizeof(tl3));
FloatToString(tempMapAng[0], ta1, sizeof(ta1));
FloatToString(tempMapAng[1], ta2, sizeof(ta2));
FloatToString(tempMapAng[2], ta3, sizeof(ta3));
FileToKeyValues(cpDB, cpPath);
if(KvJumpToKey(cpDB, steamID, true)){
KvSetString(cpDB, "lx", tl1);
KvSetString(cpDB, "lz", tl2);
KvSetString(cpDB, "ly", tl3);
KvSetString(cpDB, "ax", ta1);
KvSetString(cpDB, "az", ta2);
KvSetString(cpDB, "ay", ta3);
PrintToChat(Client, "[GetRightMate] You Saved Your Checkpoint!");
}else{
PrintToChat(Client, "[GetRightMate] Saving Your Checkpoint Failed!");
}
}else if(StrEqual(Item,"loadCP")){
FileToKeyValues(cpDB, cpPath);
if(KvJumpToKey(cpDB, steamID, true))
{
new String:l1[MAX_NAME_LENGTH], String:l2[MAX_NAME_LENGTH], String:l3[MAX_NAME_LENGTH];
new String:a1[MAX_NAME_LENGTH], String:a2[MAX_NAME_LENGTH], String:a3[MAX_NAME_LENGTH];
KvGetString(cpDB, "lx", l1, sizeof(l1), "NULL");
KvGetString(cpDB, "lz", l2, sizeof(l2), "NULL");
KvGetString(cpDB, "ly", l3, sizeof(l3), "NULL");
KvGetString(cpDB, "ax", a1, sizeof(a1), "NULL");
KvGetString(cpDB, "az", a2, sizeof(a2), "NULL");
KvGetString(cpDB, "ay", a3, sizeof(a3), "NULL");
if(StrEqual(l1, "NULL",false) && StrEqual(l2, "NULL",false) && StrEqual(l3, "NULL",false))
{
PrintToChat(Client, "[GetRightMate] No Location Saved! Save a Location To Use This Feature!");
} else{
new Float:location[3];
new Float:angle[3];
new Float:vel[3];
location[0] = StringToFloat(l1);
location[1] = StringToFloat(l2);
location[2] = StringToFloat(l3);
vel[0] = 0.00;
vel[1] = 0.00;
vel[2] = 0.00;
angle[0] = StringToFloat(a1);
angle[1] = StringToFloat(a2);
angle[2] = StringToFloat(a3);
TeleportEntity(Client, location, angle, vel);
PrintToChat(Client, "[GetRightMate] Loaded CheckPoint!");
location[0] = 0.00;
location[1] = 0.00;
location[2] = 0.00;
vel[0] = 0.00;
vel[1] = 0.00;
vel[2] = 0.00;
angle[0] = 0.00;
angle[1] = 0.00;
angle[2] = 0.00;
}
}
}
CloseHandle(cpDB);
}
}