SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 14/02/2018, 05:05 PM   #1
ivndosos
Huge Clucker
 
ivndosos's Avatar
 
Join Date: Sep 2014
Location: Russian Federation, Kaliningrad.
Posts: 403
Reputation: 18
Default Duel bugged.

So my issue is, Is that when I go to the duel I don't get no weapons!

Code:
CMD:duel(playerid, params[])
{
   new user, weap[45], weaponid = -1, str[128], str2[128];
   if(sscanf(params, "us[45]", user, weap)) return SendClientMessage(playerid, -1, "{c3c3c3}(INFO) /duel [id/name], [weapon name]");
   if(user == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "{c3c3c3}(INFO) That player is not connected!");
   if(user == playerid) return SendClientMessage(playerid, -1, "{c3c3c3}(INFO) You can't duel yourself!");
   if(duelinfo[playerid][induel] == 1) return SendClientMessage(playerid, -1, "{c3c3c3}(INFO) You're already dueling!");
   if(duelinfo[user][induel] == 1) return SendClientMessage(playerid, -1, "{c3c3c3}(INFO) That player is already dueling!");
   if(invite[user] == 1) return SendClientMessage(playerid, -1, "{c3c3c3}(INFO) That player already got a duel invitation!");
   if(inviter[playerid] == 1) return SendClientMessage(playerid, -1, "{c3c3c3}(INFO) You already invited someone, wait till it's rejected or accepted");
   if(IsPlayerInLobby[user] == 1) return SendClientMessage(playerid, -1, "{c3c3c3}(INFO) That player is in lobby therefore he can't duel!");
   if(InArena1[user] == 1) return SendClientMessage(playerid, -1, "{c3c3c3}(INFO) That player is in arena, he must quit in order to duel you!");
   if(InArena2[user] == 1) return SendClientMessage(playerid, -1, "{c3c3c3}(INFO) That player is in arena, he must quit in order to duel you!");
   if(StringNumeric(weap))
   {
	  weaponid = strval(weap);
   }
   else
   {
	  weaponid = strval(weap);
   }
   DuelSender[user] = playerid;
   duelinfo[playerid][weapid] = weaponid;
   duelinfo[playerid][weapname] = weap;
   duelinfo[user][weapid] = weaponid;
   duelinfo[user][weapname] = weap;
   invite[user] = 1;
   inviter[playerid] = 1;
   DuelReceiver[playerid] = user;
   format(str, sizeof(str), "{339933}(DUEL) You have sent a duel invitation to %s(ID:%d) (Weapon: %s)", duelinfo[user][playername], user, weap);
   SendClientMessage(playerid, -1, str);
   format(str2, sizeof(str2), "{339933}(DUEL) You have received a duel invitation from %s(ID:%d) (Weapon: %s)", duelinfo[playerid][playername], playerid, weap);
   SendClientMessage(user, -1, str2);
   return 1;
}
CMD:accept(playerid, params[])
{
   if(invite[playerid] == 1)
   {
	 new user = DuelSender[playerid];
	 SetTimerEx("ResetWeapons", 1000, false,  "i", playerid);
	 RemovePlayerFromVehicle(user);
	 SetPlayerArmour(user, 100);
	 SetPlayerHealth(user, 100);
	 SetPlayerVirtualWorld(user, 100);
	 SetPlayerPos(user, -1432.3037,997.8691,1024.2102);
	 SetPlayerInterior(user, 15);
	 GivePlayerWeapon(user, duelinfo[playerid][weapid], 500);
	 duelinfo[user][induel] = 1;
	 inviter[user] = 0;
	 SetTimerEx("DuelWeapons1", 2000, false,  "i", user);
	 
	 ResetPlayerWeapons(playerid);
	 RemovePlayerFromVehicle(playerid);
	 SetPlayerArmour(playerid, 100);
	 SetPlayerHealth(playerid, 100);
	 SetPlayerVirtualWorld(playerid, 100);
	 SetPlayerPos(playerid, -1357.0106,998.1605,1024.0735);
	 SetPlayerInterior(playerid, 15);
	 duelinfo[playerid][induel] = 1;
	 SetTimerEx("DuelWeapons", 2000, false,  "i", playerid);
	 SetTimerEx("ResetWeapons1", 1000, false,  "i", playerid);
	 invite[playerid] = 0;
   }
   else return SendClientMessage(playerid, -1, "{c3c3c3}(INFO) You didn't receive any duel requests!");
   return 1;
}
forward ResetWeapons1(playerid);
public ResetWeapons1(playerid)
{
  ResetPlayerWeapons(playerid);
  return 1;
}

