Hello everyone! I've recently started coding and I think I'm doing pretty well understanding sourcepawn in general. However when it comes to databases, it takes a dark turn.
I have no idea how to use them, and create them, getting data and all this yadayada. If someone could send me an example of how to set up a proper database script I would be really thankful.
I'm doing a project on my own, that's why I'm trying to learn sql. Already read the wiki page, didn't find it helpful enough. I'm trying to do a weapons menu, the selected weapon will be inserted into the database and saved. When the player spawns, the selected weapon will be given.
This is an example, I want a database to save all the information, thank you:
PHP Code:
#include <sourcemod>
#include <sdktools>
char g_sWeapon[MAXPLAYERS + 1][32];
#define DEAGLE "weapon_deagle"
public void OnPluginStart()
{
RegConsoleCmd("sm_weapon", Cmd_Weapon);
}
public Action Cmd_Weapon(int iClient, int iArgs)
{
Menu hMenu = new Menu(Menu_Weapon);
hMenu.SetTitle("Weapons");
hMenu.AddItem("", "Deagle");
hMenu.Display(iClient, MENU_TIME_FOREVER);
return Plugin_Handled;
}
public int Menu_Weapon(Menu hMenu, MenuAction hAction, int iClient, int iParam)
{
switch (hAction)
{
case MenuAction_Select:
{
switch (iParam)
{
case 0: g_sWeapon[iClient] = DEAGLE;
}
GiveClientWeapon(iClient);
}
case MenuAction_End:
delete hMenu;
}
}
void GiveClientWeapon(int iClient)
{
int iWeapon = GetPlayerWeaponSlot(iClient, 2);
RemovePlayerItem(iClient, iWeapon);
AcceptEntityInput(iWeapon, "Kill");
GivePlayerItem(iClient, g_sKnife[iClient]);
}
Sincerely -
Armin (Mugiwara).