SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 20/10/2019, 08:59 AM   #1
mems
Little Clucker
 
Join Date: Oct 2019
Posts: 7
Reputation: 0
Default command works, but sends SERVER: Unknown Command.

greetings,

new to scripting, just few days ago started coding, watching scripting tutorials on youtube, however i found a problem
on the command which is this one:

Code:
CMD:setskin(playerid, params[]){
new TargetID, SkinID;
	if(sscanf(params, "ui", TargetID, SkinID)) return SendClientMessage(playerid, COLOR_GREEN, "Syntax: /setskin <playerid> <skin id>");
	if(!IsPlayerConnected(TargetID)) return SendClientMessage(playerid, COLOR_RED, "ERROR: That user is currently not online.");
	if(SkinID < 0 || SkinID > 299) return SendClientMessage(playerid, COLOR_RED, "ERROR: The specified skin is invalid.");
	if(TargetID == playerid) return SendClientMessage(playerid, COLOR_RED, "ERROR: You can't set skin on yourself!");
	SetPlayerSkin(TargetID, SkinID);
	SendClientMessage(TargetID, COLOR_GREEN, "Your skin was changed.");
	SendClientMessage(playerid, COLOR_GREEN, "Successfully changed player's skin.");
	return 1;
}
any idea what's causing this? i also tried another command but it's still the same error, btw you can explain the problem on idiot talk since i'm new to scripting and i don't understand much
mems is offline   Reply With Quote
Old 20/10/2019, 09:40 AM   #2
WalkZ
Big Clucker
 
WalkZ's Avatar
 
Join Date: Oct 2019
Location: Pakistan
Posts: 84
Reputation: 4
Default Re: command works, but sends SERVER: Unknown Command.

Quote:
Originally Posted by mems View Post
greetings,

new to scripting, just few days ago started coding, watching scripting tutorials on youtube, however i found a problem
on the command which is this one:

