#1

Whats wrong in this code?

http://pastebin.com/sbi62rLk
Reply
#2

Why you not compile and give us error ? :P our brain not Compiler lol so this will easier for people help you
Reply
#3

Quote:
Originally Posted by colonel-top
Посмотреть сообщение
Why you not compile and give us error ? :P our brain not Compiler lol so this will easier for people help you
No errors, I think its something wrong with returns the comand doensen't work in the last lines i think the mistake is this codes but im not sure

cmd2 = strtok(params, scelta2);
if (!strlen(cmd2))
{
SendClientMessage(playerid,COLORE_ROSSO, "Use: /Createpv [playerid] [vehicleid] [vehiclecolor].");
}
lvla2 = strval(cmd2);
if(lvla2 < 0 || lvla2 > 255)
{
SendClientMessage(playerid,COLORE_ROSSO, "ERROR: Invald vehicle color.");
return 1;
}
Reply
#4

help me pls!
Reply
#5

in this case http://pastebin.com/cCpW5fQK
i write corect cmd and it send me all times the car color its wrong
Reply
#6

Compile the script And Reply the Error ! And The line of errors !!, If you want We Help
Reply
#7

Quote:
Originally Posted by Amunra
Посмотреть сообщение
Compile the script And Reply the Error ! And The line of errors !!, If you want We Help
He says there are no errors, read the whole script and you can see the mistakes.

I have seen a few of them, don't have enough time to check them all out though. Here is my assumptions of how it should work;

pawn Код:
dcmd_Createpv(playerid, params[])
{
     new cmd[256],id, lvla, scelta, lvla2, cmd2[256], scelta2;
     //if(PlayerInfo[playerid][gangid] ==0) return SendClientMessage(playerid,COLORE_ROSSO,"ERROR:You are not in any gang.");
     cmd = strtok(params, scelta);
     cmd2 = strtok(params, scelta2);
     if (!strlen(cmd))return SendClientMessage(playerid,COLORE_ROSSO, "Use: /Createpv [playerid] [vehicleid] [vehiclecolor].");
     if (!strlen(cmd2))return SendClientMessage(playerid,COLORE_ROSSO, "Use: /Createpv [playerid] [vehicleid] [vehiclecolor].");
     //if (!strlen(cmd2))return SendClientMessage(playerid,COLORE_ROSSO, "Use: /Createpv [playerid] [vehicleid] [vehiclecolor].");
     id = strval(cmd);
     id = strval(cmd2);
     if(!IsPlayerConnected(id))
     {
     SendClientMessage(playerid,COLORE_ROSSO, "ERROR:The player is not connect.");
     } // I've removed return 1 because it was completely unnecessary and wrong, you don't need to put return 1 after each if statement.
         else // I've put an else here, seeing as there were no callbacks to be called here.
     {
     cmd = strtok(params, scelta);
     if (!strlen(cmd))
     {
     SendClientMessage(playerid,COLORE_ROSSO, "Use: /Createpv [playerid] [vehicleid] [vehiclecolor].");
     }
     lvla = strval(cmd);
     if(lvla < 400 || lvla > 611)
     {
     SendClientMessage(playerid,COLORE_ROSSO, "ERROR: Invald vehicle id.");
     }
     
     
     cmd2 = strtok(params, scelta2);
     if (!strlen(cmd2))
     {
     SendClientMessage(playerid,COLORE_ROSSO, "Use: /Createpv [playerid] [vehicleid] [vehiclecolor].");
     }
     lvla2 = strval(cmd2);
     if(lvla2 < 0 || lvla2 > 255)
     {
     SendClientMessage(playerid,COLORE_ROSSO, "ERROR: Invald vehicle color.");
     }
     PlayerInfo[id][PrivateCar] = lvla;
     PlayerInfo[id][CarColor] = lvla2;
     SendClientMessage(playerid,COLORE_VERDE,"Successfully.");
     }
     return 1;
}
This should work like a charm if you haven't done any other script mistakes, if it doesn't then i will look for your script mistakes, you'll have to tell me what exactly you want this script to do though.
Reply
#8

This is a reason why you use indentation...
Reply
#9

Quote:
Originally Posted by Rufio
Посмотреть сообщение
He says there are no errors, read the whole script and you can see the mistakes.

I have seen a few of them, don't have enough time to check them all out though. Here is my assumptions of how it should work;

