SA-MP Forums Archive
Problem with script. - 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: Problem with script. (/showthread.php?tid=563847)



Problem with script. - NoDi522 - 17.02.2015

Hello. I was making my admin script and i get some error when compile it:

PHP код:
public OnPlayerCommandText(playeridcmdtext[])
//===========================( Admin komande )===========================
COMMAND:setlevel(playerid,params[])
{
   new 
id,level,msg[128],msg2[128],name[MAX_PLAYER_NAME];
   if(
IsPlayerAdmin(playerid))
   {
       if(
sscanf(params,"ud",id,level)) return SendClientMessage(playerid0xFFFFFF,"Koristenje: /setlevel (Ime/ID) (Level)");
       else if(
level 5) return SendClientMessage(playerid0xFFFFFF,"Error: Maximalni level admin je 5.");
       else
       {
           
PlayerInfo[id][pAdministrator] = level;
           
format(msg,sizeof(msg),"Cestitamo! Sada ste admin na levelu %d",level);
           
SendClientMessage(id,0xFFFFFF,msg);
           
GetPlayerName(id,name,sizeof(name));
           
format(msg2,sizeof(msg2),"Postavili ste admina %s na levelu %d"name,level);
           
SendClientMessage(playerid,0xFFFFFF,msg2);
       }
       
    }
    else
    {
            
SendClientMessage(playerid,0xFFFFFF,"Error: Nemate dozvolu za tu komandu!");
    }
    return 
1;
     

I really don't know what is the problem. First it was in brackets (10 errors),and i fixed it and I am still thinking that it is problem in brackets ? :P

PHP код:
C:\Users\Dino Covic\Desktop\SAMP Server\gamemodes\Server_Skripta.pwn(216) : error 029invalid expressionassumed zero
C
:\Users\Dino Covic\Desktop\SAMP Server\gamemodes\Server_Skripta.pwn(238) : warning 217loose indentation
Pawn compiler 3.2.3664              Copyright 
(c1997-2006ITB CompuPhase
1 Error

PHP код:
COMMAND:setlevel(playerid,params[]) 
<-- 216 line


Re: Problem with script. - CalvinC - 17.02.2015

Dont use zcmd inside OnPlayerCommandText, use it for itself, as it works like a public function.
Only use OnPlayerCommandText for strcmp commands.


Re: Problem with script. - HazardouS - 17.02.2015

Read the documentation on ZCMD here: https://sampforum.blast.hk/showthread.php?tid=91354
Try to understand how callbacks work and how to create your command. Also, you will have to rename your OnPlayerCommandText callback according to what the documentation says.


Re: Problem with script. - NoDi522 - 18.02.2015

Thank you guys so much


Re: Problem with script. - Scrillex - 18.02.2015

What in the hell is this ?
public OnPlayerCommandText(playerid, cmdtext[]) // yOU CAN TAKE OUT IT.. with all { and } it aint needed if you are using zcmd command procesor.. + don't put it under it.

This aint needed if you are using ZCMD.. + no brackets..


Re: Problem with script. - PaulDinam - 18.02.2015

He's already gotten an answer for that.


Re: Problem with script. - NoDi522 - 18.02.2015

Hey guyz but i have a new problem. Everything in the script works now and when i launch samp and try to type the command,nothing shows if u know what i mean...

PHP код:
CMD:PostaviAdmina(playerid,params[])
{
    new 
id,level,msg[128],msg2[128],name[MAX_PLAYER_NAME];
    if(
IsPlayerAdmin(playerid))
    if(
sscanf(params,"ud",id,level)) return SendClientMessage(playerid0xFFFFFF,"Koristenje: /setlevel (Ime/ID) (Level)");
            else if(
level 5) return SendClientMessage(playerid0xFFFFFF,"Error: Maximalni level admin je 5.");
            else
            
PlayerInfo[id][pAdministrator] = level;
            
format(msg,sizeof(msg),"Cestitamo! Sada ste admin na levelu %d",level);
            
SendClientMessage(id,0xFFFFFF,msg);
            
GetPlayerName(id,name,sizeof(name));
            
format(msg2,sizeof(msg2),"Postavili ste admina %s na levelu %d"name,level);
            
SendClientMessage(playerid,0xFFFFFF,msg2);
            else
            
SendClientMessage(playerid,0xFFFFFF,"Error: Nemate dozvolu za tu komandu!");
            return 
1;

I made this when you told me that i don't need to use brackets in it.

PHP код:
C:\Users\Dino Covic\Desktop\SAMP Server\gamemodes\Server_Skripta.pwn(415) : warning 217loose indentation
C
:\Users\Dino Covic\Desktop\SAMP Server\gamemodes\Server_Skripta.pwn(420) : error 029invalid expressionassumed zero
Pawn compiler 3.2.3664              Copyright 
(c1997-2006ITB CompuPhase
1 Error

And i get this error!


Re: Problem with script. - NoDi522 - 18.02.2015

If someone help i would +rep


Re: Problem with script. - PaulDinam - 18.02.2015

You shouldn't remove the brackets, leave them as it is.
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You're not an admin");


Re: Problem with script. - NoDi522 - 18.02.2015

Yea but when I type command nothing doesn't show?