2013-12-08 122 views
1

当我运行我的游戏模式时,玩家应该在OnPlayerSpawn中给出的坐标处产卵。它的作品非常完美,但是在按下“Spawn”按钮后,屏幕闪烁,显示我的播放器在默认的坐标位置(带有电梯的小地方),然后产生到正确的位置。我该如何解决这个问题?玩家产卵错误

到目前为止尝试了一切。 http://forum.sa-mp.com/showthread.php?t=480083

public OnGameModeInit() 
{ 
    SetGameModeText("Closed Beta"); 
    AddPlayerClass(210, 1958.3783, 1343.1572, 15.3746, 269.1425, 24, 123123, 25, 123123, 34, 123123); 
    AddPlayerClass(230, 1958.3783, 1343.1572, 15.3746, 269.1425, 24, 123123, 25, 123123, 34, 123123); 
    AddPlayerClass(38, 1958.3783, 1343.1572, 15.3746, 269.1425, 24, 123123, 25, 123123, 34, 123123); 
    AddPlayerClass(53, 1958.3783, 1343.1572, 15.3746, 269.1425, 24, 123123, 25, 123123, 34, 123123); 
    AddPlayerClass(134, 1958.3783, 1343.1572, 15.3746, 269.1425, 24, 123123, 25, 123123, 34, 123123); 
    AddPlayerClass(170, 1958.3783, 1343.1572, 15.3746, 269.1425, 24, 123123, 25, 123123, 34, 123123); 
    AddPlayerClass(177, 1958.3783, 1343.1572, 15.3746, 269.1425, 24, 123123, 25, 123123, 34, 123123); 

    //Create some nrg's 
    AddStaticVehicle(522,1293.4578,-831.7721,82.7060,2.2115,8,164); 
    AddStaticVehicle(522,1291.4998,-832.0693,82.7150,0.9063,1,89); 
    AddStaticVehicle(522,1289.1138,-832.2216,82.7144,1.8299,20,0); 
    AddStaticVehicle(522,1286.9045,-832.1899,82.7124,357.0424,150,49); 
    AddStaticVehicle(522,1283.9424,-832.0230,82.7132,1.8036,200,78); 

    AddStaticVehicle(411,1242.7148,-805.3672,83.8677,178.3237,1,0); // infernous 
    AddStaticVehicle(451,1248.9519,-805.4118,83.8476,178.6428,0,1); // turismo 
    AddStaticVehicle(541,1255.2100,-804.8454,83.7656,184.1492,1,0); // bullet 

    //Create the textdraw for welcoming the player 
    gWelcome = TextDrawCreate(320.0, 240.0, "Welcome to Uuri's Mapping Server!"); 
    TextDrawSetShadow(gWelcome, 3); 
    TextDrawSetOutline(gWelcome, 2); 
    TextDrawFont(gWelcome, 3); 
    TextDrawBoxColor(gWelcome, 0x003333FF); 
    TextDrawAlignment(gWelcome, 2); 

    //Use the running animations I like 
    UsePlayerPedAnims(); 
    return 1; 
} 

public OnPlayerConnect(playerid) 
{ 
    //Show the player the welcome textdraw 
    TextDrawShowForPlayer(playerid, gWelcome); 

    //Send a client message to all players on the current player connecting. 
    new name[MAX_PLAYER_NAME]; 
    new string[128]; 
    GetPlayerName(playerid, name, sizeof(name)); 
    format(string, sizeof(string), "%s has connected to the server!", name); 
    SendClientMessageToAll(LIGHT_GREEN, string); 

    return 1; 

} 

public OnPlayerRequestClass(playerid, classid) 
{ 
    SetPlayerPos(playerid, 2000.5919,1527.3319,14.6172); 
    SetPlayerCameraPos(playerid, 2000.6874,1528.9332,14.6223); 
    SetPlayerCameraLookAt(playerid, 2000.5919,1527.3319,14.6172); 
    SetPlayerFacingAngle(playerid, 358.2982); 

    return 1; 
} 

public OnPlayerSpawn(playerid) 
{ 
    //Hide the textdraw when the player spawns 
    TextDrawHideForPlayer(playerid, gWelcome); 

    //Print a client message to all players when a player spawns 
    new name[MAX_PLAYER_NAME]; 
    new string [128]; 
    GetPlayerName(playerid, name, sizeof(name)); 
    format(string, sizeof(string), "%s has spawned!", name); 
    SendClientMessageToAll(LIGHT_GREEN, string); 

    //Set the players coordinates to spawn; put camera behind player 
    SetPlayerPos(playerid, 1280.5247,-813.6929,83.6532); 
    SetCameraBehindPlayer(playerid); 
    SetPlayerFacingAngle(playerid, 180.0); 
    return 1; 
} 

回答

0

这是SA-MP的问题,只是它的工作方式。客户端处理用AddPlayerClass(或SetSpawnInfo)配置的产卵数据。这意味着客户端将自动产生在传递给AddPlayerClass的给定坐标,而不需要服务器交互。然而,当服务器检测到玩家已经重新生成时,它会执行你在上面指定的代码。

您可以绕过这一点的一种方式是,不要在OnPlayerSpawn中使用SetPlayerPos,您可以编辑您的AddPlayerClass函数调用以包含希望播放器产生的坐标。

例如:

AddPlayerClass(210, 1280.5247,-813.6929,83.6532, 269.1425, 24, 123123, 25, 123123, 34, 123123);