#1

Okay so I have this code of giving someone a cookie
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256], idx, file[128], tmp[256];
cmd = strtok(cmdtext, idx);

if(strcmp(cmd, "/cookies", true) == 0)
 {
 if(IsPlayerLuxAdmin(playerid))
  {
  new name[MAX_PLAYER_NAME];
  tmp = strtok(cmdtext, idx);
  GetPlayerName(playerid, name, sizeof(name));
  if(strlen(tmp) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /cookies [playerid] [amount]");
  format(file,sizeof(file),"%s.ini",name);
  if(!fexist(file))
   {
   dini_Create(file);
   dini_IntSet(file,"Cookies", 0);
   }
  }
  }
return 1;
}
Problem: I'm stuck and don't know how to give that playerid a cookie. All I can do is give myself a cookie

________
RHODE ISLAND DISPENSARY
Reply
#2

Код:
if(strlen(tmp) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /cookies [playerid] [amount]");
Change playerid with the id for other players..
Reply
#3

first of, I strongly recommend using zcmd instead. That nifty system is way more efficient than these crappy comparation codes.
then secondly:
Код:
new tmp[2];
if(strcmp(cmd, "/cookies", true) == 0)
 {
 if(IsPlayerLuxAdmin(playerid))
  {
  new name[MAX_PLAYER_NAME];
  tmp[0] = strval(strtok(cmdtext, idx));//strval makes possible that only a value is assigned, no strings will be out of the way, retrieve playerid
  tmp[1] = strval(strtok(cmdtext, idx));//strval makes possible that only a value is assigned, no strings will be out of the way, retrieve amount
  if(IsPlayerConnected(tmp[0]))return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /cookies [playerid] [amount]");;//stop code, player not connected
  GetPlayerName(tmp[0], name, sizeof(name));
  if(tmp[1] <= 0) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /cookies [playerid] [amount]");
  format(file,sizeof(file),"%s.ini",name);
  if(!fexist(file))
   {
   dini_Create(file);
   dini_IntSet(file,"Cookies", tmp[1]);
   }
  }
  }
return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)