Store player name
#1

i want to know how can i store a player name like i have a vehicle i have did /lock on it when i do /lock it should save my name and when any other player try to enter that vehicle it should say that the vehicle is locked by that player and if i do /unlock and other player do /lock then it should store his name and when any other player try to enter it should say that locker player name so that's all i just want to store a player name and show it to others and it must be for max players not only for 1 players so please give me examples
Reply
#2

Код:
	CMD:lock( playerid, params[])
	{
		new locked, owner,  engine, lights, alarm, doors, bonnet, boot, objective, playername[MAX_PLAYER_NAME];
		
		if(locked = 0)
		{
			locked = 1;
			
			owner = playerid;
			
			SendClientMessage(playerid, -1, "Vehicle is locked");
			
			GetPlayerName( owner, playername, sizeof ( playername ) );
			
			GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
			
			SetVehicleParamsEx(vehicleid, engine, lights, alarm, VEHICLE_PARAMS_ON, bonnet, boot, objective);

		}
		
		if(locked = 1 && owner == playerid)
		{
			locked = 1;
			
			SendClientMessage(playerid, -1, "Vehicle is unlocked");
			
			GetPlayerName( playerid, playername, sizeof ( playername ) );
			
			GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
			
			SetVehicleParamsEx(vehicleid, engine, lights, alarm, VEHICLE_PARAMS_OFF, bonnet, boot, objective);
			
		}
		
		else if(locked == 1 && owner != playerid)
		{
			static string[60];
			
			format( string, sizeof ( string ), "STATUS: Vehicle is owned by %s ( %d ) and is locked!", playername, owner);
			
			SendClientMessage(playerid, -1, string);
		
		}
		
		return 1;
	}
I guess you could use it somehow . I just did it real quick. You can get a general idea of how you could work with it.
Also i am not pretty sure its correct.
Reply
#3

You could use vassilis' code, but add a global timer with the max index of MAX_VEHICLES, and use player IDs instead of names.
Reply
#4

Quote:
Originally Posted by vassilis
Посмотреть сообщение
Код:
	CMD:lock( playerid, params[])
	{
		new locked, owner,  engine, lights, alarm, doors, bonnet, boot, objective, playername[MAX_PLAYER_NAME];
		
		if(locked = 0)
		{
			locked = 1;
			
			owner = playerid;
			
			SendClientMessage(playerid, -1, "Vehicle is locked");
			
			GetPlayerName( owner, playername, sizeof ( playername ) );
			
			GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
			
			SetVehicleParamsEx(vehicleid, engine, lights, alarm, VEHICLE_PARAMS_ON, bonnet, boot, objective);

		}
		
		if(locked = 1 && owner == playerid)
		{
			locked = 1;
			
			SendClientMessage(playerid, -1, "Vehicle is unlocked");
			
			GetPlayerName( playerid, playername, sizeof ( playername ) );
			
			GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
			
			SetVehicleParamsEx(vehicleid, engine, lights, alarm, VEHICLE_PARAMS_OFF, bonnet, boot, objective);
			
		}
		
		else if(locked == 1 && owner != playerid)
		{
			static string[60];
			
			format( string, sizeof ( string ), "STATUS: Vehicle is owned by %s ( %d ) and is locked!", playername, owner);
			
			SendClientMessage(playerid, -1, string);
		
		}
		
		return 1;
	}
I guess you could use it somehow . I just did it real quick. You can get a general idea of how you could work with it.
Also i am not pretty sure its correct.
this code only showing 1 person name like i have did /lock on a vehicle then if any other player doing /lock on their vehicles then it's showing their names on my locked vehicle so now what should i have to do ?
Reply
#5

I remind you that this section isn't for requests, he decided to give you an example. That's fine, but this section still isn't for requests, it's for asking help on code you write.
Reply
#6

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
I remind you that this section isn't for requests, he decided to give you an example. That's fine, but this section still isn't for requests, it's for asking help on code you write.
i have just asked a simple code which can take up to 5 minutes to give examples but i don't think there's no one will give me examples i am confused that how can make it but a knowledge person can do it in few minutes but everyone ignoring it like i have crossed a border
Reply
#7

Quote:
Originally Posted by Ronaldo1234
Посмотреть сообщение
i have just asked a simple code which can take up to 5 minutes to give examples but i don't think there's no one will give me examples i am confused that how can make it but a knowledge person can do it in few minutes but everyone ignoring it like i have crossed a border
You're technically breaking the forum rules, this board wasn't created for people to give out code so then OPs can just paste them into gamemodes and so on.

Again, requests don't go in this board. Plus, vassilis gave you something already.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)