SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 15/10/2012, 06:44 PM   #1
niels44
High-roller
 
niels44's Avatar
 
Join Date: Jul 2011
Location: Wooden Box
Posts: 1,101
Reputation: 39
Default NPC problem

hey everyone,

im trying to create a bot and puts it in a vehicle when someone does /test, but instead of putting the bot in the car, it puts me or another player in the car...

anyways this is my code:
pawn Code:
public OnGameModeInit()
{
    SetGameModeText("StreetRodzRacers");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
   
    FirstRaceBotVehicle = CreateVehicle(517,2656.8381,-2005.3379,13.0751,0,0,0,-1);
    FirstRaceBot = ConnectNPC( "FirstRaceBot", "npcdriver" );
    return 1;
}

pawn Code:
CMD:test(playerid, params[])
{
    SetPlayerRaceCheckpoint(playerid, 0, -1714.984741, 1027.797485, 45.036315, -1725.589111, 926.632080, 24.717582, 10.0);
    CheckPointID++;
    SendClientMessage(playerid, 0xFF0000FF, "test started");
    PutPlayerInVehicle(FirstRaceBot, FirstRaceBotVehicle, 0);
    WaitForBot(FirstRaceBot, FIRSTRACE, "startfirstrace");
    return 1;
}

pawn Code:
WaitForBot( playerid, menu, action[] )
{
    PlayerInfo[playerid][botready] = false;
    SendClientMessage(FirstRaceBot, COLOR_GREEN, action );
    PlayerInfo[playerid][waitingforbot] = SetTimerEx("WaitForBotTimer",250,true,"dd",playerid,menu );

    return 1;
}
public WaitForBotTimer( playerid, menu )
{
    if( PlayerInfo[playerid][botready] ) // This is handled inside npcdriver.pwn
    {
        KillTimer(PlayerInfo[playerid][waitingforbot]);

        switch(menu)
        {
            case FIRSTRACE:
            {
            }
        }
    }
    return 1;
}

does anyone sees wuts wrong in this code?

greets niels
niels44 is offline   Reply With Quote
Old 16/10/2012, 03:23 AM   #2
clavador
Huge Clucker
 
clavador's Avatar
 
Join Date: Jun 2007
Location: Argentina
Posts: 220
Reputation: 71
Default Re: NPC problem

Your problem is here:

Code:
FirstRaceBot = ConnectNPC( "FirstRaceBot", "npcdriver" );
ConnectNPC doesnt return anything, so your variable FirstRaceBot is something else.

If you want to link an npc to an id, you can make a check inside OnPlayerConnect and check the name of the bot, if the bot's name is the the name you're looking for, then assing a variable that identifies that bot to it's player id, like:

Code:
OnPlayerConnect(playerid)
{
	if( IsPlayerNPC(playerid) ){
		new name[24];
		
		GetPlayerName(playerid, name, sizeof(name));
		
		if( name == "FirstRaceBot" ){
			//Is the bot we are looking for, so we assing a variable to it.
			FirstRaceBot = playerid;
		}
	}
}
If you want to link a bot to a player id, it's a little more complicated, but you should be able to figure it out with this piece of code.
__________________

Last edited by clavador; 16/10/2012 at 07:18 AM.
clavador is offline   Reply With Quote
Old 16/10/2012, 05:42 AM   #3
niels44
High-roller
 
niels44's Avatar
 
Join Date: Jul 2011
Location: Wooden Box
Posts: 1,101
Reputation: 39
Default Re: NPC problem

Thnx , i thought it was something wuth this in begin, butvdidnt jnew how i should it in other way so i searched for sonething else
Anyways thnx again DD
niels44 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
npc_record failed problem(not typical problem) [mmtech]DakoTa Scripting Help 7 10/07/2012 08:31 PM
Wanted problem and neon system problem iRealSAMP Scripting Help 4 04/02/2012 06:22 PM
problem with CWRP in linux (mysql problem) BSMan Server Support 1 16/06/2009 02:36 PM


All times are GMT. The time now is 08:31 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.