Server Closed connection
#1

Hello, i fixed finally my /givegun command there is now another problem

if i give my self a Minigun, weapon id 39 or rocket then i get server Closed connection but im not banned.

how can i fix this i tried this in the command

PHP код:
if(weaponid == 38) return SendClientMessageEx(playeridCOLOR_RED"You cannot give anyone a minigun!"); 
But it stil give me the minigun and then i got Server closed connection
Reply
#2

here is the command :

PHP код:
CMD:givegun(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] < 5) return SendClientMessageEx(playeridCOLOR_RED" You are not authorized to use that command !");
    new 
giveplayeridweaponid;
    if(
weaponid == 38) return SendClientMessageEx(playeridCOLOR_RED"You cannot give anyone a minigun!");
    if(
sscanf(params"ud"giveplayeridweaponid))
    {
        
SendClientMessage(playeridCOLOR_WHITE"Syntax:givegun [player] [weaponid]");
    }
    
GivePlayerGun(giveplayeridweaponid50);

    return 
1;

Reply
#3

You use any anti-weapon hack?
Reply
#4

Try this.
PHP код:
CMD:givegun(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] < 5) return SendClientMessageEx(playeridCOLOR_RED" You are not authorized to use that command !");
    new 
giveplayeridweaponid;
    if(
weaponid == 38) return SendClientMessageEx(playeridCOLOR_RED"You cannot give anyone a minigun!");
    if(
sscanf(params"ud"giveplayeridweaponid))
    {
        
SendClientMessage(playeridCOLOR_WHITE"Syntax:givegun [player] [weaponid]");
    }
    return 
1;

Reply
#5

problem solved.
Reply
#6

Quote:
Originally Posted by karan007
Посмотреть сообщение
Try this.
PHP код:
CMD:givegun(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] < 5) return SendClientMessageEx(playeridCOLOR_RED" You are not authorized to use that command !");
    new 
giveplayeridweaponid;
    if(
weaponid == 38) return SendClientMessageEx(playeridCOLOR_RED"You cannot give anyone a minigun!");
    if(
sscanf(params"ud"giveplayeridweaponid))
    {
        
SendClientMessage(playeridCOLOR_WHITE"Syntax:givegun [player] [weaponid]");
    }
    return 
1;

You do the same mistake too.

"weaponid" is 0 because it has not been updated with sscanf (it should be before the check):
PHP код:
CMD:givegun(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] < 5) return SendClientMessageEx(playeridCOLOR_RED" You are not authorized to use that command !");
    new 
giveplayeridweaponid;
    if(
sscanf(params"ud"giveplayeridweaponid)) return SendClientMessage(playeridCOLOR_WHITE"Syntax:givegun [player] [weaponid]");
    if(
giveplayerid == INVALID_PLAYER_ID) return SendClientMessageEx(playeridCOLOR_RED"Offline player");
    if(!(
<= weaponid <= 46))  return SendClientMessageEx(playeridCOLOR_RED"Invalid weaponid");
    if(
weaponid == 38) return SendClientMessageEx(playeridCOLOR_RED"You cannot give anyone a minigun!");
    
GivePlayerGun(giveplayeridweaponid50);
    return 
1;

EDIT: Oh, you got it fixed.
Reply
#7

Konstantinos if i do your command i get this errors

PHP код:
(2265) : error 001expected token")"but found "-identifier-"
(2265) : error 029invalid expressionassumed zero
(2265) : warning 215expression has no effect
(2265) : error 001expected token";"but found "return"
(2265) : fatal error 107too many error messages on one line

Compilation aborted
.Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase


4 Errors

This line:

PHP код:
if(!(<= 0 weaponid <= 46))  return SendClientMessageEx(playeridCOLOR_RED"Invalid weaponid"); 
Reply
#8

His was actually correct. Apart from not checking weapon IDs 19-21 (Invalid weapon IDs), his code was perfect.

He never had '0 <= 0 weaponid', that was your mistake.

pawn Код:
CMD:givegun(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 5) return SendClientMessageEx(playerid, COLOR_RED, " You are not authorized to use that command !");
    new giveplayerid, weaponid;
    if(sscanf(params, "ud", giveplayerid, weaponid)) return SendClientMessage(playerid, COLOR_WHITE, "Syntax:givegun [player] [weaponid]");
    if(giveplayerid == INVALID_PLAYER_ID) return SendClientMessageEx(playerid, COLOR_RED, "Offline player");
    if(!(0 <= weaponid <= 18 || 22 <= weaponid <= 46))  return SendClientMessageEx(playerid, COLOR_RED, "Invalid weaponid");
    if(weaponid == 38) return SendClientMessageEx(playerid, COLOR_RED, "You cannot give anyone a minigun!");
    GivePlayerGun(giveplayerid, weaponid, 50);
    return 1;
}
Reply
#9

Nevermind, i fixed the problem

http://gyazo.com/4d64b9b5bfee809065928e47d6ec69f1
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)