Carcolor
#1

Hi, i've this code:
Код:
	if(strcmp(cmd, "/culoaremasina", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
	        	if(PlayerData[playerid][pPcarkey] == 999)
	        	{
	            	SendClientMessage(playerid, COLOR_GREY,"Nu ai o masina personala.");
	            	return 1;
	        	}
	        	if(GetPlayerCash(playerid) < 1000)
	        	{
	            	SendClientMessage(playerid, COLOR_GREY," Nu ai destui bani la tine.");
	            	return 1;
	        	}
	        	tmp = strtok(cmdtext, idx);
	        	if(!strlen(tmp))
				{
					SendUsage(playerid,"/culoaremasina [ID culoare 1] [ID culoare 2]");
					return 1;
				}
				new color1;
				color1 = strval(tmp);
				if(color1 < 0 && color1 > 126)
				{
			    	SendClientMessage(playerid, COLOR_GREY, "Id-ul culorii trebuie sa fie cuprins intre 0 si 126!");
			    	return 1;
				}
				tmp = strtok(cmdtext, idx);
	        	if(!strlen(tmp))
				{
					SendUsage(playerid,"/culoaremasina [ID culoare 1] [ID culoare 2]");
					return 1;
				}
				new color2;
				color2 = strval(tmp);
				if(color2 < 0 && color2 > 126)
				{
			    	SendClientMessage(playerid, COLOR_GREY, "ID-ul culorii trebuie sa fie cuprins intre 0 si 126!");
			    	return 1;
				}

				new vehid;
				if(GetPlayerVehicleID(playerid) == PlayerData[playerid][pPcarkey]+PreVehicle)
				{
					vehid = PlayerData[playerid][pPcarkey];
				}
				else { return 1; }

	        	if(IsPlayerInVehicle(playerid, vehid+PreVehicle))
	        	{
         			CarData[vehid][cColorOne] = color1;
	                CarData[vehid][cColorTwo] = color2;
	                GivePlayerCash(playerid, -1000);
	                GameTextForPlayer(playerid, "~w~Costul vopsiri~n~~r~-$1000", 5000, 1);
	                ChangeVehicleColor(vehid+PreVehicle, color1, color2);
	                new query[MAX_STRING];
	                format(query, sizeof(query), "UPDATE cars SET ColorOne='%d' WHERE id=%d", CarData[vehid][cColorOne], vehid);
					mysql_query(query);
					format(query, sizeof(query), "UPDATE cars SET ColorTwo='%d' WHERE id=%d", CarData[vehid][cColorTwo], vehid);
					mysql_query(query);
					return 1;
    			}
	        	else
	        	{
	            	SendClientMessage(playerid, COLOR_GREY,"Nu esti in masina.");
	            	return 1;
	        	}

     	}
		return 1;
	}
So.... i can have color up to 126...
Why this don't work?
Reply
#2

so try:

pawn Код:
if(strcmp(cmd, "/culoaremasina", true) == 0)
{

    if(IsPlayerConnected(playerid))
    {

        if(PlayerData[playerid][pPcarkey] == 999)
        {

            SendClientMessage(playerid, COLOR_GREY,"Nu ai o masina personala.");
            return 1;
        }
        if(GetPlayerCash(playerid) < 1000)
        {

            SendClientMessage(playerid, COLOR_GREY," Nu ai destui bani la tine.");
            return 1;
        }
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {

            SendUsage(playerid,"/culoaremasina [ID culoare 1] [ID culoare 2]");
            return 1;
        }
        new color1;
        color1 = strval(tmp);
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {

            SendUsage(playerid,"/culoaremasina [ID culoare 1] [ID culoare 2]");
            return 1;
        }
        new color2;
        color2 = strval(tmp);
        if(color2 < 0 && color2 > 126)
        {

            SendClientMessage(playerid, COLOR_GREY, "ID-ul culorii trebuie sa fie cuprins intre 0 si 126!");
            return 1;
        }

        new vehid;
        if(GetPlayerVehicleID(playerid) == PlayerData[playerid][pPcarkey]+PreVehicle)
        {

            vehid = PlayerData[playerid][pPcarkey];
        }
        else { return 1; }

        if(IsPlayerInVehicle(playerid, vehid+PreVehicle))
        {

            CarData[vehid][cColorOne] = color1;
            CarData[vehid][cColorTwo] = color2;
            GivePlayerCash(playerid, -1000);
            GameTextForPlayer(playerid, "~w~Costul vopsiri~n~~r~-$1000", 5000, 1);
            ChangeVehicleColor(vehid+PreVehicle, color1, color2);
            new query[MAX_STRING];
            format(query, sizeof(query), "UPDATE cars SET ColorOne='%d' WHERE id=%d", CarData[vehid][cColorOne], vehid);
            mysql_query(query);
            format(query, sizeof(query), "UPDATE cars SET ColorTwo='%d' WHERE id=%d", CarData[vehid][cColorTwo], vehid);
            mysql_query(query);
            return 1;
        }
        else
        {

            SendClientMessage(playerid, COLOR_GREY,"Nu esti in masina.");
            return 1;
        }

    }
    return 1;
}
Reply
#3

Quote:
Originally Posted by FallweN
Посмотреть сообщение
so try:

