SA-MP Forums Archive
My script loads a usage it's not supposed to load - 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)
+--- Thread: My script loads a usage it's not supposed to load (/showthread.php?tid=613156)



My script loads a usage it's not supposed to load - justjamie - 25.07.2016

Hello.
It loads /v create usage, even tho it's not even supposed to load, wtf?
this is my code:
PHP код:
COMMAND:v(playeridparams[]) {
        if(!
Player[playerid][Authed] || Player[playerid][Admin] < 3) return SendClientError(playerid"You are not authorised to use this command.");
        new 
tmp15 ], tmp215 ];
        if(
sscanf(params"szz"tmptmp2)) SendClientMessage(playerid, -1"{7f7f7f}Usage: {b2b2b2}/v [Create / Model / Reload / Reloadall ]");
        if(!
strcmp(tmp"create"true6))
         {
        if(!
strlen(tmp2)) return SendClientUsage(playerid"/v create [model name / model id]");
        if(
GetPlayerInterior(playerid) > || GetPlayerVirtualWorld(playerid) > 0) return SendClientError(playerid"Please exit the interior you're currently in.");
        new 
modelID;
          if(!
IsNumeric(tmp2)) modelID GetVehicleModelIDFromName(tmp2);
        else 
modelID strval(tmp2);
        if(
modelID == -|| modelID 400 || modelID 611) return SendClientError(playerid"Model ID/Name is invalid, please try again.");
        new 
query[500]; mysql_format(connectionquerysizeof(query), "SELECT * FROM Vehicles WHERE vActive = '0' LIMIT 1;"); mysql_tquery(connectionquery"CreateVehicle1""dd"playeridmodelID);
        }
        else if(!
strcmp(tmp"reload",true,6))
        {
        if(!
IsPlayerInAnyVehicle(playerid)) return SendClientError(playerid"You are not in any vehicle!");
        
ReloadVehicle(GetPlayerVehicleID(playerid));
        
SendClientMessage(playerid,-1"Success: The car has been reloaded");
        }
        else if(!
strcmp(tmp"reloadall",true,9))
        {
        new 
query1[128]; mysql_format(connectionquery1sizeof(query1), "SELECT * FROM Vehicles WHERE vActive = '1'"); mysql_tquery(connectionquery1"reloadAllCars");
        
SendClientMessage(playerid,-1"Success: All cars have been reloaded.");
        }
        else if(!
strcmp(tmp"model"true4))
        {
        if(!
IsPlayerInAnyVehicle(playerid)) return SendClientError(playerid"You are not in any vehicle!");
        if(!
strlen(tmp2)) return SendClientUsage(playerid"create /v create [model name / model id]");
        new 
tehvID;
        if(!
IsNumeric(tmp2)) tehvID GetVehicleModelIDFromName(tmp2);
        else 
tehvID strval(tmp2);
        if(
tehvID == -|| tehvID 400 ||tehvID 611) return SendClientError(playerid"Invalid model!");
         
Vehicle[GetPlayerVehicleID(playerid)][vModel] = tehvID;
         new 
query[500];
         
format(query,sizeof(query),"UPDATE Vehicles SET vModel='%i' WHERE id='%i'",tehvID,GetPlayerVehicleID(playerid));
         
mysql_tquery(connection,query,"","");
         
ReloadVehicle(GetPlayerVehicleID(playerid));
        new 
Float:Position[3];
        
GetPlayerPos(playeridPosition[0], Position[1], Position[2]);
        
SetPlayerPos(playeridPosition[0], Position[1], Position[2]+3);
        
SendClientMessage(playerid,-1"Success: The model has been changed");
        }
        else if(!
strcmp(tmp"info"true4))
        {
        new 
string[420];
        
format(string,sizeof(string),"%i",GetPlayerVehicleID(playerid));
        
SendClientMessage(playerid,-1,string);
        }
        
        else return 