Code:
CMD:setskin(playerid, params[]){
new TargetID, SkinID;
	if(sscanf(params, "ui", TargetID, SkinID)) return SendClientMessage(playerid, COLOR_GREEN, "Syntax: /setskin <playerid> <skin id>");
	if(!IsPlayerConnected(TargetID)) return SendClientMessage(playerid, COLOR_RED, "ERROR: That user is currently not online.");
	if(SkinID < 0 || SkinID > 299) return SendClientMessage(playerid, COLOR_RED, "ERROR: The specified skin is invalid.");
	if(TargetID == playerid) return SendClientMessage(playerid, COLOR_RED, "ERROR: You can't set skin on yourself!");
	SetPlayerSkin(TargetID, SkinID);
	SendClientMessage(TargetID, COLOR_GREEN, "Your skin was changed.");
	SendClientMessage(playerid, COLOR_GREEN, "Successfully changed player's skin.");
	return 1;
}
any idea what's causing this? i also tried another command but it's still the same error, btw you can explain the problem on idiot talk since i'm new to scripting and i don't understand much
You need to update your ZCMD include to fix it
for a quick fix try this
PHP Code:
public OnPlayerCommandText(playeridcmdtext[])
{
    if(!
strcmp(cmdtext"/setskin"true))
    {
      new 
TargetIDSkinID;
      if(
sscanf(params"ui"TargetIDSkinID)) return SendClientMessage(playeridCOLOR_GREEN"Syntax: /setskin <playerid> <skin id>");
      if(!
IsPlayerConnected(TargetID)) return SendClientMessage(playeridCOLOR_RED"ERROR: That user is currently not online.");
      if(
SkinID || SkinID 299) return SendClientMessage(playeridCOLOR_RED"ERROR: The specified skin is invalid.");
      if(
TargetID == playerid) return SendClientMessage(playeridCOLOR_RED"ERROR: You can't set skin on yourself!");
      
SetPlayerSkin(TargetIDSkinID);
      
SendClientMessage(TargetIDCOLOR_GREEN"Your skin was changed.");
      
SendClientMessage(playeridCOLOR_GREEN"Successfully changed player's skin.");
      return 
true;
    }
    return 
SendClientMessage(playerid0xFFFFFF"Unknown Command!");

__________________
[EN] Chinatown Freeroam [BETA]
- Different Advanced Deathmatches with Times and Scores
- Different Races
- Different Events
- Gangs (Groves, Ballas, Aztecas, Mafia, Bikers & Triads)
- Drugs with Drug Dealers at Streets
- Hitman Bounty System
- Ammunations, Pizza Stacks, Burger-Shots, Banks
- Jobs (Pizza-Boy, Plumber, Trasher, Bus)
- Money-Bag every 30 minutes
- Reaction Test every 15 minutes
- Daily improving by adding new features and fixing present bugs.
WalkZ is online now   Reply With Quote
Old 20/10/2019, 09:56 AM   #3
mems
Little Clucker
 
Join Date: Oct 2019
Posts: 7
Reputation: 0
Default Re: command works, but sends SERVER: Unknown Command.

hmm, the thing is i didn't include ZCMD, lemme include it and i will give updates

update: it actually fixed it, thanks man. +rep

wait, something happened, when i included ZCMD, it worked, but when i type the command to set my skin, it gives the command again...
mems is offline   Reply With Quote
Old 20/10/2019, 10:05 AM   #4
Proxus
Huge Clucker
 
Proxus's Avatar
 
Join Date: May 2018
Location: United Kingdom
Posts: 319
Reputation: 12
Default Re: command works, but sends SERVER: Unknown Command.

Quote:
Originally Posted by mems View Post
hmm, the thing is i didn't include ZCMD, lemme include it and i will give updates

update: it actually fixed it, thanks man. +rep

wait, something happened, when i included ZCMD, it worked, but when i type the command to set my skin, it gives the command again...
By 'gives the command again', do you mean it gives the "Unknown command" error or something else?
__________________
Developer @ Trucknation
Administrator & Developer @ Lost Legacy
"Never tell people how to do things. Tell them what to do and they will surprise you with their ingenuity"


IMPORTANT LINKS
Proxus is online now   Reply With Quote
Old 20/10/2019, 10:07 AM   #5
mems
Little Clucker
 
Join Date: Oct 2019
Posts: 7
Reputation: 0
Default Re: command works, but sends SERVER: Unknown Command.

umm no, when i type for example (/setskin 0 188, it just sends this: Syntax: /setskin <playerid> <skinid>

edit again: does this error have to do with this warning maybe?
Code:
\pawno\include\zcmd.inc(18) : warning 201: redefinition of constant/macro (symbol "COMMAND:%1(%2)")
\pawno\include\zcmd.inc(21) : warning 201: redefinition of constant/macro (symbol "CMD:%1(%2)")
mems is offline   Reply With Quote
Old 20/10/2019, 10:12 AM   #6
WalkZ
Big Clucker
 
WalkZ's Avatar
 
Join Date: Oct 2019
Location: Pakistan
Posts: 84
Reputation: 4
Default Re: command works, but sends SERVER: Unknown Command.

Quote:
Originally Posted by mems View Post
umm no, when i type for example (/setskin 0 188, it just sends this: Syntax: /setskin <playerid> <skinid>
Change
PHP Code:
      if(sscanf(params"ui"TargetIDSkinID)) return SendClientMessage(playeridCOLOR_GREEN"Syntax: /setskin <playerid> <skin id>"); 
To

PHP Code:
      if(sscanf(params"uds[30]"TargetIDSkinID)) return SendClientMessage(playeridCOLOR_GREEN"Syntax: /setskin <playerid> <skin id>"); 
__________________
[EN] Chinatown Freeroam [BETA]
- Different Advanced Deathmatches with Times and Scores
- Different Races
- Different Events
- Gangs (Groves, Ballas, Aztecas, Mafia, Bikers & Triads)
- Drugs with Drug Dealers at Streets
- Hitman Bounty System
- Ammunations, Pizza Stacks, Burger-Shots, Banks
- Jobs (Pizza-Boy, Plumber, Trasher, Bus)
- Money-Bag every 30 minutes
- Reaction Test every 15 minutes
- Daily improving by adding new features and fixing present bugs.
WalkZ is online now   Reply With Quote
Old 20/10/2019, 10:14 AM   #7
Proxus
Huge Clucker
 
Proxus's Avatar
 
Join Date: May 2018
Location: United Kingdom
Posts: 319
Reputation: 12
Default Re: command works, but sends SERVER: Unknown Command.

Quote:
Originally Posted by WalkZ View Post
Change
PHP Code:
      if(sscanf(params"ui"TargetIDSkinID)) return SendClientMessage(playeridCOLOR_GREEN"Syntax: /setskin <playerid> <skin id>"); 
To

PHP Code:
      if(sscanf(params"uds[30]"TargetIDSkinID)) return SendClientMessage(playeridCOLOR_GREEN"Syntax: /setskin <playerid> <skin id>"); 
Why would you do that? There's only two args (targetid and skinid, not 3)

@mems, if you've already got a CMD: setskin / COMMAND: setskin, try getting rid of the strcmp command. Otherwise, you may have made a duplicate command?

So basically, if you added the script above which was this:
Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext, "/setskin", true))
    {
      new TargetID, SkinID;
      if(sscanf(params, "ui", TargetID, SkinID)) return SendClientMessage(playerid, COLOR_GREEN, "Syntax: /setskin <playerid> <skin id>");
      if(!IsPlayerConnected(TargetID)) return SendClientMessage(playerid, COLOR_RED, "ERROR: That user is currently not online.");
      if(SkinID < 0 || SkinID > 299) return SendClientMessage(playerid, COLOR_RED, "ERROR: The specified skin is invalid.");
      if(TargetID == playerid) return SendClientMessage(playerid, COLOR_RED, "ERROR: You can't set skin on yourself!");
      SetPlayerSkin(TargetID, SkinID);
      SendClientMessage(TargetID, COLOR_GREEN, "Your skin was changed.");
      SendClientMessage(playerid, COLOR_GREEN, "Successfully changed player's skin.");
      return true;
    }
    return SendClientMessage(playerid, 0xFFFFFF, "Unknown Command!");
}
Get rid of that if you're using zcmd
__________________
Developer @ Trucknation
Administrator & Developer @ Lost Legacy
"Never tell people how to do things. Tell them what to do and they will surprise you with their ingenuity"


