PDA

View Full Version : If pickup id spams


jasperschellekens
24/03/2017, 12:22 AM
Hello,

Im a little stuck on an on duty pickup.
The problem is that the pickup spams every 2 seconds.
If your organization is id 4 it will spam going on and off duty.
If you are not, It spams the message that you are not allowed to do it.

Is there any way i can fix this?

Code:

if(pickupid==ArmyDuty)
{
if(PlayerOrg[playerid]==4)
{
if(PlayerInfo[playerid][USMCDuty] == 0)
{
Suited[playerid]=1;
PlayerInfo[playerid][USMCDuty] = 1;
PlayerInfo[playerid][LawDuty] = 1;
GivePlayerWeaponEx(playerid, 27, 300);
GivePlayerWeaponEx(playerid, 31, 300);
GivePlayerWeaponEx(playerid, 24, 300);
GivePlayerWeaponEx(playerid, 41, 500);
SetPlayerArmourEx(playerid, 100);
SetPlayerColor(playerid, 0x0000FFAA);
SetPlayerSkin(playerid, 287);
SendClientMessage(playerid, GREEN, "You are now on USMC duty, /usmchelp for help");
}
else
{
Suited[playerid]=0;
PlayerInfo[playerid][USMCDuty] = 0;
PlayerInfo[playerid][LawDuty] = 0;
PlayerInfo[playerid][FreeSkin] = 1;
SetPlayerArmourEx(playerid, 0);
ResetPlayerWeapons(playerid);
SetPlayerSkin(playerid, 3);
SetPlayerColor(playerid, COLOR_WHITE);
SendClientMessage(playerid, GREEN, "You are not on USMC duty anymore. You can change ur skin for free once by using /freeskin");
}
}else return SendClientMessage(playerid, RED, "You are not allowed to do this.");
}

Toroi
24/03/2017, 01:02 AM
Which pickup type are you using?

http://wiki.sa-mp.com/wiki/PickupTypes

jasperschellekens
24/03/2017, 02:22 AM
I am using pickup type 2. The pickup does not destroy. I do use type 2 for ammunation too, and that does work just fine:

ArmyDuty=CreateDynamicPickup(1247,2,268.4107,1871. 3419,8.6094,-1);

BuySomeGuns=CreateDynamicPickup(1274,2,297.0358,-38.5132,1001.5156,-1);

Sew_Sumi
24/03/2017, 05:26 AM
Are you using OnPlayerPickUpPickup, or OnPlayerPickUpDynamicPickup?

jasperschellekens
24/03/2017, 06:07 AM
OnPlayerPickUpDynamicPickup

ATGOggy
24/03/2017, 06:15 AM
Make them press a key like F to get the job while standing on the pickup.

jasperschellekens
24/03/2017, 05:36 PM
I have started based on the way you said.
Only i have a problem.
I can press H anywhere, but when i am on the Pickup, it returns the 0.
What am i doing wrong?


if(newkeys==KEY_CTRL_BACK)
{
if(GetPlayerScore(playerid)<3)return GameTextForPlayer(playerid,"You need at least 3 score",800,1);
if(!IsPlayerInRangeOfPoint(playerid,5,297.0358,-38.5132,1001.5156))
{
ShowPlayerDialog(playerid, 12345, DIALOG_STYLE_LIST, "Ammunation Weapon Shop", "Melee Weapons\nSub MachineGuns\nLethal Guns\nShotGuns\nHand Guns\nMisc", "Choose", "Cancel");
}else return 0;
if(GetPlayerScore(playerid)<3)return GameTextForPlayer(playerid,"You need at least 3 score",800,1);
if(!IsPlayerInRangeOfPoint(playerid,5,291.8283,-85.2263,1001.5156))
{
ShowPlayerDialog(playerid, 12345, DIALOG_STYLE_LIST, "Ammunation Weapon Shop", "Melee Weapons\nSub MachineGuns\nLethal Guns\nShotGuns\nHand Guns\nMisc", "Choose", "Cancel");
}else return 0;
if(GetPlayerScore(playerid)<3)return GameTextForPlayer(playerid,"You need at least 3 score",800,1);
if(!IsPlayerInRangeOfPoint(playerid,5,290.2377,-109.7684,1001.5156))
{
ShowPlayerDialog(playerid, 12345, DIALOG_STYLE_LIST, "Ammunation Weapon Shop", "Melee Weapons\nSub MachineGuns\nLethal Guns\nShotGuns\nHand Guns\nMisc", "Choose", "Cancel");
}else return 0;
if(GetPlayerScore(playerid)<3)return GameTextForPlayer(playerid,"You need at least 3 score",800,1);
if(!IsPlayerInRangeOfPoint(playerid,5,312.6401,-166.1406,999.6010))
{
ShowPlayerDialog(playerid, 12345, DIALOG_STYLE_LIST, "Ammunation Weapon Shop", "Melee Weapons\nSub MachineGuns\nLethal Guns\nShotGuns\nHand Guns\nMisc", "Choose", "Cancel");
}else return 0;
if(GetPlayerScore(playerid)<3)return GameTextForPlayer(playerid,"You need at least 3 score",800,1);
if(!IsPlayerInRangeOfPoint(playerid,5,314.2591,-133.5507,999.6016))
{
ShowPlayerDialog(playerid, 12345, DIALOG_STYLE_LIST, "Ammunation Weapon Shop", "Melee Weapons\nSub MachineGuns\nLethal Guns\nShotGuns\nHand Guns\nMisc", "Choose", "Cancel");
}else return 0;
}

Toroi
24/03/2017, 08:45 PM
if(!IsPlayerInRangeOfPoint(playerid,5,297.0358,-38.5132,1001.5156))

You're asking if the IsPlayerInRangeOfPoint function is false. You should remove the ! from these conditions for your function to work as you intend.