string enum printing problem
#1

Whenever I print an enum string variable, it does only show the first letter of the string.
This is my code.
Код:
	new rand = random(sizeof(mLocations[]));
	pInfo[playerid][LocIDName1] = mLocations[rand][Name];
    rand = random(sizeof(mLocations[]));
	pInfo[playerid][LocIDName2] = mLocations[rand][Name];
	format(string, sizeof(string), ""COL_YELLOW"WORK:"COL_WHITE" Deliver supplies from "COL_YELLOW"%s"COL_WHITE" to "COL_YELLOW"%s"COL_WHITE".",pInfo[playerid][LocIDName1],pInfo[playerid][LocIDName2]);
	SendClientMessage(playerid, -1, string);
	SendClientMessage(playerid, -1, ""COL_YELLOW"WORK:"COL_WHITE" You can always stop work using /stopwork.");
Reply
#2

how you declared variable string ?? show its size
Reply
#3

Код:
enum PlayerVariables
{
	LocIDName1[128],
	LocIDName2[128]
};
new pInfo[MAX_PLAYERS][PlayerVariables];
Код:
enum MissionLocations
{
	Name[128],
	Float:X,
	Float:Y,
	Float:Z
};
new mLocations[][MissionLocations] =
{
	{"LS Construction Site", 1859.0, -1314.0, 14.0},
   	{"SF Construction Site", -2083.0, 209.0, 35.5},
	{"LV Construction Site", 2708.0, 878.0, 10.0}
};
Reply
#4

Show us the full code, not just a part of it. Tell us the size of "string", and pInfo[playerid][LocIDName1] and pInnfo[playerid][LocIDName2].

EDIT: Late post, but anyway - WHAT's the size of "string" variable?
Reply
#5

Код:
CMD:work(playerid, params[])
{
	new vid = GetPlayerVehicleID(playerid), string[128];
	if(pInfo[playerid][InWork] == true) return SendClientMessage(playerid, -1, ""COL_GRAY"You are still in the middle of a work!:");
	//if(GetVehicleModel(vid) != 403 || GetVehicleModel(vid) != 515 || GetVehicleModel(vid) != 514) return SendClientMessage(playerid, -1, ""COL_GRAY"You must be in a truck to start working!");
	if(!IsTrailerAttachedToVehicle(vid)) return SendClientMessage(playerid, -1, ""COL_GRAY"You need to have a trailer attached to your vehicle to start working!");
	new rand = random(sizeof(mLocations[]));
	format(pInfo[playerid][LocIDName1], sizeof(pInfo[playerid][LocIDName1]), "%s", mLocations[rand][Name]);
    pInfo[playerid][X1] = mLocations[rand][X];
    pInfo[playerid][Y1] = mLocations[rand][Y];
    pInfo[playerid][Z1] = mLocations[rand][Z];
    rand = random(sizeof(mLocations[]));
	format(pInfo[playerid][LocIDName2], sizeof(pInfo[playerid][LocIDName2]), "%s", mLocations[rand][Name]);
    pInfo[playerid][X2] = mLocations[rand][X];
    pInfo[playerid][Y2] = mLocations[rand][Y];
    pInfo[playerid][Z2] = mLocations[rand][Z];
	format(string, sizeof(string), ""COL_YELLOW"WORK:"COL_WHITE" Deliver supplies from "COL_YELLOW"%s"COL_WHITE" to "COL_YELLOW"%s"COL_WHITE".",pInfo[playerid][LocIDName1],pInfo[playerid][LocIDName2]);
	SendClientMessage(playerid, -1, string);
	SendClientMessage(playerid, -1, ""COL_YELLOW"WORK:"COL_WHITE" You can always stop work using /stopwork.");
	SetPlayerCheckpoint(playerid, pInfo[playerid][X1], pInfo[playerid][Y1], pInfo[playerid][Z1], 7);
	pInfo[playerid][VehicleID] = vid;
	pInfo[playerid][VehicleTrailerID] = GetVehicleTrailer(vid);
	pInfo[playerid][InWork] = true;
	return 1;
}
EDIT: String size is 128.
Reply
#6

