Adminscript - 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: Adminscript (
/showthread.php?tid=120941)
Adminscript -
icorne - 14.01.2010
Im making an adminscript but if i login in rcon and do /givepilot i give myself pilot. I want have that /givepilot [ID] works.
Anyone know how i make /givepilot [ID] ?
Код:
public OnPlayerCommandText(playerid, cmdtext[])
if(strcmp("/makepilot", cmdtext, true) == 0)
{
if(IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, 0xFF6600AA, "That player is now pilot!");
SetPlayerSkin(playerid, 61);
IsPlayerAdmin(playerid);
return 1;
}
return 1;
}
Re: Adminscript -
wiilweer - 14.01.2010
Hmm since I'm newbie scripter and we have faster commands like dcmd and zcmd, i can do this, but strtok...nope

.
DCMD:
pawn Код:
dcmd_makepilot(playerid, params[])
{
new otherid;
if sscanf(params, "u", otherid) return SendClientMessage(playerid, COLOR_GREY, "USAGE: makepilot: ID");
if (!(IsPlayerAdmin(playerid))) return SendClientMessage(playerid, COLOR_GREY, "You must be admin!");
SendClientMessage(playerid, 0xFF6600AA, "That player is now pilot!");
SetPlayerSkin(playerid, 61);
return 1;
}
Re: Adminscript -
icorne - 14.01.2010
Quote:
Originally Posted by wiilweer
Hmm since I'm newbie scripter and we have faster commands like dcmd and zcmd, i can do this, but strtok...nope  .
DCMD:
pawn Код:
dcmd_makepilot(playerid, params[]) { new otherid; if sscanf(params, "u", otherid) return SendClientMessage(playerid, COLOR_GREY, "USAGE: makepilot: ID");
if (!(IsPlayerAdmin(playerid))) return SendClientMessage(playerid, COLOR_GREY, "You must be admin!");
SendClientMessage(playerid, 0xFF6600AA, "That player is now pilot!"); SetPlayerSkin(playerid, 61); return 1; }
|
Not works, standing ingame: Unknown Command
Re: Adminscript -
icorne - 14.01.2010
Anyone else?
Re: Adminscript -
wafffllesss - 14.01.2010
Quote:
Originally Posted by icorne
Anyone else?
|
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new idx;
new cmd[256];
cmd = strtok(cmdtext, idx);
if(!strcmp("/makepilot", cmd, true))
{
if(IsPlayerAdmin(playerid))
{
new tmp[128];
tmp = strtok(cmdtext,idx);
if(!strlen(tmp)){
SendClientMessage(playerid,0xFF6600AA,"USAGE: /makepilot [playerid]");
return true;
}
new pid = strval(tmp);
if(!IsPlayerConnected(pid)){
SendClientMessage(playerid,0xFF6600AA,"Player is offline");
return true;
}
SendClientMessage(playerid, 0xFF6600AA, "That player is now pilot!");
SendClientMessage(pid, 0xFF6600AA, "You're now a pilot!");
SetPlayerSkin(pid, 61);
return 1;
}
}
return 1;
}
In case you need:
pawn Код:
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
Re: Adminscript -
icorne - 14.01.2010
Quote:
Originally Posted by wafffllesss
Quote:
Originally Posted by icorne
Anyone else?
|
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[]) { new idx; new cmd[256]; cmd = strtok(cmdtext, idx); if(!strcmp("/makepilot", cmd, true)) { if(IsPlayerAdmin(playerid)) { new tmp[128]; tmp = strtok(cmdtext,idx); if(!strlen(tmp)){ SendClientMessage(playerid,0xFF6600AA,"USAGE: /makepilot [playerid]"); return true; }
new pid = strval(tmp); if(!IsPlayerConnected(pid)){ SendClientMessage(playerid,0xFF6600AA,"Player is offline"); return true; } SendClientMessage(playerid, 0xFF6600AA, "That player is now pilot!"); SendClientMessage(pid, 0xFF6600AA, "You're now a pilot!"); SetPlayerSkin(pid, 61); return 1; } } return 1; }
In case you need:
pawn Код:
strtok(const string[], &index) { new length = strlen(string); while ((index < length) && (string[index] <= ' ')) { index++; }
new offset = index; new result[20]; while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1))) { result[index - offset] = string[index]; index++; } result[index - offset] = EOS; return result; }
|
Good but 1 error: C:\Documents and Settings\Administrator\Bureaublad\Warserver\filter scripts\admscript.pwn(42) : error 030: compound statement not closed at the end of file (started at line 15)
Re: Adminscript -
wafffllesss - 14.01.2010
Quote:
Originally Posted by icorne
Quote:
Originally Posted by wafffllesss
Quote:
Originally Posted by icorne
Anyone else?
|
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[]) { new idx; new cmd[256]; cmd = strtok(cmdtext, idx); if(!strcmp("/makepilot", cmd, true)) { if(IsPlayerAdmin(playerid)) { new tmp[128]; tmp = strtok(cmdtext,idx); if(!strlen(tmp)){ SendClientMessage(playerid,0xFF6600AA,"USAGE: /makepilot [playerid]"); return true; }
new pid = strval(tmp); if(!IsPlayerConnected(pid)){ SendClientMessage(playerid,0xFF6600AA,"Player is offline"); return true; } SendClientMessage(playerid, 0xFF6600AA, "That player is now pilot!"); SendClientMessage(pid, 0xFF6600AA, "You're now a pilot!"); SetPlayerSkin(pid, 61); return 1; } } return 1; }
In case you need:
pawn Код:
strtok(const string[], &index) { new length = strlen(string); while ((index < length) && (string[index] <= ' ')) { index++; }
new offset = index; new result[20]; while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1))) { result[index - offset] = string[index]; index++; } result[index - offset] = EOS; return result; }
|
Good but 1 error: C:\Documents and Settings\Administrator\Bureaublad\Warserver\filter scripts\admscript.pwn(42) : error 030: compound statement not closed at the end of file (started at line 15)
|
This mean you forget to close "}" something.. cuz the script i set you is working. at least for me. check your script.