/Ooc -
RoneyRemington - 23.02.2010
why is this code wrong in pawn?
it says (2923) : error 030: compound statement not closed at the end of file (started at line 2889)
public OnPlayerCommandText(playerid, cmdtext[])
{
new string[256];
new playermoney;
new sendername[MAX_PLAYER_NAME];
new giveplayer[MAX_PLAYER_NAME];
new playername[MAX_PLAYER_NAME];
new cmd[256];
new tmp[256];
new giveplayerid, moneys, idx;
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/ooc", true) == 0 || strcmp(cmd, "/o", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(gPlayerLogged[playerid] == 0)
{
SendClientMessage(playerid, COLOR_GREY, " You havent logged in yet !");
return 1;
}
GetPlayerName(playerid, sendername, sizeof(sendername));
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: (/o)oc [ooc chat]");
return 1;
}
format(string, sizeof(string), "(( %s: %s ))", sendername, result);
printf("%s", string);
{
return 0;
}
Re: /Ooc -
Klutty - 23.02.2010
Remove the return 1; after the SendClientMessage.
Re: /Ooc -
Correlli - 23.02.2010
You have an opening bracket ({) before
return 0; code.
Re: /Ooc -
RoneyRemington - 23.02.2010
now i get this error. and it looks like this
error
Код:
C:\Users\TJ's Server\Desktop\Server SA-MP\gamemodes\WEWFGRP.pwn(2935) : error 030: compound statement not closed at the end of file (started at line 2881)
code
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256];
new tmp[256];
new Message[256];
new gMessage[256];
new pName[MAX_PLAYER_NAME+1];
new iName[MAX_PLAYER_NAME+1];
new idx;
new string[256];
new playermoney;
new sendername[MAX_PLAYER_NAME];
new giveplayer[MAX_PLAYER_NAME];
new playername[MAX_PLAYER_NAME];
cmd = strtok(cmdtext, idx);
{
if(strcmp(cmd, "/ooc", true) == 0 || strcmp(cmd, "/o", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(gPlayerLogged[playerid] == 0)
{
SendClientMessage(playerid, COLOR_GREY, " You havent logged in yet !");
}
GetPlayerName(playerid, sendername, sizeof(sendername));
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: (/o)oc [ooc chat]");
return 1;
}
format(string, sizeof(string), "(( %s: %s ))", sendername, result);
printf("%s", string);
}
return 1;
}
}
Re: /Ooc -
Joe Staff - 23.02.2010
I have yet to understand why people insist on using that method of getting the single-stringed parameters of a player's command
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmd, "/ooc", true,4) == 0 || strcmp(cmd, "/o", true,2) == 0)
{
//if(IsPlayerConnected(playerid)) //Redundant, a player can't type a command if he isn't connected to the server
if(gPlayerLogged[playerid] == 0)return SendClientMessage(playerid, COLOR_GREY, " You havent logged in yet !");
GetPlayerName(playerid, sendername, sizeof(sendername));
new space=strfind(cmdtext," ");
if(!strlen(cmdtext[space])||(space==-1))return SendClientMessage(playerid, COLOR_GRAD2, "USAGE: (/o)oc [ooc chat]");
format(string, sizeof(string), "(( %s: %s ))", sendername, cmdtext[space]);
printf("%s", cmdtext[space]);
return 1;
}
}
Re: /Ooc -
RoneyRemington - 23.02.2010
ok now i get an error that says that i have if but not ; chack please
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
{
new cmd[256];
new tmp[256];
new Message[256];
new gMessage[256];
new pName[MAX_PLAYER_NAME+1];
new iName[MAX_PLAYER_NAME+1];
new idx;
new string[256];
new playermoney;
new sendername[MAX_PLAYER_NAME];
new giveplayer[MAX_PLAYER_NAME];
new playername[MAX_PLAYER_NAME];
cmd = strtok(cmdtext, idx)
if(strcmp(cmd, "/ooc", true,4) == 0 || strcmp(cmd, "/o", true,2) == 0)
if(gPlayerLogged[playerid] == 0)return SendClientMessage(playerid, COLOR_GREY, " You havent logged in yet !");
GetPlayerName(playerid, sendername, sizeof(sendername));
new space=strfind(cmdtext," ");
if(!strlen(cmdtext[space])||(space==-1))return SendClientMessage(playerid, COLOR_GRAD2, "USAGE: (/o)oc [ooc chat]");
format(string, sizeof(string), "(( %s: %s ))", sendername, cmdtext[space]);
printf("%s", cmdtext[space]);
return 1;
}
}
Re: /Ooc -
Shubham - 24.02.2010
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256];
new tmp[256];
new Message[256];
new gMessage[256];
new pName[MAX_PLAYER_NAME+1];
new iName[MAX_PLAYER_NAME+1];
new idx;
new string[256];
new playermoney;
new sendername[MAX_PLAYER_NAME];
new giveplayer[MAX_PLAYER_NAME];
new playername[MAX_PLAYER_NAME];
cmd = strtok(cmdtext, idx)
if(strcmp(cmd, "/ooc", true,4) == 0 || strcmp(cmd, "/o", true,2) == 0)
{
if(gPlayerLogged[playerid] == 0)return SendClientMessage(playerid, COLOR_GREY, " You havent logged in yet !");
GetPlayerName(playerid, sendername, sizeof(sendername));
new space=strfind(cmdtext," ");
if(!strlen(cmdtext[space])||(space==-1))return SendClientMessage(playerid, COLOR_GRAD2, "USAGE: (/o)oc [ooc chat]");
format(string, sizeof(string), "(( %s: %s ))", sendername, cmdtext[space]);
printf("%s", cmdtext[space]);
return 1;
}
return 0;
}
Re: /Ooc -
RoneyRemington - 24.02.2010
it is an error with this line.
if(strcmp(cmd, "/ooc", true,4) == 0 || strcmp(cmd, "/o", true,2) == 0)
C:\Users\TJ's Server\Desktop\Server SA-MP\gamemodes\WEWFGRP.pwn(2914) : error 001: expected token: ";", but found "if"
Re: /Ooc -
VonLeeuwen - 24.02.2010
Change
pawn Код:
cmd = strtok(cmdtext, idx)
into
pawn Код:
cmd = strtok(cmdtext, idx);