forward DuelWeapons(playerid);
public DuelWeapons(playerid)
{
  GivePlayerWeapon(playerid, duelinfo[playerid][weapid], 500);
  return 1;
}
forward DuelWeapons1(user);
public DuelWeapons1(user)
{
  GivePlayerWeapon(user, duelinfo[user][weapid], 500);
  return 1;
}
ivndosos is offline   Reply With Quote
Old 14/02/2018, 07:49 PM   #2
jasperschellekens
High-roller
 
jasperschellekens's Avatar
 
Join Date: Dec 2016
Location: Holland
Posts: 1,065
Reputation: 106
Default Re: Duel bugged.

Add debug messages to get an indication of the problem. It could for example have something to do with duelinfo[playerid][weapid].

PHP Code:
duelinfo[playerid][weapid] = weaponid
weaponid gets his info from strval(weap)
Try changing weaponid to an actual weapon id. You will have to simply test a few things to check where the problem comes from.
Debug messages will help you with this.
__________________
If you want to have your own custom script, or even want to have one of our already released scripts, join our SCRIPTING SERVICES DISCORD, or send me a private message!


Undead Wasteland Roleplay - The year is 1996. San Andreas is a wasteland ruled by the undead. the once so glorius landscape of San Andreas, is now a shattered decayed place that is only a vague memory of the world as we used to know it.
Discord - Website
jasperschellekens is offline   Reply With Quote
Old 14/02/2018, 11:16 PM   #3
AdamsLT
Big Clucker
 
AdamsLT's Avatar
 
Join Date: Oct 2011
Location: Lithuania
Posts: 124
Reputation: 33
Default Re: Duel bugged.

Do what Jasper said. I believe the problem might be there as well.


But I skimmed through your code. Just a heads up - your /accept command has a few flaws that you should correct.

In the user block:
You reset the weapons of the playerid instead of the user.
You give weapons to user twice (one with a timer, one with the GivePlayerWeapon function).

In the playerid block:
You reset the players weapons twice. Once with a timer and once with just the ResetPlayerWeapons function.



I'd strongly advise you to do it all in a separate function and just pass a different playerid to it since you are bound to miss something while typing the exact same code twice.
AdamsLT is offline   Reply With Quote
Old 15/02/2018, 04:35 AM   #4
ivndosos
Huge Clucker
 
ivndosos's Avatar
 
Join Date: Sep 2014
Location: Russian Federation, Kaliningrad.
Posts: 403
Reputation: 18
Default Re: Duel bugged.

Okay, btw.

I use this guy's filterscript. I re-wrote his whole FS so I can learn along the way because there are no tutorials on how to make a duel system.

http://forum.sa-mp.com/showthread.php?t=531402
ivndosos is offline   Reply With Quote
Old 15/02/2018, 05:26 AM   #5
ivndosos
Huge Clucker
 
ivndosos's Avatar
 
Join Date: Sep 2014
Location: Russian Federation, Kaliningrad.
Posts: 403
Reputation: 18
Default Re: Duel bugged.