SendClientMessage(playerid, -1"{7f7f7f}Usage: {b2b2b2}/v [soon.txt ]");
        return 
1;

screen of what it does:



Re: My script loads a usage it's not supposed to load - Quinncell - 25.07.2016

My mistake of I did not understood you correctly.So you want the server to NOT load that command?


Re: My script loads a usage it's not supposed to load - justjamie - 25.07.2016

Quote:
Originally Posted by KeithCooper
Посмотреть сообщение
My mistake of I did not understood you correctly.So you want the server to NOT load that command?
this is the command:
PHP код:
COMMAND:v(playeridparams[]) { 
        if(!
Player[playerid][Authed] || Player[playerid][Admin] < 3) return SendClientError(playerid"You are not authorised to use this command."); 
        new 
tmp15 ], tmp215 ], tmp315 ], tmp415 ]; 
        if(
sscanf(params"szz"tmptmp2tmp3tmp4)) SendClientMessage(playerid, -1"{7f7f7f}Usage: {b2b2b2}/v [Create / ]"); 
        if(!
strcmp(tmp"create"true5)) 
         { 
        if(
GetPlayerInterior(playerid) > || GetPlayerVirtualWorld(playerid) > 0) return SendClientError(playerid"Please exit the interior you're currently in."); 
        new 
modelID
        if(!
strlen(tmp2)) return SendClientMessage(playerid, -1"{7f7f7f}Usage: {b2b2b2}/v create [Model]"); 
        
modelID strval(tmp2); 
        if(
modelID == -|| modelID 400 || modelID 611) return SendClientError(playerid"Model ID/Name is invalid, please try again."); 
        new 
query[500]; mysql_format(connectionquerysizeof(query), "SELECT * FROM Vehicles WHERE vActive = '0' LIMIT 1;"); mysql_tquery(connectionquery"CreateVehicle1""dd"playeridmodelID); 
        } 
        return 
1

it loads this:
PHP код:
 if(!strlen(tmp2)) return SendClientMessage(playerid, -1"{7f7f7f}Usage: {b2b2b2}/v create [Model]"); 
while it's not supposed to load it.
Why does it load the "/v create [Model]"

??


Re: My script loads a usage it's not supposed to load - Quinncell - 25.07.2016

Why did you use this in ZCMD?
PHP код:
if(!strcmp(tmp"create"true5)) 



Re: My script loads a usage it's not supposed to load - justjamie - 25.07.2016

Quote:
Originally Posted by KeithCooper
Посмотреть сообщение
Why did you use this in ZCMD?
PHP код:
if(!strcmp(tmp"create"true5)) 
to make commands like /v create and not /vcreate

did i do it wrong?


Re: My script loads a usage it's not supposed to load - Quinncell - 25.07.2016

Quote:
Originally Posted by justjamie
Посмотреть сообщение
to make commands like /v create and not /vcreate

did i do it wrong?
ohh, well there is no need to complicate things.Just re-name the command do /vc /v or something similar.
BTW, your problem is that you have to client messages sending when you do the command, just delete one.


Re: My script loads a usage it's not supposed to load - PrO.GameR - 25.07.2016