pawn Код:
CMD:work(playerid, params[])
{
    new vid = GetPlayerVehicleID(playerid), string[512];
    if(pInfo[playerid][InWork] == true) return SendClientMessage(playerid, -1, ""COL_GRAY"You are still in the middle of a work!:");
    //if(GetVehicleModel(vid) != 403 || GetVehicleModel(vid) != 515 || GetVehicleModel(vid) != 514) return SendClientMessage(playerid, -1, ""COL_GRAY"You must be in a truck to start working!");
    if(!IsTrailerAttachedToVehicle(vid)) return SendClientMessage(playerid, -1, ""COL_GRAY"You need to have a trailer attached to your vehicle to start working!");
    new rand = random(sizeof(mLocations[]));
    format(pInfo[playerid][LocIDName1], sizeof(pInfo[playerid][LocIDName1]), "%s", mLocations[rand][Name]);
        pInfo[playerid][X1] = mLocations[rand][X];
        pInfo[playerid][Y1] = mLocations[rand][Y];
        pInfo[playerid][Z1] = mLocations[rand][Z];
        rand = random(sizeof(mLocations[]));
    format(pInfo[playerid][LocIDName2], sizeof(pInfo[playerid][LocIDName2]), "%s", mLocations[rand][Name]);
    pInfo[playerid][X2] = mLocations[rand][X];
        pInfo[playerid][Y2] = mLocations[rand][Y];
        pInfo[playerid][Z2] = mLocations[rand][Z];
    format(string, sizeof(string), ""COL_YELLOW"WORK:"COL_WHITE" Deliver supplies from "COL_YELLOW"%s"COL_WHITE" to "COL_YELLOW"%s"COL_WHITE".",pInfo[playerid][LocIDName1],pInfo[playerid][LocIDName2]);
    SendClientMessage(playerid, -1, string);
    SendClientMessage(playerid, -1, ""COL_YELLOW"WORK:"COL_WHITE" You can always stop work using /stopwork.");
    SetPlayerCheckpoint(playerid, pInfo[playerid][X1], pInfo[playerid][Y1], pInfo[playerid][Z1], 7);
    pInfo[playerid][VehicleID] = vid;
    pInfo[playerid][VehicleTrailerID] = GetVehicleTrailer(vid);
    pInfo[playerid][InWork] = true;
    return 1;
}
Just increased the string size to 512.
Reply
#7

I'm not even sure if these people that try to help know pawn at all.
problem is here

pInfo[playerid][LocIDName2] = mLocations[rand][Name];
This doesn't copy strings into eachother, just the first letter, there are strcat, memcpy and strcpy for this job.
Reply
#8

After increasing the size, the output is still the same.

EDIT:Oh, yes, I forgot those functions. Let me update the thread after I've done those functions.
Reply
#9

Quote:
Originally Posted by PrO.GameR
Посмотреть сообщение
I'm not even sure if these people that try to help know pawn at all.
problem is here

pInfo[playerid][LocIDName2] = mLocations[rand][Name];
This doesn't copy strings into eachother, just the first letter, there are strcat, memcpy and strcpy for this job.
Hey brother, the post he made before I asked the full code was probably a rough one. Look at the full command code he has posted. You seem to be a blind. Don't just jump into conclusion just be seeing the last post.
Reply
#10

