PDA

View Full Version : Spawn Point bug with SCRP script


benjaminjones
03/05/2016, 11:24 PM
So, I am working on this script, but I tested the spawn points. I used /fspawn due to the fact I am in a faction and tried /spawnpoint and set it to the the faction spawn, relogged and I still spawned on the last position I used to be at. Tried the same with the airport spawn, still spawned at the old position. I am sure, you all have the SCRP script, but in case you want any of the function or anything, just tell me.

Here is the OnPlayerSpawn.

public OnPlayerSpawn(playerid)
{
// Skill levels
SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL, 0);
SetPlayerSkillLevel(playerid, WEAPONSKILL_MICRO_UZI, 0);
SetPlayerSkillLevel(playerid, WEAPONSKILL_SPAS12_SHOTGUN, 0);

if (PlayerData[playerid][pHUD])
{
TextDrawShowForPlayer(playerid, gServerTextdraws[0]);
TextDrawShowForPlayer(playerid, gServerTextdraws[1]);
}
SetPlayerSkin(playerid, PlayerData[playerid][pSkin]);
Streamer_ToggleIdleUpdate(playerid, true);

PlayerData[playerid][pKilled] = 0;

if (PlayerData[playerid][pBleeding])
{
PlayerData[playerid][pBleedTime] = 1;
}
if (PlayerData[playerid][pJailTime] > 0)
{
if (PlayerData[playerid][pPrisoned])
{
SetPlayerInPrison(playerid);
}
else
{
SetPlayerPos(playerid, 197.6346, 175.3765, 1003.0234);
SetPlayerInterior(playerid, 3);

SetPlayerVirtualWorld(playerid, (playerid + 100));
SetPlayerFacingAngle(playerid, 0.0);

SetCameraBehindPlayer(playerid);
}
ResetWeapons(playerid);

PlayerTextDrawShow(playerid, PlayerData[playerid][pTextdraws][70]);
SendServerMessage(playerid, "You have %d seconds of remaining jail time.", PlayerData[playerid][pJailTime]);
}
else if (PlayerData[playerid][pHospital] != -1)
{
PlayerData[playerid][pHospitalTime] = 0;

PlayerData[playerid][pHunger] = 50;
PlayerData[playerid][pThirst] = 50;

SetPlayerInterior(playerid, 3);
SetPlayerVirtualWorld(playerid, playerid + 100);

SetPlayerPos(playerid, -211.0370, -1738.6848, 676.7153);
SetPlayerFacingAngle(playerid, 82.0000);

SetPlayerCameraPos(playerid, -214.236602, -1738.812133, 676.648132);
SetPlayerCameraLookAt(playerid, -203.072738, -1738.656127, 675.768737);

ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);

GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~n~~n~~n~~w~Recovering... 15", 1000, 3);
TogglePlayerControllable(playerid, 0);
}
else if (!PlayerData[playerid][pCreated])
{
TogglePlayerControllable(playerid, 0);
SetPlayerPos(playerid, 216.8005, -99.8691, 1005.2578);
SetPlayerFacingAngle(playerid, 90.0000);

SetPlayerInterior(playerid, 15);
SelectTextDraw(playerid, -1);

for (new i = 23; i < 34; i ++) {
PlayerTextDrawShow(playerid, PlayerData[playerid][pTextdraws][i]);
}
}
else
{
SetPlayerFacingAngle(playerid, PlayerData[playerid][pPos][3]);

SetPlayerInterior(playerid, PlayerData[playerid][pInterior]);
SetPlayerVirtualWorld(playerid, PlayerData[playerid][pWorld]);

SetCameraBehindPlayer(playerid);
SetAccessories(playerid);

if (PlayerData[playerid][pWorld] == PRISON_WORLD)
{
SetPlayerPosEx(playerid, PlayerData[playerid][pPos][0], PlayerData[playerid][pPos][1], PlayerData[playerid][pPos][2]);
}
else
{
if(PlayerData[playerid][pInjured] == 0)
{
SetPlayerPos(playerid, PlayerData[playerid][pPos][0], PlayerData[playerid][pPos][1], PlayerData[playerid][pPos][2]);
}
}
if (PlayerData[playerid][pInjured])
{
ShowHungerTextdraw(playerid, 0);

TextDrawShowForPlayer(playerid, gServerTextdraws[2]);
SendClientMessage(playerid, COLOR_LIGHTRED, "[WARNING]:{FFFFFF} You are injured and require medical attention (/call 911).");

ApplyAnimation(playerid, "CRACK", "null", 4.0, 0, 0, 0, 1, 0, 1);
ApplyAnimation(playerid, "CRACK", "crckdeth4", 4.0, 0, 0, 0, 1, 0, 1);
}
else
{
SetWeapons(playerid);
ShowHungerTextdraw(playerid, 1);

SetPlayerHealth(playerid, PlayerData[playerid][pHealth]);
SetPlayerArmour(playerid, PlayerData[playerid][pArmorStatus]);
}
}
return 1;
}