IMPORTANT LINKS
Proxus is online now   Reply With Quote
Old 20/10/2019, 10:15 AM   #8
WalkZ
Big Clucker
 
WalkZ's Avatar
 
Join Date: Oct 2019
Location: Pakistan
Posts: 84
Reputation: 4
Default Re: command works, but sends SERVER: Unknown Command.

Quote:
Originally Posted by mems View Post
umm no, when i type for example (/setskin 0 188, it just sends this: Syntax: /setskin <playerid> <skinid>

edit again: does this error have to do with this warning maybe?
Code:
\pawno\include\zcmd.inc(18) : warning 201: redefinition of constant/macro (symbol "COMMAND:%1(%2)")
\pawno\include\zcmd.inc(21) : warning 201: redefinition of constant/macro (symbol "CMD:%1(%2)")
Are you using more than 1 command processor?
Show what files you included in your script
__________________
[EN] Chinatown Freeroam [BETA]
- Different Advanced Deathmatches with Times and Scores
- Different Races
- Different Events
- Gangs (Groves, Ballas, Aztecas, Mafia, Bikers & Triads)
- Drugs with Drug Dealers at Streets
- Hitman Bounty System
- Ammunations, Pizza Stacks, Burger-Shots, Banks
- Jobs (Pizza-Boy, Plumber, Trasher, Bus)
- Money-Bag every 30 minutes
- Reaction Test every 15 minutes
- Daily improving by adding new features and fixing present bugs.
WalkZ is online now   Reply With Quote
Old 20/10/2019, 10:15 AM   #9
mems
Little Clucker
 
Join Date: Oct 2019
Posts: 7
Reputation: 0
Default Re: command works, but sends SERVER: Unknown Command.

Quote:
Originally Posted by WalkZ View Post
Change
PHP Code:
      if(sscanf(params"ui"TargetIDSkinID)) return SendClientMessage(playeridCOLOR_GREEN"Syntax: /setskin <playerid> <skin id>"); 
To

PHP Code:
      if(sscanf(params"uds[30]"TargetIDSkinID)) return SendClientMessage(playeridCOLOR_GREEN"Syntax: /setskin <playerid> <skin id>"); 
replaced it, also included zcmd, ran but same results
mems is offline   Reply With Quote
Old 20/10/2019, 10:16 AM   #10
Proxus
Huge Clucker
 
Proxus's Avatar
 
Join Date: May 2018
Location: United Kingdom
Posts: 319
Reputation: 12
Default Re: command works, but sends SERVER: Unknown Command.

Quote:
Originally Posted by mems View Post
replaced it, also included zcmd, ran but same results
Have you tried what I posted? ^^
__________________
Developer @ Trucknation
Administrator & Developer @ Lost Legacy
"Never tell people how to do things. Tell them what to do and they will surprise you with their ingenuity"


IMPORTANT LINKS
Proxus is online now   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SERVER UNKNOWN COMMAND, but command works majmunko Scripting Help 7 19/09/2018 10:02 AM
SERVER:Unknown command. error even the command works well GameOvr Scripting Help 20 07/09/2018 03:05 PM
SERVER: Unknown Command, but still works? BeEasy114 Help Archive 11 04/06/2011 04:26 PM
SERVER: Unknown Command but the Command works anantanni Help Archive 13 19/03/2011 06:00 AM
Teleport works but Server:Unknown Command patchkinson Help Archive 2 22/11/2009 01:40 PM


All times are GMT. The time now is 04:29 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.