SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 21/06/2018, 02:40 AM   #1
kovac
Banned
 
Join Date: Mar 2018
Posts: 177
Reputation: 14
Default Format returning SERVER:UNKNOWN COMMAND

Hello,
I m experiencing problem while trying to divide UserStats[targetid][WeaponHitsOP] with UserStats[targetid][MissedWeaponHits]

PHP Code:
    format(stringsizeof(string), "{FF0000}[STATS] {FFFFFF}Kills: %d, Deaths: %d, Ratio: %0.2f, Hit accuracy: %d"UserStats[targetid][Kills],UserStats[targetid][Deaths],floatdiv(UserStats[targetid][Kills], UserStats[targetid][Deaths]), UserStats[targetid][WeaponHitsOP]/UserStats[targetid][MissedWeaponHits]);
    
SendClientMessage(playeridCOLOR_WHITEstring); 
Command would return "SERVER: Unknown command" error. Why?
If I remove that part of code, or just the accuracy, everything would be fine.
kovac is offline   Reply With Quote
Old 21/06/2018, 02:50 AM   #2
AgusZ
Big Clucker
 
Join Date: Nov 2014
Location: Earth
Posts: 148
Reputation: 7
Default Re: Format returning SERVER:UNKNOWN COMMAND

Can you show me the full of code?
AgusZ is offline   Reply With Quote
Old 21/06/2018, 02:53 AM   #3
kovac
Banned
 
Join Date: Mar 2018
Posts: 177
Reputation: 14
Default Re: Format returning SERVER:UNKNOWN COMMAND

Here you go.

PHP Code:
CMD<ALL>:stats(cmdidplayeridparams[])
{
    new 
targetidstring[128];
    if(
sscanf(params"u"targetid)) targetid playerid;
    if(!
IsPlayerConnected(targetid)) return SCM(playeridCOLOR_REDNOPLAYER);
    if(!
LoggedIn[targetid]) return SCM(playeridCOLOR_REDNOTLOGGEDIN);
    
SendClientMessage(playeridCOLOR_TOMATO"");
    
format(stringsizeof(string), "..:: %s's account statistic ::.."GetName(targetid));
    
SendClientMessage(playeridCOLOR_TOMATOstring);
    
format(stringsizeof(string), "{FF0000}[WEAPON KILLS] {FFFFFF}Deagle: %d, Sniper: %d, M4: %d, Shotgun: %d, Combat: %d, MP5: %d, SawnOff: %d"UserStats[targetid][DeagleKills],UserStats[targetid][SniperKills],UserStats[targetid][M4Kills], UserStats[targetid][ShotgunKills],UserStats[targetid][CombatKills],UserStats[targetid][MP5Kills],UserStats[targetid][SawnOffKills]);
    
SendClientMessage(playeridCOLOR_WHITEstring);
    
format(stringsizeof(string), "{FF0000}[STATS] {FFFFFF}Kills: %d, Deaths: %d, Ratio: %0.2f, Hit accuracy: %d"UserStats[targetid][Kills],UserStats[targetid][Deaths],floatdiv(UserStats[targetid][Kills], UserStats[targetid][Deaths]), UserStats[targetid][WeaponHitsOnPlayer]/UserStats[targetid][MissedWeaponHits]);
    
SendClientMessage(playeridCOLOR_WHITEstring);
    
SendClientMessage(playeridCOLOR_TOMATO"");
    return 
1;


The command works if I don't include that part.
kovac is offline   Reply With Quote
Old 21/06/2018, 06:40 AM   #4
Shadow0707
Big Clucker
 
Join Date: Sep 2016
Posts: 92
Reputation: 7
Default Re: Format returning SERVER:UNKNOWN COMMAND

Quote:
Originally Posted by kovac View Post
Here you go.

PHP Code:
format(stringsizeof(string), "{FF0000}[STATS] {FFFFFF}Kills: %d, Deaths: %d, Ratio: %0.2f, Hit accuracy: %d"UserStats[targetid][Kills],UserStats[targetid][Deaths],floatdiv(UserStats[targetid][Kills], UserStats[targetid][Deaths]), UserStats[targetid][WeaponHitsOnPlayer]/UserStats[targetid][MissedWeaponHits]); // -----  is this slash should be really there? 

The command works if I don't include that part.
I just found something correct me if i'm wrong
PHP Code:
CMD<ALL>:stats(cmdidplayeridparams[]) 

    new 
targetidstring[128]; 
    if(
sscanf(params"u"targetid)) targetid playerid
    if(!
IsPlayerConnected(targetid)) return SCM(playeridCOLOR_REDNOPLAYER); 
    if(!
LoggedIn[targetid]) return SCM(playeridCOLOR_REDNOTLOGGEDIN); 
    
SendClientMessage(playeridCOLOR_TOMATO""); 
    
format(stringsizeof(string), "..:: %s's account statistic ::.."GetName(targetid)); 
    
SendClientMessage(playeridCOLOR_TOMATOstring); 
    
format(stringsizeof(string), "{FF0000}[WEAPON KILLS] {FFFFFF}Deagle: %d, Sniper: %d, M4: %d, Shotgun: %d, Combat: %d, MP5: %d, SawnOff: %d"UserStats[targetid][DeagleKills],UserStats[targetid][SniperKills],UserStats[targetid][M4Kills], UserStats[targetid][ShotgunKills],UserStats[targetid][CombatKills],UserStats[targetid][MP5Kills],UserStats[targetid][SawnOffKills]); 
    
SendClientMessage(playeridCOLOR_WHITEstring); 
    
format(stringsizeof(string), "{FF0000}[STATS] {FFFFFF}Kills: %d, Deaths: %d, Ratio: %0.2f, Hit accuracy: %d"UserStats[targetid][Kills],UserStats[targetid][Deaths],floatdiv(UserStats[targetid][Kills], UserStats[targetid][Deaths]), UserStats[targetid][WeaponHitsOnPlayer], UserStats[targetid][MissedWeaponHits]); 
    
SendClientMessage(playeridCOLOR_WHITEstring); 
    
SendClientMessage(playeridCOLOR_TOMATO""); 
    return 
1

Shadow0707 is offline   Reply With Quote
Old 21/06/2018, 06:45 AM   #5
RoboN1X
Huge Clucker
 
RoboN1X's Avatar
 
Join Date: Feb 2011
Location: Indonesia
Posts: 453
Reputation: 145
Default Re: Format returning SERVER:UNKNOWN COMMAND

Let me guess your problem:
You are trying to divide with zero...

When the player has hits but never missed, they will get that error in commands.

You need to check first if MissedWeaponHits has positive value, then you can divide with it. When both is zero, simply tells the player has no accuracy, otherwise 100% accuracy.
__________________
Need Help? Use Search, WIKI, and FAQ
RoboN1X is offline   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
Returning unknown command conor565 Scripting Help 7 07/09/2015 03:56 AM
format() causing SERVER: Unknown command quagga Scripting Help 2 31/07/2012 05:32 PM
one command is returning SERVER: Unknown Command admantis Scripting Help 11 20/11/2011 03:26 PM
2 Commands returning "SERVER: Unknown command" _Vortex Help Archive 6 08/01/2010 07:38 PM


All times are GMT. The time now is 09:18 AM.


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