pawn Код:
if(strcmp(cmd, "/culoaremasina", true) == 0)
{

    if(IsPlayerConnected(playerid))
    {

        if(PlayerData[playerid][pPcarkey] == 999)
        {

            SendClientMessage(playerid, COLOR_GREY,"Nu ai o masina personala.");
            return 1;
        }
        if(GetPlayerCash(playerid) < 1000)
        {

            SendClientMessage(playerid, COLOR_GREY," Nu ai destui bani la tine.");
            return 1;
        }
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {

            SendUsage(playerid,"/culoaremasina [ID culoare 1] [ID culoare 2]");
            return 1;
        }
        new color1;
        color1 = strval(tmp);
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {

            SendUsage(playerid,"/culoaremasina [ID culoare 1] [ID culoare 2]");
            return 1;
        }
        new color2;
        color2 = strval(tmp);
        if(color2 < 0 && color2 > 126)
        {

            SendClientMessage(playerid, COLOR_GREY, "ID-ul culorii trebuie sa fie cuprins intre 0 si 126!");
            return 1;
        }

        new vehid;
        if(GetPlayerVehicleID(playerid) == PlayerData[playerid][pPcarkey]+PreVehicle)
        {

            vehid = PlayerData[playerid][pPcarkey];
        }
        else { return 1; }

        if(IsPlayerInVehicle(playerid, vehid+PreVehicle))
        {

            CarData[vehid][cColorOne] = color1;
            CarData[vehid][cColorTwo] = color2;
            GivePlayerCash(playerid, -1000);
            GameTextForPlayer(playerid, "~w~Costul vopsiri~n~~r~-$1000", 5000, 1);
            ChangeVehicleColor(vehid+PreVehicle, color1, color2);
            new query[MAX_STRING];
            format(query, sizeof(query), "UPDATE cars SET ColorOne='%d' WHERE id=%d", CarData[vehid][cColorOne], vehid);
            mysql_query(query);
            format(query, sizeof(query), "UPDATE cars SET ColorTwo='%d' WHERE id=%d", CarData[vehid][cColorTwo], vehid);
            mysql_query(query);
            return 1;
        }
        else
        {

            SendClientMessage(playerid, COLOR_GREY,"Nu esti in masina.");
            return 1;
        }

    }
    return 1;
}
Don't work! No-error, no color changing!
Reply
#4

Show us the errors you got.
Reply
#5

No-errors i said, but the color won't change!
Reply
#6

So, the color won't change eh?

why don't you just print what
vehid+PreVehicle, color1 and color2 are holding?

what's this preVehicle anyways?
you might've fucked up there...
like the id of the vehicle which'll get it's color changed ain't the one the player is inside.

So just add some printf's and see what exactly your code is doing.
You'll see where you fucked up like this, it's called debugging


just in case you don't know how to do this:
PHP код:
if(strcmp(cmd"/culoaremasina"true) == 0)
    {
        if(
IsPlayerConnected(playerid))
        {
                if(
PlayerData[playerid][pPcarkey] == 999)
                {
                    
SendClientMessage(playeridCOLOR_GREY,"Nu ai o masina personala.");
                    return 
1;
                }
                if(
GetPlayerCash(playerid) < 1000)
                {
                    
SendClientMessage(playeridCOLOR_GREY," Nu ai destui bani la tine.");
                    return 
1;
                }
                
tmp strtok(cmdtextidx);
                if(!
strlen(tmp))
                {
                    
SendUsage(playerid,"/culoaremasina [ID culoare 1] [ID culoare 2]");
                    return 
1;
                }
                new 
color1;
                
color1 strval(tmp);
                if(
color1 && color1 126)
                {
                    
SendClientMessage(playeridCOLOR_GREY"Id-ul culorii trebuie sa fie cuprins intre 0 si 126!");
                    return 
1;
                }
                
tmp strtok(cmdtextidx);
                if(!
strlen(tmp))
                {
                    
SendUsage(playerid,"/culoaremasina [ID culoare 1] [ID culoare 2]");
                    return 
1;
                }
                new 
color2;
                
color2 strval(tmp);
                if(
color2 && color2 126)
                {
                    
SendClientMessage(playeridCOLOR_GREY"ID-ul culorii trebuie sa fie cuprins intre 0 si 126!");
                    return 
1;
                }
                new 
vehid;
                if(
GetPlayerVehicleID(playerid) == PlayerData[playerid][pPcarkey]+PreVehicle)
                {
                    
vehid PlayerData[playerid][pPcarkey];
                }
                else { return 
1; }
                if(
IsPlayerInVehicle(playeridvehid+PreVehicle))
                {
                    
printf("IsInMainControlStructure with veh-ID: %d",vehid+PreVehicle);//////setp1
                     
CarData[vehid][cColorOne] = color1;
                    
CarData[vehid][cColorTwo] = color2;
                    
GivePlayerCash(playerid, -1000);
                    
GameTextForPlayer(playerid"~w~Costul vopsiri~n~~r~-$1000"50001);
                    
ChangeVehicleColor(vehid+PreVehiclecolor1color2);
                    
printf("Vehicle-ID %d got it's color changed to: %d and %d",vehid+PreVehiclecolor1color2);//////step2
                    
new query[MAX_STRING];
                    
format(querysizeof(query), "UPDATE cars SET ColorOne='%d' WHERE id=%d"CarData[vehid][cColorOne], vehid);
                    
mysql_query(query);
                    
format(querysizeof(query), "UPDATE cars SET ColorTwo='%d' WHERE id=%d"CarData[vehid][cColorTwo], vehid);
                    
mysql_query(query);
                    return 
1;
                }
                else
                {
                    
SendClientMessage(playeridCOLOR_GREY,"Nu esti in masina.");
                    return 
1;
                }
         }
        return 
1;
    } 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)