UPDATE:
strcat - outcome: Deliver supplies from to .
Код:
CMD:work(playerid, params[])
{
	new vid = GetPlayerVehicleID(playerid), string[512];
	if(pInfo[playerid][InWork] == true) return SendClientMessage(playerid, -1, ""COL_GRAY"You are still in the middle of a work!:");
	//if(GetVehicleModel(vid) != 403 || GetVehicleModel(vid) != 515 || GetVehicleModel(vid) != 514) return SendClientMessage(playerid, -1, ""COL_GRAY"You must be in a truck to start working!");
	if(!IsTrailerAttachedToVehicle(vid)) return SendClientMessage(playerid, -1, ""COL_GRAY"You need to have a trailer attached to your vehicle to start working!");
	new rand = random(sizeof(mLocations[]));
	strcat(pInfo[playerid][LocIDName1], mLocations[rand][Name]);
    pInfo[playerid][X1] = mLocations[rand][X];
    pInfo[playerid][Y1] = mLocations[rand][Y];
    pInfo[playerid][Z1] = mLocations[rand][Z];
    rand = random(sizeof(mLocations[]));
	strcat(pInfo[playerid][LocIDName2], mLocations[rand][Name]);
    pInfo[playerid][X2] = mLocations[rand][X];
    pInfo[playerid][Y2] = mLocations[rand][Y];
    pInfo[playerid][Z2] = mLocations[rand][Z];
	format(string, sizeof(string), ""COL_YELLOW"WORK:"COL_WHITE" Deliver supplies from "COL_YELLOW"%s"COL_WHITE" to "COL_YELLOW"%s"COL_WHITE".",pInfo[playerid][LocIDName1],pInfo[playerid][LocIDName2]);
	SendClientMessage(playerid, -1, string);
	SendClientMessage(playerid, -1, ""COL_YELLOW"WORK:"COL_WHITE" You can always stop work using /stopwork.");
	SetPlayerCheckpoint(playerid, pInfo[playerid][X1], pInfo[playerid][Y1], pInfo[playerid][Z1], 7);
	pInfo[playerid][VehicleID] = vid;
	pInfo[playerid][VehicleTrailerID] = GetVehicleTrailer(vid);
	pInfo[playerid][InWork] = true;
	return 1;
}
strcpy - outcome: SERVER: Unknown command.
Код:
CMD:work(playerid, params[])
{
	new vid = GetPlayerVehicleID(playerid), string[512];
	if(pInfo[playerid][InWork] == true) return SendClientMessage(playerid, -1, ""COL_GRAY"You are still in the middle of a work!:");
	//if(GetVehicleModel(vid) != 403 || GetVehicleModel(vid) != 515 || GetVehicleModel(vid) != 514) return SendClientMessage(playerid, -1, ""COL_GRAY"You must be in a truck to start working!");
	if(!IsTrailerAttachedToVehicle(vid)) return SendClientMessage(playerid, -1, ""COL_GRAY"You need to have a trailer attached to your vehicle to start working!");
	new rand = random(sizeof(mLocations[]));
	strcpy(pInfo[playerid][LocIDName1], mLocations[rand][Name]);
    pInfo[playerid][X1] = mLocations[rand][X];
    pInfo[playerid][Y1] = mLocations[rand][Y];
    pInfo[playerid][Z1] = mLocations[rand][Z];
    rand = random(sizeof(mLocations[]));
	strcpy(pInfo[playerid][LocIDName2], mLocations[rand][Name]);
    pInfo[playerid][X2] = mLocations[rand][X];
    pInfo[playerid][Y2] = mLocations[rand][Y];
    pInfo[playerid][Z2] = mLocations[rand][Z];
	format(string, sizeof(string), ""COL_YELLOW"WORK:"COL_WHITE" Deliver supplies from "COL_YELLOW"%s"COL_WHITE" to "COL_YELLOW"%s"COL_WHITE".",pInfo[playerid][LocIDName1],pInfo[playerid][LocIDName2]);
	SendClientMessage(playerid, -1, string);
	SendClientMessage(playerid, -1, ""COL_YELLOW"WORK:"COL_WHITE" You can always stop work using /stopwork.");
	SetPlayerCheckpoint(playerid, pInfo[playerid][X1], pInfo[playerid][Y1], pInfo[playerid][Z1], 7);
	pInfo[playerid][VehicleID] = vid;
	pInfo[playerid][VehicleTrailerID] = GetVehicleTrailer(vid);
	pInfo[playerid][InWork] = true;
	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)