Help - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help (
/showthread.php?tid=145081)
Help -
ViruZZzZ_ChiLLL - 30.04.2010
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
Re: Help -
Dolph - 30.04.2010
Код:
if(strlen(tmp) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /cookies [playerid] [amount]");
Change playerid with the id for other players..
Re: Help -
maij - 30.04.2010
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;
}