Here is the right way to do it, don't break params down into other variables before you know how you are gonna use them.
Try restructuring it this way.
PHP код:
!strcmp(params"create"true6)
{
if(
sscanf(params"'create'ddd",bla,bla,bla) return blabla;




Re: My script loads a usage it's not supposed to load - justjamie - 25.07.2016

Quote:
Originally Posted by PrO.GameR
Посмотреть сообщение
Here is the right way to do it, don't break params down into other variables before you know how you are gonna use them.
Try restructuring it this way.
PHP код:
!strcmp(params"create"true6)
{
if(
sscanf(params"'create'ddd",bla,bla,bla) return blabla;

ah,
Thanks!
edit; still not working


Re: My script loads a usage it's not supposed to load - Lucaboy28 - 25.07.2016

Quote:
PHP код:
COMMAND:v(playeridparams[]) { 
        if(!
Player[playerid][Authed] || Player[playerid][Admin] < 3) return SendClientError(playerid"You are not authorised to use this command."); 
        new 
tmp15 ], tmp215 ]; 
        if(
sscanf(params"szz"tmptmp2)) SendClientMessage(playerid, -1"{7f7f7f}Usage: {b2b2b2}/v [Create / Model / Reload / Reloadall ]"); 
        if(!
strcmp(tmp"create"true6)) 
         { 
        if(!
strlen(tmp2)) return SendClientUsage(playerid"/v create [model name / model id]"); 
        if(
GetPlayerInterior(playerid) > || GetPlayerVirtualWorld(playerid) > 0) return SendClientError(playerid"Please exit the interior you're currently in."); 
        new 
modelID
          if(!
IsNumeric(tmp2)) modelID GetVehicleModelIDFromName(tmp2); 
        else 
modelID strval(tmp2); 
        if(
modelID == -|| modelID 400 || modelID 611) return SendClientError(playerid"Model ID/Name is invalid, please try again."); 
        new 
query[500]; mysql_format(connectionquerysizeof(query), "SELECT * FROM Vehicles WHERE vActive = '0' LIMIT 1;"); mysql_tquery(connectionquery"CreateVehicle1""dd"playeridmodelID); 
        } 
        else if(!
strcmp(tmp"reload",true,6)) 
        { 
        if(!
IsPlayerInAnyVehicle(playerid)) return SendClientError(playerid"You are not in any vehicle!"); 
        
ReloadVehicle(GetPlayerVehicleID(playerid)); 
        
SendClientMessage(playerid,-1"Success: The car has been reloaded"); 
        } 
        else if(!
strcmp(tmp"reloadall",true,9)) 
        { 
        new 
query1[128]; mysql_format(connectionquery1sizeof(query1), "SELECT * FROM Vehicles WHERE vActive = '1'"); mysql_tquery(connectionquery1"reloadAllCars"); 
        
SendClientMessage(playerid,-1"Success: All cars have been reloaded."); 
        } 
        else if(!
strcmp(tmp"model"true4)) 
        { 
        if(!
IsPlayerInAnyVehicle(playerid)) return SendClientError(playerid"You are not in any vehicle!"); 
        if(!
strlen(tmp2)) return SendClientUsage(playerid"create /v create [model name / model id]"); 
        new 
tehvID
        if(!
IsNumeric(tmp2)) tehvID GetVehicleModelIDFromName(tmp2); 
        else 
tehvID strval(tmp2); 
        if(
tehvID == -|| tehvID 400 ||tehvID 611) return SendClientError(playerid"Invalid model!"); 
         
Vehicle[GetPlayerVehicleID(playerid)][vModel] = tehvID
         new 
query[500]; 
         
format(query,sizeof(query),"UPDATE Vehicles SET vModel='%i' WHERE id='%i'",tehvID,GetPlayerVehicleID(playerid)); 
         
mysql_tquery(connection,query,"",""); 
         
ReloadVehicle(GetPlayerVehicleID(playerid)); 
        new 
Float:Position[3]; 
        
GetPlayerPos(playeridPosition[0], Position[1], Position[2]); 
        
SetPlayerPos(playeridPosition[0], Position[1], Position[2]+3); 
        
SendClientMessage(playerid,-1"Success: The model has been changed"); 
        } 
        else if(!
strcmp(tmp"info"true4)) 
        { 
        new 
string[420]; 
        
format(string,sizeof(string),"%i",GetPlayerVehicleID(playerid)); 
        
SendClientMessage(playerid,-1,string); 
        } 
         
        else return 
SendClientMessage(playerid, -1"{7f7f7f}Usage: {b2b2b2}/v [soon.txt ]"); 
        return 
1

Quote:
PHP код:
else if(!strcmp(tmp"create"true6)) 
no problem man.