Code:
new WeaponInfo[][sWeaponInfo] =
{
    {"Fist",1,0},
    {"Brass Knuckles",1,0},
    {"Golf Club",1,1},
    {"Nightstick",1,1},
    {"Knife",1,1},
    {"Baseball Bat",1,1},
    {"Shovel",1,1},
    {"Pool cue",1,1},
    {"Katana",1,1},
    {"Chainsaw",1,1},
    {"Double-ended Dildo",1,10},
    {"Dildo",1,10},
    {"Vibrator",1,10},
    {"Silver Vibrator",1,10},
    {"Flowers",1,10},
    {"Cane",1,10},
    {"Grenade",1,8},
    {"Tear Gas",1,8},
    {"Molotov Cocktail",1,8},
    {"9mm Pistol",1,2},
    {"Silenced 9mm",1,2},
    {"Deagle",1,2},
    {"Shotgun",1,3},
    {"Sawnoff Shotgun",1,3},
    {"Combat Shotgun",1,3},
    {"Micro SMG",1,4},
    {"MP5",1,4},
    {"AK-47",1,5},
    {"M4",1,5},
    {"Tec-9",1,4},
    {"Country Rifle",1,6},
    {"Sniper Rifle",1,6},
    {"RPG",1,7},
    {"HS Rocket",1,7},
    {"Flamethrower",1,7},
    {"Minigun",1,7},
    {"Sachel Charge",1,8},
    {"Detonator",1,12},
    {"Spray Can",1,9},
    {"Fire Extinguisher",1,9},
    {"Camera",1,9},
    {"Night Vision Goggles",0,11},
    {"Thermal Goggles",0,11},
    {"Parachute",1,11}
};
Code:
CMD:accept(playerid, params[])
{
    if(invite[playerid] == 1)
    {
        new user = DuelSender[playerid];
        ResetPlayerWeapons(user);
        RemovePlayerFromVehicle(user);
        SetPlayerArmour(user, 0);
        SetPlayerHealth(user, 100);
        SetPlayerVirtualWorld(user, 100);
        SetPlayerPos(user, 1399.3311, 2789.9409, 10.8203);
        GivePlayerWeapon(user, duelinfo[playerid][weapid], 500);
        duelinfo[user][induel] = 1;
        inviter[user] = 0;

        ResetPlayerWeapons(playerid);
        RemovePlayerFromVehicle(playerid);
        SetPlayerArmour(playerid, 0);
        SetPlayerHealth(playerid, 100);
        SetPlayerVirtualWorld(playerid, 100);
        GivePlayerWeapon(playerid, duelinfo[user][weapid], 500);
        SetPlayerPos(playerid, 1358.0012, 2789.6218, 10.8203);
        duelinfo[playerid][induel] = 1;
        invite[playerid] = 0;
    }
    else return SendClientMessage(playerid, -1, "{c3c3c3}(INFO) You didn't recieve any duel request");
    return 1;
}
ivndosos is offline   Reply With Quote
Old 15/02/2018, 06:08 AM   #6
Sew_Sumi
Banned
 
Join Date: Jun 2008
Location: Azerbaijan
Posts: 6,244
Reputation: 525
Default Re: Duel bugged.

Are you using an anti-cheat? Or anything else that would modify the way it handles weapons?

Also a good idea could be to put messages in the accept so you know it succeeded, not just by the giving of weapons.
Sew_Sumi is offline   Reply With Quote
Old 15/02/2018, 06:28 AM   #7
ivndosos
Huge Clucker
 
ivndosos's Avatar
 
Join Date: Sep 2014
Location: Russian Federation, Kaliningrad.
Posts: 403
Reputation: 18
Default Re: Duel bugged.

No I don't use any anti-cheat, However when I choose to add a weapon I can type "dadsa", and I will receive a messsage "You got a duel from ... with weapon dadsa"

I think something is wrong in the duel command itself and the new WeaponInfo.
ivndosos is offline   Reply With Quote
Old 15/02/2018, 06:41 AM   #8
Sew_Sumi
Banned
 
Join Date: Jun 2008
Location: Azerbaijan
Posts: 6,244
Reputation: 525
Default Re: Duel bugged.

Quote:
Originally Posted by ivndosos View Post
No I don't use any anti-cheat, However when I choose to add a weapon I can type "dadsa", and I will receive a messsage "You got a duel from ... with weapon dadsa"

I think something is wrong in the duel command itself and the new WeaponInfo.
Indeed, return the variables using printf, or SendClientMessage more often (All stages of the commands for debug as such). The accept command also looks confusing for the amount of work it does.
Sew_Sumi is offline   Reply With Quote
Old 15/02/2018, 06:45 AM   #9
ivndosos
Huge Clucker
 
ivndosos's Avatar
 
Join Date: Sep 2014
Location: Russian Federation, Kaliningrad.
Posts: 403
Reputation: 18
Default Re: Duel bugged.

How do I printf it exactly? I never really used it so I don't know.
ivndosos is offline   Reply With Quote
Old 15/02/2018, 06:53 AM   #10
Kane
Gangsta
 
Kane's Avatar
 
Join Date: Sep 2012
Posts: 822
Reputation: 130
Default Re: Duel bugged.

PHP Code:
   if(StringNumeric(weap))
   {
      
weaponid strval(weap);
   }
   else
   {
      
weaponid strval(weap);
   } 
?
__________________
Los Santos Roleplay - Developer
@ls-rp.com

Former Beta Tester

Kane is online now   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] Duel System DKN | /duel [playerid] ipsBruno Filterscripts 10 22/05/2018 01:55 AM
Duel System bugged NealPeteros Scripting Help 5 04/01/2018 06:22 PM
DeathMatch duel to box duel in GYM blanic Scripting Help 0 08/12/2015 10:30 AM
[Map] Duel map (With duel watch place) Glossy42O Maps 20 21/12/2014 06:52 PM
Need help with duel system [/duel] admantis Scripting Help 5 12/11/2011 08:10 AM


All times are GMT. The time now is 11:21 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.