08.02.2009, 22:18
this is how i save weapons using dubd
This obviously gives the player their weapons back when they spawn but you can use the LoadWeapons function in a timer to and check to see if ppl are in the area
pawn Код:
public LoadWeapons(playerid) {
for (new i = 0; i < 13; i++) {
new tmp[10];
valstr(tmp,i);
new slot[10];
format(slot,10,"weapslot%s",tmp);
if (dUserINT(PlayerName(playerid)).(slot)!=0)
{
new ammo[10];
format(ammo,10,"weapammo%s",tmp);
GivePlayerWeapon(playerid,dUserINT(PlayerName(playerid)).(slot),dUserINT(PlayerName(playerid)).(ammo));
}
}
}
public OnPlayerDisconnect(playerid, reason)
{
if(Registered[playerid])
{
dUserSetINT(PlayerName(playerid)).("Money",GetPlayerMoney(playerid));
dUserSetINT(PlayerName(playerid)).("Kills",MyKills[playerid]);
dUserSetINT(PlayerName(playerid)).("Deaths",MyDeaths[playerid]);
dUserSetINT(PlayerName(playerid)).("Level",Level[playerid]);
dUserSetINT(PlayerName(playerid)).("Wantedlvl",GetPlayerWantedLevel(playerid));
dUserSetINT(PlayerName(playerid)).("LoggedIn",LoggedIn[playerid]=0);
dUserSetINT(PlayerName(playerid)).("Registered",Registered[playerid]);
new weapons[13][2];
for (new i = 0; i < 13; i++)
{
GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);
if (weapons[i][0]!=0)
{
new tmp[10];
valstr(tmp,i);
new slot[10];
format(slot,10,"weapslot%s",tmp);
dUserSetINT(PlayerName(playerid)).(slot,weapons[i][0]);
new ammo[10];
format(ammo,10,"weapammo%s",tmp);
dUserSetINT(PlayerName(playerid)).(ammo,weapons[i][1]);
}
}
}
return 1;
}
public OnPlayerSpawn(playerid)
{
SetTimer("LoadWeapons",2000,0);
return 1;
}