SA-MP Forums Archive
strcmp - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: strcmp (/showthread.php?tid=214330)



strcmp - ombre - 21.01.2011

Hi,

I want to create a command who check the car spawn and a name.

My code:

Код:
GetPlayerName(giveplayerid, gpname, MAX_PLAYER_NAME);
for(new i = 0; i < MAX_VEHICLES; iv++)
{
        printf("veh %d",i);
        if(strcmp(gpname, VehicleInfo[i][Owner], true) == 0)   // gpname is the name , VehicleInfo[i][Owner] is the owner
	{
	  	printf("check %s,%s",gpnme,VehicleInfo[i][Owner]);
                print("VEHiCLE SPAWN");
		return 1 ;
	}
}
So I'm John_Turn I spawn a car id= 1, in my log:
"veh 1"
"check John_Turn,John_Turn"
"VEHiCLE SPAWN"

Perfect but if I dont spawn a vehicle I have in my log:
"veh 1"
"check John_Turn, " nothing
"VEHiCLE SPAWN"


So if VehicleInfo[i][Owner] = my name or nothing, it say my car is spawn. This problиme is if(strcmp(gpname, VehicleInfo[i][Owner], true) == 0) Ihve tested !=1 ... but identical.

Help thanks.


Re: strcmp - silvan - 21.01.2011

check if all the variables are working well, i had similar problems which when i debugged it, it showed that the variables wasn't assigned correctly.