Command Problem
#1

Hello everyone Can to help mee with a command ?

PHP Code:
CMD:ban(playerid,parmas[])
{
    if(
pInfo[playerid][pLogged] == 1)
    {
        if(
pInfo[playerid][pAdminLevel] >= 1)
         {
            new 
tid,du,res[150],ppp[50];
            if(
sscanf(parmas,"uis[150]",tid,du,res) || isnull(parmas))return SendClientMessage(playerid,-1,"{ff0000}Wrong Usage || Correct Usage : /ban id duration(In Days) Reason");
            if(!
IsPlayerConnected(tid))return SendClientMessage(playerid,-1,"{ff6666}The Player you requested is not connected.");
            new 
banmt[300],banma[300],adminname[MAX_PLAYER_NAME],targetn[MAX_PLAYER_NAME];
            
GetPlayerName(playerid,adminname,sizeof(adminname));
            new 
exp=gettime()+(60*60*24*du);
            
GetPlayerIp(tid,ppp,sizeof(ppp));
            new 
INI:File INI_Open(UserBanPath(tid));
            
INI_SetTag(File,"data");
            
INI_WriteInt(File,"Banexp",exp);
            
INI_WriteInt(File,"BanPerm",0);
            
INI_WriteString(File,"BanAdmin",adminname);
            
INI_WriteString(File,"Reason",res);
            
INI_WriteString(File,"IP",ppp);
            
INI_Close(File);
            
GetPlayerName(tid,targetn,sizeof(targetn));
            new 
INI:iFile INI_Open(UserIPPath(tid));
            
INI_SetTag(iFile,"data");
            
INI_WriteInt(iFile,"Banexp",exp);
            
INI_WriteInt(iFile,"BanPerm",0);
            
INI_WriteString(iFile,"BanPlayer",targetn);
            
INI_WriteString(iFile,"BanAdmin",adminname);
            
INI_WriteString(iFile,"Reason",res);
            
INI_Close(iFile);
            new 
File:logg=fopen("BannedPlayers.txt",io_append);
            
fwrite(loggtargetn);
             
fwrite(logg,"\n");
             
fclose(logg);
              
format(banmt,sizeof(banmt),"{ff0000}Admin %s has banned you for %i days due to %s",adminname,du,res);
               
format(banma,sizeof(banma),"{ff0000}Admin %s has banned %s for %i days due to %s",adminname,targetn,du,res);
            
SendClientMessage(tid,-1,banmt);
            
SendClientMessageToAll(-1,banma);
            
SetTimerEx("KickPlayer",100,false,"i",tid);
          }
        else {
            
SendClientMessage(playerid,-1,""chat""COL_LIGHTBLUE" You do not have the right admin permissions for this command!");
        }
    }
    else if(
pInfo[playerid][pLogged] == 0)
    {
        
SendClientMessage(playerid,-1,""chat""COL_LIGHTBLUE" Nice try u fucking fag gay!");
        
printf("%s has been kicked for trying to use a command without being logged in!"PlayerName(playerid));
        
Kick(playerid);
    }
    return 
1;

This is the command when i Use /ban 0 1 Test

He send mee the message of command not exist

Help mee please
Reply
#2

Sorry for bump but help mee please
I need your help
PLEASEEE
Reply
#3

Hello, plase replace your code with this code:
Code:
Command:ban(playerid,parmas[]) 
{ 
    if(pInfo[playerid][pLogged] == 1) 
    { 
        if(pInfo[playerid][pAdminLevel] >= 1) 
         { 
            new tid,du,res[150],ppp[50]; 
            if(sscanf(parmas,"uis[150]",tid,du,res) || isnull(parmas))return SendClientMessage(playerid,-1,"{ff0000}Wrong Usage || Correct Usage : /ban id duration(In Days) Reason"); 
            if(!IsPlayerConnected(tid))return SendClientMessage(playerid,-1,"{ff6666}The Player you requested is not connected."); 
            new banmt[300],banma[300],adminname[MAX_PLAYER_NAME],targetn[MAX_PLAYER_NAME]; 
            GetPlayerName(playerid,adminname,sizeof(adminname)); 
            new exp=gettime()+(60*60*24*du); 
            GetPlayerIp(tid,ppp,sizeof(ppp)); 
            new INI:File = INI_Open(UserBanPath(tid)); 
            INI_SetTag(File,"data"); 
            INI_WriteInt(File,"Banexp",exp); 
            INI_WriteInt(File,"BanPerm",0); 
            INI_WriteString(File,"BanAdmin",adminname); 
            INI_WriteString(File,"Reason",res); 
            INI_WriteString(File,"IP",ppp); 
            INI_Close(File); 
            GetPlayerName(tid,targetn,sizeof(targetn)); 
            new INI:iFile = INI_Open(UserIPPath(tid)); 
            INI_SetTag(iFile,"data"); 
            INI_WriteInt(iFile,"Banexp",exp); 
            INI_WriteInt(iFile,"BanPerm",0); 
            INI_WriteString(iFile,"BanPlayer",targetn); 
            INI_WriteString(iFile,"BanAdmin",adminname); 
            INI_WriteString(iFile,"Reason",res); 
            INI_Close(iFile); 
            new File:logg=fopen("BannedPlayers.txt",io_append); 
            fwrite(logg, targetn); 
             fwrite(logg,"\n"); 
             fclose(logg); 
              format(banmt,sizeof(banmt),"{ff0000}Admin %s has banned you for %i days due to %s",adminname,du,res); 
               format(banma,sizeof(banma),"{ff0000}Admin %s has banned %s for %i days due to %s",adminname,targetn,du,res); 
            SendClientMessage(tid,-1,banmt); 
            SendClientMessageToAll(-1,banma); 
            SetTimerEx("KickPlayer",100,false,"i",tid); 
          } 
        else { 
            SendClientMessage(playerid,-1,""chat""COL_LIGHTBLUE" You do not have the right admin permissions for this command!"); 
        } 
    } 
    else if(pInfo[playerid][pLogged] == 0) 
    { 
        SendClientMessage(playerid,-1,""chat""COL_LIGHTBLUE" Nice try u fucking fag gay!"); 
        printf("%s has been kicked for trying to use a command without being logged in!", PlayerName(playerid)); 
        Kick(playerid); 
    } 
    return 1; 
}
Reply
#4

Kidding?
I need your help how to fix my problem now with what to replace

I found the bug where is
new exp=gettime()+(60*60*24*du);
its here when remove it command dont show dhat message
When add it command show error message
Reply
#5

Hey there,
I ran few tests about the problem and came to conclusion that a function used in y_ini named valstr is causing crash.
To fix this download fixes.inc from https://sampforum.blast.hk/showthread.php?tid=292813
and then include in script
Make sure that fixes.inc is inluded first then y_ini
line this
Code:
#include <fixes.inc>//first this
#include <YSI\y_ini>//then this
Reply
#6

IF i use this i got Spawned Like a ball in Air
Idk why
Reply
#7

In that case don't include fixes.inc, paste this code above #include <YSI\y_ini> line
pawn Code:
stock fvalstr(dest[], value, bool:pack = false)
    {
        //credits to slice
        // "format" can't handle cellmin properly.
        static const
            sc_szCellmin[] = !"-2147483648";
        if (value == cellmin)
        {
            pack && strpack(dest, sc_szCellmin, 12) || strunpack(dest, sc_szCellmin, 12);
        }
        else
        {
            format(dest, 12, "%d", value),
            pack && strpack(dest, dest, 12);
        }
        return 0;
    }

#if defined _ALS_valstr
  #undef valstr
#else
#define _ALS_valstr
#endif
#define valstr fvalstr
Like This -
pawn Code:
#include <a_samp>//first this
    stock fvalstr(dest[], value, bool:pack = false)
    {
        //credits to slice
        // "format" can't handle cellmin properly.
        static const
            sc_szCellmin[] = !"-2147483648";
        if (value == cellmin)
        {
            pack && strpack(dest, sc_szCellmin, 12) || strunpack(dest, sc_szCellmin, 12);
        }
        else
        {
            format(dest, 12, "%d", value),
            pack && strpack(dest, dest, 12);
        }
        return 0;
    }

#if defined _ALS_valstr
  #undef valstr
#else
#define _ALS_valstr
#endif
#define valstr fvalstr

#include <YSI\y_ini>//Then This
//other includes here
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)