Spawn Weapon saving system
#1

Hi everybody , i have a little problem with my script :

- i would like to create a spawn weapon menu with somes guns , i know how to do the menu ... but i don't know for saving the weapons at the spawn.

I will appreciate your help , thanks
Reply
#2

look in other gamemodes.
A lot of gamemodes have that as an feature.
Download them and check them.
Reply
#3

have you any example to see?
Reply
#4

Well its not much but this is something i had done a while back.
Still needs some fine tuning for myself but could help you out a lot.
You will need DracoBlue's DUDB for these commands to work.

What it does is cycle through all the weapon slots and writes the data to a variable.
Then saves it to username.dudb.sav

ReturnAccount(playerid) is just a simple function I made that returns your username.
I don't need to explain anymore.

To save the weapons
Код:
stock SaveWeapons(playerid)
{
  new wepinfo[13][2], strWep[10], strAmmo[50], strSend[128];
  for(new i = 0; i < 13; i++)
  {
    GetPlayerWeaponData(playerid, i, wepinfo[i][0], wepinfo[i][1]);
    format(strWep, 10, "Wep%d", i);
    format(strAmmo, 50, "Ammo%d", i);
    udb_UserSetInt(ReturnAccount(playerid), strWep, wepinfo[i][0]);
    udb_UserSetInt(ReturnAccount(playerid), strAmmo, wepinfo[i][1]);
    format(strSend, 128, ":%s: All weapons and ammo saved.", "SNX");
    SendClientMessage(playerid, COLOR_GOLD, strSend);
  }
}
And this loads the weapons in their right slot.

Код:
stock LoadWeapons(playerid)
{
  new strWep[10], strAmmo[50], strSend[128];
  for(new i = 0; i < 13; i++)
  {
    format(strWep, 10, "Wep%d",i);
    format(strAmmo, 50, "Ammo%d",i);
    GivePlayerWeapon(playerid, udb_UserInt(ReturnAccount(playerid), strWep), udb_UserInt(ReturnAccount(playerid), accounts, strAmmo));
  }
  format(strSend, 128, ":%s: All weapons and ammo restored.", "SNX");
  return SendClientMessage(playerid, COLOR_GOLD, strSend);
}
Reply
#5

Quote:
Originally Posted by ShizNator
Well its not much but this is something i had done a while back.
Still needs some fine tuning for myself but could help you out a lot.
You will need DracoBlue's DUDB for these commands to work.

What it does is cycle through all the weapon slots and writes the data to a variable.
Then saves it to username.dudb.sav

ReturnAccount(playerid) is just a simple function I made that returns your username.
I don't need to explain anymore.

To save the weapons

Does it save automaticly your weapons?
Код:
stock SaveWeapons(playerid)
{
  new wepinfo[13][2], strWep[10], strAmmo[50], strSend[128];
  for(new i = 0; i < 13; i++)
  {
    GetPlayerWeaponData(playerid, i, wepinfo[i][0], wepinfo[i][1]);
    format(strWep, 10, "Wep%d", i);
    format(strAmmo, 50, "Ammo%d", i);
    udb_UserSetInt(ReturnAccount(playerid), strWep, wepinfo[i][0]);
    udb_UserSetInt(ReturnAccount(playerid), strAmmo, wepinfo[i][1]);
    format(strSend, 128, ":%s: All weapons and ammo saved.", "SNX");
    SendClientMessage(playerid, COLOR_GOLD, strSend);
  }
}
And this loads the weapons in their right slot.

Код:
stock LoadWeapons(playerid)
{
  new strWep[10], strAmmo[50], strSend[128];
  for(new i = 0; i < 13; i++)
  {
    format(strWep, 10, "Wep%d",i);
    format(strAmmo, 50, "Ammo%d",i);
    GivePlayerWeapon(playerid, udb_UserInt(ReturnAccount(playerid), strWep), udb_UserInt(ReturnAccount(playerid), accounts, strAmmo));
  }
  format(strSend, 128, ":%s: All weapons and ammo restored.", "SNX");
  return SendClientMessage(playerid, COLOR_GOLD, strSend);
}
DOES it save the weapons automaticly>??
Reply
#6

doesn't work
Reply
#7

It does work but this requires you to have a a login system using dudb so that

pawn Код:
udb_UserSetInt(ReturnAccount(playerid), strWep, wepinfo[i][0]);
Will write it in the dudb username file.

ReturnAccount(playerid) is just a simple command that return the account name of the user.
something like so.

pawn Код:
stock ReturnAccount(playerid)
{
  new PlayerName[30], str[30];
  GetPlayerName(playerid, PlayerName, 30);
  format(str, 30, "%s", PlayerName);
  return PlayerName;
}
You just need to have a file created with your username. example: ShizNator.dudb.sav

also you need to call the commands for them to work.

And no I can't make it work for you. I can't test anything I code in pawn I lost my copy of GTA and can't find a legal copy except the steam version I got and unfortunately it ai'nt compatible with SA:MP.

Anybody who took the time to learn the basics of SA:MP, basic dudb login and text commands
could make this work.

So happy learning and good luck!


Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)