SA-MP Forums Archive
Server Closed connection - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Server Closed connection (/showthread.php?tid=573062)



Server Closed connection - IndependentGaming - 04.05.2015

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


Re: Server Closed connection - IndependentGaming - 04.05.2015

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;




Re: Server Closed connection - giorgosdim12 - 04.05.2015

You use any anti-weapon hack?


Re: Server Closed connection - Karan007 - 04.05.2015

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;




Re: Server Closed connection - IndependentGaming - 04.05.2015

problem solved.


Re: Server Closed connection - Konstantinos - 04.05.2015

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.


Re: Server Closed connection - IndependentGaming - 04.05.2015

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"); 



Re: Server Closed connection - Threshold - 04.05.2015

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;
}



Re: Server Closed connection - IndependentGaming - 04.05.2015

Nevermind, i fixed the problem

http://gyazo.com/4d64b9b5bfee809065928e47d6ec69f1