The SetDefaultSpawn stock is not used in OnPlayerSpawn, any ideas?
stock SetDefaultSpawn(playerid)
{
SetPlayerInterior(playerid, 0);
SetPlayerVirtualWorld(playerid, 0);


if(PlayerData[playerid][pSpawnPoint] == 0) // Airport
{
SetPlayerPos(playerid, 1642.1957, -2334.4849, 13.5469);
SetPlayerFacingAngle(playerid, 0.0);
}
if(PlayerData[playerid][pSpawnPoint] == 1) // Faction
{
new faction = PlayerData[playerid][pFactionID];
if(PlayerData[playerid][pFactionID] == -1)
{
SendErrorMessage(playerid, "You've been set to civilian spawn.");
SetPlayerPos(playerid, 1642.1957, -2334.4849, 13.5469);
SetPlayerFacingAngle(playerid, 0.0);
}
SetPlayerPos(playerid,FactionData[faction][SpawnX],FactionData[faction][SpawnY],FactionData[faction][SpawnZ]);
SetPlayerInterior(playerid,FactionData[faction][SpawnInterior]);
SetPlayerVirtualWorld(playerid, FactionData[faction][SpawnVW]);
}
if(PlayerData[playerid][pSpawnPoint] == 2)
{
SetPlayerPos(playerid, PlayerData[playerid][pPos][0], PlayerData[playerid][pPos][1], PlayerData[playerid][pPos][2]);
SetPlayerFacingAngle(playerid, PlayerData[playerid][pPos][3]);
SetPlayerInterior(playerid, PlayerData[playerid][pInterior]);
SetPlayerVirtualWorld(playerid, PlayerData[playerid][pWorld]);
}

/*#if SERVER_CITY == 1
SetPlayerPos(playerid, 1642.1957, -2334.4849, 13.5469);
SetPlayerFacingAngle(playerid, 0.0);
#elseif SERVER_CITY == 2
SetPlayerPos(playerid, -2425.5615, 337.5465, 37.0018);
SetPlayerFacingAngle(playerid, 238.0);
#elseif SERVER_CITY == 3
SetPlayerPos(playerid, 1675.7245, 1447.8938, 10.7866);
SetPlayerFacingAngle(playerid, 270.0);
#endif*/

SetCameraBehindPlayer(playerid);
TogglePlayerControllable(playerid, 1);
return 1;
}

benjaminjones
04/05/2016, 12:03 PM
Up, any ideas?

Nin9r
04/05/2016, 12:12 PM
What do you wanna say ? Do you want o command to change the faction spawn and it is not saving?

benjaminjones
04/05/2016, 01:55 PM
I have command which is changing the spawn point, here it is.

CMD:spawnpoint(playerid, params[])
{
new point;
if(sscanf(params, "i", point)) return SendErrorMessage(playerid, "/spawnpoint [0-2] (0 = Airport, 1 = Faction, 2 = Last logged)");
if(point == 0)
{
SendClientMessage(playerid, COLOR_WHITE, "You've changed your spawn point to airport.");
PlayerData[playerid][pSpawnPoint] = 0;
return 1;
}
if(point == 1)
{
if(PlayerData[playerid][pFactionID] == -1)
{
SendErrorMessage(playerid, "You're not apart of a faction.");
return 1;
}
SendClientMessage(playerid, COLOR_WHITE, "You've changed your spawn to faction.");
PlayerData[playerid][pSpawnPoint] = 1;
return 1;
}
if(point == 2)
{
SendClientMessage(playerid, COLOR_WHITE, "You've changed your spawn to your last logged off.");
PlayerData[playerid][pSpawnPoint] = 2;
return 1;
}
return 1;
}


Command for setting faction spawn
CMD:fspawn(playerid, params[])
{
new faction = PlayerData[playerid][pFactionID];

if (PlayerData[playerid][pFaction] == -1)
return SendErrorMessage(playerid, "You must be a faction leader.");

if (PlayerData[playerid][pFactionRank] < FactionData[PlayerData[playerid][pFaction]][factionRanks] - 5)
return SendErrorMessage(playerid, "You must be at least rank %d.", FactionData[PlayerData[playerid][pFaction]][factionRanks] - 5);
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
FactionData[faction][SpawnX] = X;
FactionData[faction][SpawnY] = Y;
FactionData[faction][SpawnZ] = Z;
FactionData[faction][SpawnInterior] = GetPlayerInterior(playerid);
FactionData[faction][SpawnVW] = GetPlayerVirtualWorld(playerid);
Faction_Save(faction);
SendClientMessage(playerid, COLOR_ORANGE, "You have changed your faction's spawn point. Faction members are now going to spawn here.");
return 1;
}

benjaminjones
06/05/2016, 01:20 PM
Bump.

Dayrion
06/05/2016, 01:36 PM
Which saving system are you using ? YINI? SQL?

GoldenLion
06/05/2016, 02:11 PM
Which saving system are you using ? YINI? SQL?
It's MySQL. http://forum.sa-mp.com/showthread.php?t=538107

benjaminjones
08/05/2016, 04:10 AM
Sorry for the late reply, Its MySQL. Anyone able to help so far?

Ritzy2K
08/05/2016, 04:13 AM
Works for me. I tried it now.

Sew_Sumi
08/05/2016, 04:55 AM
^^ If that's true, clear your database, clear the server, and start again following the tutorial.

benjaminjones
09/05/2016, 10:01 PM
Just tested [ND]xXZeusXx.'s suggestion. It is not working. Downloaded fresh new copy of the database and the gamemode, didnt work.

Ultrascipter
10/05/2016, 09:00 AM
Use SetSpawnInfo in the dialog for spawn.

Set all parameter SetSpawnInfo to 0.

Sew_Sumi
10/05/2016, 01:02 PM
I'd suggest now finding a new gamemode. You'd find a new one faster than having this fixed.

Napst34
01/07/2016, 04:57 AM
Put the lines on the OnPlayerConnect