24.09.2017, 01:22
(
Последний раз редактировалось ChristofferHoffmann; 24.09.2017 в 01:27.
Причина: Changed title.
)
Hey.
I have been attempting to use SetPVarInt to share information between my gamemode and a filterscript. Obviously the weapons should be serversided so I made use of an include I found that looks like this:
I then made a quick test by doing this:
When I first tested it there were no issues, but that was because I didn't try hard enough. After playing around for a while with some weapons I realised that after clicking a bit too many times it would start returning the message "Hack" with weapons that weren't spawned in. It seems that after a while the setpvarint goes to 0 or something goes wrong. I'm just not sure what it is.
I have been attempting to use SetPVarInt to share information between my gamemode and a filterscript. Obviously the weapons should be serversided so I made use of an include I found that looks like this:
Код:
stock ResetWeapons(playerid)
{
SetPVarInt(playerid, "Brass Knuckles", 0);
SetPVarInt(playerid, "Golf Club", 0);
SetPVarInt(playerid, "Nite Stick", 0);
SetPVarInt(playerid, "Knife", 0);
SetPVarInt(playerid, "Baseball Bat", 0);
SetPVarInt(playerid, "Shovel", 0);
SetPVarInt(playerid, "Pool Cue", 0);
SetPVarInt(playerid, "Katana", 0);
SetPVarInt(playerid, "Chainsaw", 0);
SetPVarInt(playerid, "Heat Seaker", 0);
SetPVarInt(playerid, "Dildo", 0);
SetPVarInt(playerid, "Vibrator", 0);
SetPVarInt(playerid, "Flowers", 0);
SetPVarInt(playerid, "Cane", 0);
SetPVarInt(playerid, "Teargas", 0);
SetPVarInt(playerid, "Bomb", 0);
SetPVarInt(playerid, "HS Rocket", 0);
SetPVarInt(playerid, "Flamethrower", 0);
SetPVarInt(playerid, "Satchel Explosives", 0);
SetPVarInt(playerid, "Spray Can", 0);
SetPVarInt(playerid, "Fire Extinguisher", 0);
SetPVarInt(playerid, "Camera", 0);
SetPVarInt(playerid, "Night Vis Goggles", 0);
SetPVarInt(playerid, "Thermal Goggles", 0);
SetPVarInt(playerid, "Grenade", 0);
SetPVarInt(playerid, "Molotov Cocktail", 0);
SetPVarInt(playerid, "Colt 45", 0);
SetPVarInt(playerid, "Silenced Pistol", 0);
SetPVarInt(playerid, "Desert Eagle", 0);
SetPVarInt(playerid, "Shotgun", 0);
SetPVarInt(playerid, "Sawn-off Shotgun", 0);
SetPVarInt(playerid, "Combat Shotgun", 0);
SetPVarInt(playerid, "UZI", 0);
SetPVarInt(playerid, "MP5", 0);
SetPVarInt(playerid, "AK47", 0);
SetPVarInt(playerid, "M4", 0);
SetPVarInt(playerid, "Tec9", 0);
SetPVarInt(playerid, "Rifle", 0);
SetPVarInt(playerid, "Sniper Rifle", 0);
SetPVarInt(playerid, "Rocket Launcher", 0);
SetPVarInt(playerid, "Minigun", 0);
ResetPlayerWeapons(playerid);
}
stock GivePlayerServerWeapon(playerid, weapid, ammo)
{
new gunname[32];
GivePlayerWeapon(playerid, weapid, ammo);
GetWeaponName(weapid, gunname, sizeof(gunname));
SetPVarInt(playerid, gunname, GetPVarInt(playerid, gunname) +ammo);
}
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & KEY_FIRE)
{
if(IsPlayerConnected(playerid))
{
new weaponid = GetPlayerWeapon(playerid);
new weapname[32];
GetWeaponName(weaponid, weapname, sizeof(weapname));
if(GetPVarInt(playerid, weapname) < 1) return SendClientMessage(playerid, -1, "Hack");
SetPVarInt(playerid, weapname, GetPVarInt(playerid, weapname) -1);
}
}
return 1;
}


