Burgershot
  • Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Burgershot General Programming [HELP] Changing the skin when OnPlayerConnect

 
  • 0 Vote(s) - 0 Average
[HELP] Changing the skin when OnPlayerConnect
robertocaribbean
Offline

Burgershot Member
Posts: 27
Threads: 8
Joined: Aug 2020
Reputation: 0
Location: Argentina
#2
2021-04-10, 04:00 PM (This post was last modified: 2021-04-10, 06:53 PM by robertocaribbean.)
(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(playerid, name, sizeof(name));

if (
name == "Luna_Beaule") {
  SetPlayerSkin(playerid, 20003);
} 

- 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(playerid, name, sizeof(name));

if (
name == "Luna_Beaule") {
  SetPlayerSkin(playerid, 20003);
} 

instead of:

PHP Code:
if (GetPlayerName(playerid, name) == Luna_Beaule) return SetPlayerSkin(playerid, 20003); 

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(playerid, name, sizeof(name));

  if (name == "Luna_Beaule") {
    SetPlayerSkin(playerid, 20003);
  }

  return 
1;
} 

I hope this helps to you, regards!
« Next Oldest | Next Newest »



Messages In This Thread
[HELP] Changing the skin when OnPlayerConnect - by romanstti - 2021-04-10, 02:31 PM
RE: [HELP] Changing the skin when OnPlayerConnect - by robertocaribbean - 2021-04-10, 04:00 PM
RE: [HELP] Changing the skin when OnPlayerConnect - by ImOver - 2021-04-15, 12:45 PM
RE: [HELP] Changing the skin when OnPlayerConnect - by Snow - 2021-04-10, 06:51 PM

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Burgershot - Powered by our Community and MyBB Original Theme by Emerald

Linear Mode
Threaded Mode