pawn Код:
dcmd_Createpv(playerid, params[])
{
     new cmd[256],id, lvla, scelta, lvla2, cmd2[256], scelta2;
     //if(PlayerInfo[playerid][gangid] ==0) return SendClientMessage(playerid,COLORE_ROSSO,"ERROR:You are not in any gang.");
     cmd = strtok(params, scelta);
     cmd2 = strtok(params, scelta2);
     if (!strlen(cmd))return SendClientMessage(playerid,COLORE_ROSSO, "Use: /Createpv [playerid] [vehicleid] [vehiclecolor].");
     if (!strlen(cmd2))return SendClientMessage(playerid,COLORE_ROSSO, "Use: /Createpv [playerid] [vehicleid] [vehiclecolor].");
     //if (!strlen(cmd2))return SendClientMessage(playerid,COLORE_ROSSO, "Use: /Createpv [playerid] [vehicleid] [vehiclecolor].");
     id = strval(cmd);
     id = strval(cmd2);
     if(!IsPlayerConnected(id))
     {
     SendClientMessage(playerid,COLORE_ROSSO, "ERROR:The player is not connect.");
     } // I've removed return 1 because it was completely unnecessary and wrong, you don't need to put return 1 after each if statement.
         else // I've put an else here, seeing as there were no callbacks to be called here.
     {
     cmd = strtok(params, scelta);
     if (!strlen(cmd))
     {
     SendClientMessage(playerid,COLORE_ROSSO, "Use: /Createpv [playerid] [vehicleid] [vehiclecolor].");
     }
     lvla = strval(cmd);
     if(lvla < 400 || lvla > 611)
     {
     SendClientMessage(playerid,COLORE_ROSSO, "ERROR: Invald vehicle id.");
     }
     
     
     cmd2 = strtok(params, scelta2);
     if (!strlen(cmd2))
     {
     SendClientMessage(playerid,COLORE_ROSSO, "Use: /Createpv [playerid] [vehicleid] [vehiclecolor].");
     }
     lvla2 = strval(cmd2);
     if(lvla2 < 0 || lvla2 > 255)
     {
     SendClientMessage(playerid,COLORE_ROSSO, "ERROR: Invald vehicle color.");
     }
     PlayerInfo[id][PrivateCar] = lvla;
     PlayerInfo[id][CarColor] = lvla2;
     SendClientMessage(playerid,COLORE_VERDE,"Successfully.");
     }
     return 1;
}
This should work like a charm if you haven't done any other script mistakes, if it doesn't then i will look for your script mistakes, you'll have to tell me what exactly you want this script to do though.
If i type /createpv [id] [carid] and not [carcolor] the cmd send this message
[13:07:23] ERROR: Invald vehicle color.
[13:07:23] Successfully.

If i type /createpv [id] and not [carid] [carcolor] the cmd send this message

[13:07:05] Use: /Createpv [playerid] [vehicleid] [vehiclecolor].
[13:07:05] ERROR: Invald vehicle id.
[13:07:05] Use: /Createpv [playerid] [vehicleid] [vehiclecolor].
[13:07:05] Successfully.

If i type /createpv [id] [carid] [carcolor] with all correct, the cmd send this message

[13:07:29] ERROR: Invald vehicle color.
[13:07:29] Successfully.
And wrong to set carcolor, it always set to 0 like if i don't put the carcolor
Reply
#10

pawn Код:
dcmd_Createpv(playerid, params[])
{
    new cmd[256],id, lvla, scelta, lvla2, cmd2[256], scelta2;
    //if(PlayerInfo[playerid][gangid] ==0) return SendClientMessage(playerid,COLORE_ROSSO,"ERROR:You are not in any gang.");
    cmd = strtok(params, scelta);
    cmd2 = strtok(params, scelta2);
    if (!strlen(cmd))return SendClientMessage(playerid,COLORE_ROSSO, "Use: /Createpv [playerid] [vehicleid] [vehiclecolor].");
    if (!strlen(cmd2))return SendClientMessage(playerid,COLORE_ROSSO, "Use: /Createpv [playerid] [vehicleid] [vehiclecolor].");
    //if (!strlen(cmd2))return SendClientMessage(playerid,COLORE_ROSSO, "Use: /Createpv [playerid] [vehicleid] [vehiclecolor].");
    id = strval(cmd);
    id = strval(cmd2);
    if(!IsPlayerConnected(id))
    {
        return SendClientMessage(playerid,COLORE_ROSSO, "ERROR:The player is not connect.");
    } // I've removed return 1 because it was completely unnecessary and wrong, you don't need to put return 1 after each if statement.
    else // I've put an else here, seeing as there were no callbacks to be called here.
    {
        cmd = strtok(params, scelta);
        if (!strlen(cmd))
        {
            return SendClientMessage(playerid,COLORE_ROSSO, "Use: /Createpv [playerid] [vehicleid] [vehiclecolor].");
        }
        lvla = strval(cmd);
        if(lvla < 400 || lvla > 611)
        {
            return SendClientMessage(playerid,COLORE_ROSSO, "ERROR: Invald vehicle id.");
        }


        cmd2 = strtok(params, scelta2);
        if (!strlen(cmd2))
        {
            return SendClientMessage(playerid,COLORE_ROSSO, "Use: /Createpv [playerid] [vehicleid] [vehiclecolor].");
        }
        lvla2 = strval(cmd2);
        if(lvla2 < 0 || lvla2 > 255)
        {
            return SendClientMessage(playerid,COLORE_ROSSO, "ERROR: Invald vehicle color.");
        }
        PlayerInfo[id][PrivateCar] = lvla;
        PlayerInfo[id][CarColor] = lvla2;
        SendClientMessage(playerid,COLORE_VERDE,"Successfu lly.");
    }
    return 1;
}
I added "return" before error messages (return is for give the function and then stop the function, so, when gives error, it stop the function)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)