Can someone correct my script please ?
#1

I don't understand the errors in my script I tried so hardly to correct them but I'm not very good in scripting so can someone give me a corrected version of my script please ?

Here's my script :

#include <a_samp>
#include <zcmd>

public OnPlayerCommandText(playerid, cmdtext[])
// if using ZCMD

CMD:commands(playerid, params[])
{
// using 1 for dialogid might cause conflict, change it to the next available id.
ShowPlayerDialog(playerid, /* dialogid */ 2, DIALOG_STYLE_LIST, "Commands Menu", "Player Commands\nAdmin Commands", "Select", "Cancel");
return 1;
}

// In OnDialogResponse
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 2 /* or the dialogid you selected */)
{
if(response) {
switch(listitem) {
case 0: {
SendClientMessage(playerid, -2, "*Commands* \joindevent\n joingevent\n joinsrevent\n joinmlevent\n joinshevent\n joinsgevent\n joindmevent\n joinpdevent\n joinuzievent\n joinkevent\n joincsevent", "Cancel");
}
case 1: {
if(IsPlayerAdmin(playerid)) {
SendClientMessage(playerid, -2, "*Admin Commands* \devent\n gevent\n srevent\n mlevent\n shevent\n sgevent\n dmevent\n pdeven\n uzievent\n kevent\n csevent\n startminievent\n eh", "Cancel");
}
}
}
}
}
return 0;
}


And here are the compiling errors :

C:\Users\Propriйtaire\Desktop\caca.pwn(7) : error 029: invalid expression, assumed zero
C:\Users\Propriйtaire\Desktop\caca.pwn(22) : error 027: invalid character constant
C:\Users\Propriйtaire\Desktop\caca.pwn(22) : error 027: invalid character constant
C:\Users\Propriйtaire\Desktop\caca.pwn(26) : error 027: invalid character constant
C:\Users\Propriйtaire\Desktop\caca.pwn(26) : error 027: invalid character constant
C:\Users\Propriйtaire\Desktop\caca.pwn(32) : warning 217: loose indentation
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


5 Errors.
Reply
#2

You cannot use \n in the SendClientMessage.
Reply
#3

pawn Код:
#include <a_samp>
#include <zcmd>

public OnPlayerCommandText(playerid, cmdtext[])
// if using ZCMD

CMD:commands(playerid, params[])
{
    // using 1 for dialogid might cause conflict, change it to the next available id.
    ShowPlayerDialog(playerid, /* dialogid */ 2, DIALOG_STYLE_LIST, "Commands Menu", "Player Commands\nAdmin Commands", "Select", "Cancel");
    return 1;
}

// In OnDialogResponse
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 2 /* or the dialogid you selected */)
    {
        if(response) {
            switch(listitem) {
                case 0: {
                    SendClientMessage(playerid, -2, "*Commands* \njoindevent\n joingevent\n joinsrevent\n joinmlevent\n joinshevent\n joinsgevent\n joindmevent\n joinpdevent\n joinuzievent\n joinkevent\n joincsevent", "Cancel");
                }
                case 1: {
                    if(IsPlayerAdmin(playerid)) {
                        SendClientMessage(playerid, -2, "*Admin Commands* \ndevent\n gevent\n srevent\n mlevent\n shevent\n sgevent\n dmevent\n pdeven\n uzievent\n kevent\n csevent\n startminievent\n eh", "Cancel");
                    }
                }
            }
        }
    }
    return 0;
}
You had this line:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
without brackets and caused the errors. About the invalid character constant, you had "\" character with invalid characters. Although, using /n in client messages makes no difference only on dialogs.
Reply
#4

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
Is not used in ZCMD, and YCMD.

It's only used in the old and outdated STRCMP.
Reply
#5

so you mean that i have to take this line «public OnPlayerCommandText(playerid, cmdtext[])» out of my script and to put this «/» instead of this «\» ?
Reply
#6

Yes, OnPlayerCommandText is not needed but the problem was caused because it wasn't with brackets {}.

About the escape codes:
https://sampwiki.blast.hk/wiki/Scripting...cape_character
https://sampwiki.blast.hk/wiki/Escape_codes

\n is valid (it exists).
\j is not valid (it doesn't exist).
Reply
#7

pawn Код:
#include <a_samp>
#include <zcmd>

CMD:commands(playerid, params[])
{
    ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "Commands Menu", "Player Commands\nAdmin Commands", "Select", "Cancel");
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 2)
    {
        if(response) {
            switch(listitem) {
                case 0: {
                    new string[512], message[] = "*Commands* \njoindevent\n joingevent\n joinsrevent\n joinmlevent\n joinshevent\n joinsgevent\n joindmevent\n joinpdevent\n joinuzievent\n joinkevent\n joincsevent";
                    format(string, sizeof(string),"%s",message);
                    ShowPlayerDialog(playerid,19343,DIALOG_STYLE_LIST,"Dialog Title",string, "Select","Cancel");
                }
                case 1: {
                    if(IsPlayerAdmin(playerid)) {
                    new string[512], message[] = "*Admin Commands* \ndevent\n gevent\n srevent\n mlevent\n shevent\n sgevent\n dmevent\n pdeven\n uzievent\n kevent\n csevent\n startminievent\n eh";
                    format(string, sizeof(string),"%s",message);
                    ShowPlayerDialog(playerid,19343,DIALOG_STYLE_LIST,"Dialog Title",string, "Select","Cancel");
                    }
                }
            }
        }
    }
    return 0;
}
Something like that, or use STRCAT
Reply
#8

thanks a lot man your help was really efficient now i have no errors but i have warnings but warnings are'nt bad I think. It looks like this now :

#include <a_samp>
#include <zcmd>

CMD:commands(playerid, params[])
{
// using 1 for dialogid might cause conflict, change it to the next available id.
ShowPlayerDialog(playerid, /* dialogid */ 2, DIALOG_STYLE_LIST, "Commands Menu", "Player Commands\nAdmin Commands", "Select", "Cancel");
return 1;
}

// In OnDialogResponse
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 2 /* or the dialogid you selected */)
{
if(response) {
switch(listitem) {
case 0: {
SendClientMessage(playerid, -2, "*Commands* /joindevent/n joingevent/n joinsrevent/n joinmlevent/n joinshevent/n joinsgevent/n joindmevent/n joinpdevent/n joinuzievent/n joinkevent/n joincsevent", "Cancel");
}
case 1: {
if(IsPlayerAdmin(playerid)) {
SendClientMessage(playerid, -2, "*Admin Commands* /devent/n gevent/n srevent/n mlevent/n shevent/n sgevent/n dmevent/n pdeven/n uzievent/n kevent/n csevent/n startminievent/n eh", "Cancel");
}
}
}
}
}
return 0;
}


And the warnings :

C:\Users\Propriйtaire\Desktop\caca.pwn(19) : warning 202: number of arguments does not match definition
C:\Users\Propriйtaire\Desktop\caca.pwn(23) : warning 202: number of arguments does not match definition
C:\Users\Propriйtaire\Desktop\caca.pwn(29) : warning 217: loose indentation
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


3 Warnings.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)