Commands problem
#1

Hello , i got some problems with those two cmds
there is no errors or warnings , but their not working in Game

here's the code

First cmd :

PHP код:
if(!strcmp(cmd"/setscore"))
    {
  {
  if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,"You are not an admin !");
  new 
targetidscorestring[128];
  if(
sscanf(params"uz"targetid,score)) return SendClientMessage(playerid0xFFFFFFFF"Usage: /setscore [playerid/partofname] [score]");
  if(!
IsPlayerConnected(targetid)) return SendClientMessage(playerid0xFFFFFFFF"Player not connected!");
  else
  {
  
SetPlayerScore(targetidscore);
  
format(string,sizeof(string),"an Admin has changed your Score to %s "score);
  
SendClientMessage(targetid0xA10000AAstring);
  }
  }
  return 
1;

Second one

PHP код:
if(!strcmp(cmd"/asay1"))
    {
  {
  if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,"You are not an admin !");
  new 
text[128];
  if(
sscanf(params"s[128]",text)) return SendClientMessage(playerid0xFFFFFFFF"Usage: /asay [text]");
  else
  {
  new 
string[128];
  new 
pName[128];
  
GetPlayerName(playerid,pName,128);
  
format(string,sizeof string,"[ADMIN]%s: %s",pName,text);
  
SendClientMessageToAll(0xA10000AA,string);
  }
  }
  return 
1;

Reply
#2

why
else
{
code
} ?? you dont need to put else ^^
Reply
#3

Код:
if(!strcmp(cmd, "/setscore",true) == 0) 
    { 
  { 
  if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,"You are not an admin !"); 
  new targetid, score, string[128]; 
  if(sscanf(params, "uz", targetid,score)) return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /setscore [playerid/partofname] [score]"); 
  if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, 0xFFFFFFFF, "Player not connected!"); 
  else 
  { 
  SetPlayerScore(targetid, score); 
  format(string,sizeof(string),"an Admin has changed your Score to %s ", score); 
  SendClientMessage(targetid, 0xA10000AA, string); 
  } 
  } 
  return 1; 
}
Код:
if(!strcmp(cmd, "/asay1",true) == 0) 
    { 
  { 
  if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,"You are not an admin !"); 
  new text[128]; 
  if(sscanf(params, "s[128]",text)) return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /asay [text]"); 
  else 
  { 
  new string[128]; 
  new pName[128]; 
  GetPlayerName(playerid,pName,128); 
  format(string,sizeof string,"[ADMIN]%s: %s",pName,text); 
  SendClientMessageToAll(0xA10000AA,string); 
  } 
  } 
  return 1; 
}
Reply
#4

-.- you dont have 2 put else!!!!!!!!!
Reply
#5

For first one Try this Not tested
pawn Код:
if(!strcmp(cmd, "/setscore"))
    {
  {
  if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,"You are not an admin !");
  new targetid, score, string[128];
  if(sscanf(params, "uz", targetid,score)) return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /setscore [playerid/partofname] [score]");
  if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, 0xFFFFFFFF, "Player not connected!");
  SetPlayerScore(targetid, score);
  format(string,sizeof(string),"an Admin has changed your Score to %s ", score);
  SendClientMessage(targetid, 0xA10000AA, string);
  }
  }
  return 1;
}
Reply
#6

Quote:
Originally Posted by [ISS]jumbo
Посмотреть сообщение
-.- you dont have 2 put else!!!!!!!!!
+1
get rid of the elses

Код:
if(!strcmp(cmd, "/setscore")) 
{ 

  if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,"You are not an admin !"); 
  new targetid, score, string[128]; 
  if(sscanf(params, "uz", targetid,score)) return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /setscore [playerid/partofname] [score]"); 
  if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, 0xFFFFFFFF, "Player not connected!"); 
  SetPlayerScore(targetid, score); 
  format(string,sizeof(string),"an Admin has changed your Score to %s ", score); 
  SendClientMessage(targetid, 0xA10000AA, string); 
return 1;
}
Код:
if(!strcmp(cmd, "/asay1")) 
{ 

  if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,"You are not an admin !"); 
  new text[128]; 
  if(sscanf(params, "s[128]",text)) return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /asay [text]"); 
  new string[128]; 
  new pName[128]; 
  GetPlayerName(playerid,pName,128); 
  format(string,sizeof string,"[ADMIN]%s: %s",pName,text); 
  SendClientMessageToAll(0xA10000AA,string); 
  return 1; 
}
Reply
#7

I Tryed all you told me to do.. But still not working...
For the /setscore , when i do /setscore 0 7 , my score changes to 55 and when i do /setscore 0 9 , nothing happens.
and for the /asay1 , still when i do /asay1 Hey , it shows /asay1 [text]

Can you please try to help me?
Reply
#8

im kindof new to sscanf , so I you would make it with strtok what would be good .
but this should really fix the problem. but I know that in sscanf i = integer . why did you put there uz?
Reply
#9

I Put uz because , i made /setarmour and /sethealth and the 2 commands so i thought /setscore will work in the same way.
Reply
#10

and that's us problem. You have to put ui even for the setarmour and sethealth. uz is used only on some cmds like /ban etc... (not /kick)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)