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!