• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[HELP] Changing the skin when OnPlayerConnect
#2
(2021-04-10, 02:31 PM)romanstti Wrote: ...

There is a couple of things that I think is wrong with your code:

- I think you only need the "return 1" at the end of the public function.

- GetPlayerName it's being used wrong. You should create a variable and store in it the Skin ID of the player:
https://open.mp/docs/scripting/functions/GetPlayerName (here is how to use it).

PHP Code:
new name[MAX_PLAYER_NAME  1];

GetPlayerName(playeridnamesizeof(name));

if (
name == "Luna_Beaule") {
SetPlayerSkin(playerid20003);


- OnPlayerConnect is called when a player connects to the server, so you can't change their skin because the player is not in the game yet.
You probably should use this code in OnPlayerSpawn:

PHP Code:
new name[MAX_PLAYER_NAME  1];

GetPlayerName(playeridnamesizeof(name));

if (
name == "Luna_Beaule") {
SetPlayerSkin(playerid20003);


instead of:

PHP Code:
if (GetPlayerName(playeridname) == Luna_Beaule) return SetPlayerSkin(playerid20003); 

I mean the logic it's good, but you need to change how you use GetPlayerName and where you are using SetPlayerSkin. You can't change the player's skin if the player is not spawned in the game before.

- Luna_Beaule needs to go between quotation marks: "Luna_Beaule"

Full code should be:

PHP Code:
public OnPlayerConnect(playerid) {
SendClientMessage (playerid, -1"Servidor oficial de pruebas.");
  return 
1;
}

public 
OnPlayerSpawn(playerid) {
? new 
name[MAX_PLAYER_NAME  1];

GetPlayerName(playeridnamesizeof(name));

? if (
name == "Luna_Beaule") {
??? 
SetPlayerSkin(playerid20003);
  }

  return 
1;


I hope this helps to you, regards!
  Reply


Messages In This Thread
RE: [HELP] Changing the skin when OnPlayerConnect - by robertocaribbean - 2021-04-10, 04:00 PM

Forum Jump: