Kurence NPC system for Virtual World 1 ?
#1

Hy all! I Download an NPC mod by Kurence. This is nice and good, but how do I do it to npc's spawn in virtual world 1 ? Please help me!
Here is the Pawn code:
Код:
#include <a_samp>
#include <filemanager.inc>
new recording[MAX_PLAYERS] = 5;
new rids[51]=0;
new pnpcid[MAX_PLAYERS]=-1;
new caridnpcfuck[MAX_PLAYERS];
new strfuck[32];
new isnpcincar[51]=0;
new namesplit[51][51];
new fuckerskin[51];
new n00b;
new Text3D:bitch[MAX_PLAYERS];
forward lulz(); //UPDATE SKINS - it is timer because some gamemodes change skin on spawn lol
public OnFilterScriptInit()
{
	print("\n----------------------------------");
	print("InGame NPC editor by Kurence loaded!");
	print("----------------------------------\n");
	for(new i=0;i<51;i++){
	new filename[64],scriptname[32];
	format(filename,sizeof(filename),"daddycar%d.cfg",i);
	format(scriptname,sizeof(scriptname),"scriptfiles/daddycar%d.cfg",i);
	if(!fexist(filename)) file_create(scriptname);
    format(filename,sizeof(filename),"daddyskin%d.cfg",i);
	format(scriptname,sizeof(scriptname),"scriptfiles/daddyskin%d.cfg",i);
	if(!fexist(filename)) file_create(scriptname);
	}
	for(new i=0;i<51;i++){
	new filename[64],nickname[32],scriptname[32];
	format(filename,sizeof(filename),"daddycar%d.cfg",i);
	new File:fuckingfile=fopen(filename, io_read);
	new value[32];
    fread(fuckingfile,value);
    fclose(fuckingfile);
    caridnpcfuck[i]=strval(value);


    format(filename,sizeof(filename),"daddyskin%d.cfg",i);
	fuckingfile=fopen(filename, io_read);
    fread(fuckingfile,value);
    fclose(fuckingfile);
    fuckerskin[i]=strval(value);
    
	format(filename,sizeof(filename),"npcmodes/recordings/daddycar%d.rec",i);
	format(nickname,sizeof(nickname),"Kurence%d",i);
	format(scriptname,sizeof(scriptname),"daddycar%d",i);
	if(file_exists(filename)) ConnectNPC(nickname,scriptname);
    format(filename,sizeof(filename),"npcmodes/recordings/daddyfoot%d.rec",i);
    format(scriptname,sizeof(scriptname),"daddyfoot%d",i);
	if(file_exists(filename)) ConnectNPC(nickname,scriptname);
	}
	SetTimer("lulz",1000,1);
	return 1;
}
public OnFilterScriptExit()
{
	print("\n------------------------------------");
	print("InGame NPC editor by Kurence unloaded!");
	print("------------------------------------\n");
	for(new i;i<MAX_PLAYERS;i++){
	GetPlayerName(i,strfuck,sizeof(strfuck));
	new fuckername[32];
	GetPlayerName(i,fuckername,sizeof(fuckername));
	if(IsPlayerNPC(i) && !strcmp("Kurence",fuckername,false,7))Kick(i);
	}
	return 1;
}
public OnPlayerCommandText(playerid,cmdtext[]){
	new cmd[128], idx;
	cmd = strtok(cmdtext, idx);
	if(!strcmp("/knicks",cmdtext)){
	if(n00b==0){
	for(new i;i<MAX_PLAYERS;i++){
	GetPlayerName(i,strfuck,sizeof(strfuck));
	if(IsPlayerNPC(i) && !strcmp("Kurence",strfuck,false,7)){
	GetPlayerName(i,strfuck,sizeof(strfuck));
	bitch[i] = Create3DTextLabel(strfuck,0x28BA9AFF,0,0,0,200,-1,0);
 	Attach3DTextLabelToPlayer(bitch[i],i,0,0,0.3);
	}
	}
	SendClientMessage(playerid,0x00FF0000,"NPC nicknames enabled");
	n00b=1;
	return 1;
	}
	else{
	for(new i;i<MAX_PLAYERS;i++){
	Delete3DTextLabel(bitch[i]);
	}
	SendClientMessage(playerid,0x00FF0000,"NPC nicknames disabled");
	n00b=0;
	return 1;
	}
	}
	if(!strcmp("/knpchelp",cmdtext)){
	SendClientMessage(playerid,0xFF000000,"In-Game NPC maker by Kurence");
	SendClientMessage(playerid,0x00FF0000,"COMMANDS:");
	SendClientMessage(playerid,0x00FF0000,"/knpc [ID 0-50] - start/stop recording npc (PLAYER_RECORDING_TYPE will depend on your current state (on foot/driver)");
	SendClientMessage(playerid,0x00FF0000,"/knpclist - show list of currently connected NPC's");
	SendClientMessage(playerid,0x00FF0000,"/kremove [ID 0-50] - remove NPC (or use '/kremove all' to remove all NPCs)");
	SendClientMessage(playerid,0x00FF0000,"/knicks - show/hide nicknames of NPC's");
	SendClientMessage(playerid,0x00FF0000,"/knpchelp - show list of commands");
	return 1;
	}
	if(!strcmp("/knpclist",cmd)){
	new tmp[128];
	tmp = strtok(cmdtext, idx);
	SendClientMessage(playerid,0xFF000000,"[NPCID]		[NICKNAME]		[PLAYERID]");
	for(new i;i<MAX_PLAYERS;i++){
	if(IsPlayerConnected(i)){
	GetPlayerName(i,strfuck,sizeof(strfuck));
	if(!strcmp("Kurence",strfuck,false,7)){
	split(strfuck,namesplit,'e');
	new msg[64];
	format(msg,sizeof(msg),"%d      %s		%d",strval(namesplit[2]),strfuck,i);
	SendClientMessage(playerid,0xFF000000,msg);
	}
	}
	}
	return 1;
	}
	if (!strcmp("/kremove",cmd)){
	new tmp[128];
	tmp = strtok(cmdtext, idx);
	if(!strcmp("all",tmp) && strlen(tmp)==3){
	SendClientMessage(playerid,0xFF000000,"Removing all NPC's...");
	for(new i;i<MAX_PLAYERS;i++){
    GetPlayerName(i,strfuck,sizeof(strfuck));
	if(!strcmp("Kurence",strfuck,false,7))Kick(i);
	new filename[64];
	format(filename,sizeof(filename),"npcmodes/recordings/daddycar%d.rec",i);
	if(file_exists(filename)) file_delete(filename);
	format(filename,sizeof(filename),"npcmodes/recordings/daddyfoot%d.rec",i);
	if(file_exists(filename)) file_delete(filename);
	}
	return 1;
	}
	if(!strlen(tmp)) return SendClientMessage(playerid,0xFF000000,"Usage: /kremove [ID] - Valid IDs: 0-50 or /kremove all");
 	if(strval(tmp)>50 || strval(tmp)<0) return SendClientMessage(playerid,0xFF000000,"Usage: /kremove [ID] - Valid IDs: 0-50 or /kremove all");
	new remmsg[64];
	format(remmsg,sizeof(remmsg),"Removing NPC with ID %d",strval(tmp));
    for(new i;i<MAX_PLAYERS;i++){
	GetPlayerName(i,strfuck,sizeof(strfuck));
	new fuckername[32];
	format(fuckername,sizeof(fuckername),"Kurence%d",strval(tmp));
	if (!strcmp(fuckername,strfuck)) Kick(i);
	}
	SendClientMessage(playerid,0x00FF0000,remmsg);
	new filename[64];
	format(filename,sizeof(filename),"npcmodes/recordings/daddycar%d.rec",strval(tmp));
	if(file_exists(filename)) file_delete(filename);
	format(filename,sizeof(filename),"npcmodes/recordings/daddyfoot%d.rec",strval(tmp));
	if(file_exists(filename)) file_delete(filename);
	return 1;
 	}
	if (!strcmp("/knpc",cmd)){
	new tmp[128];
	tmp = strtok(cmdtext, idx);
	if(pnpcid[playerid]!=-1){
    if(recording[playerid] == 1){
	StopRecordingPlayerData(playerid);
	recording[playerid] = 5;
	new filenamefuck[64],daddyslittlegirl[64];
	format(filenamefuck,sizeof(filenamefuck),"npcmodes/recordings/daddyfoot%d.rec",pnpcid[playerid]);
	file_delete(filenamefuck);
	format(filenamefuck,sizeof(filenamefuck),"npcmodes/recordings/daddycar%d.rec",pnpcid[playerid]);
	file_delete(filenamefuck);
	format(filenamefuck,sizeof(filenamefuck),"scriptfiles/daddyfoot%d.rec",pnpcid[playerid]);
	format(daddyslittlegirl,sizeof(daddyslittlegirl),"npcmodes/recordings/daddyfoot%d.rec",pnpcid[playerid]);
	file_move(filenamefuck,daddyslittlegirl);
	new fuckernamelulz[32];
	format(fuckernamelulz,sizeof(fuckernamelulz),"Kurence%d",pnpcid[playerid]);
	format(daddyslittlegirl,sizeof(daddyslittlegirl),"daddyfoot%d",pnpcid[playerid]);
	ConnectNPC(fuckernamelulz,daddyslittlegirl);
	rids[pnpcid[playerid]]=0;
	pnpcid[playerid]=-1;
	recording[playerid] = 5;
}
	if(recording[playerid] == 2){
	StopRecordingPlayerData(playerid);
	recording[playerid] = 5;
	new filenamefuck[64],daddyslittlegirl[64];
	format(filenamefuck,sizeof(filenamefuck),"npcmodes/recordings/daddycar%d.rec",pnpcid[playerid]);
	file_delete(filenamefuck);
	format(filenamefuck,sizeof(filenamefuck),"npcmodes/recordings/daddyfoot%d.rec",pnpcid[playerid]);
	file_delete(filenamefuck);
	format(filenamefuck,sizeof(filenamefuck),"scriptfiles/daddycar%d.rec",pnpcid[playerid]);
	format(daddyslittlegirl,sizeof(daddyslittlegirl),"npcmodes/recordings/daddycar%d.rec",pnpcid[playerid]);
	file_move(filenamefuck,daddyslittlegirl);
	new fuckernamelulz[32];
	format(fuckernamelulz,sizeof(fuckernamelulz),"Kurence%d",pnpcid[playerid]);
	format(daddyslittlegirl,sizeof(daddyslittlegirl),"daddycar%d",pnpcid[playerid]);
	ConnectNPC(fuckernamelulz,daddyslittlegirl);
	for(new i;i<MAX_PLAYERS;i++){
	GetPlayerName(i,strfuck,sizeof(strfuck));
	new namelulzomg[32];
	format(namelulzomg,sizeof(namelulzomg),"Kurence%d",pnpcid[playerid]);
	if (!strcmp(namelulzomg,strfuck)) PutPlayerInVehicle(i,caridnpcfuck[pnpcid[playerid]],0);
	}
	rids[pnpcid[playerid]]=0;
	pnpcid[playerid]=-1;
	recording[playerid] = 5;
	}
	}else{
	if(!strlen(tmp)) return SendClientMessage(playerid,0xFF000000,"Usage: /knpc [ID] - Valid IDs: 0-50");
	if(strval(tmp)>50 || strval(tmp)<0) return SendClientMessage(playerid,0xFF000000,"Usage: /knpc [ID] - Valid IDs: 0-50");
	if(rids[strval(tmp)]==1) return SendClientMessage(playerid,0xFF000000,"Someone is already creating NPC with this ID!");
	if(GetPlayerState(playerid) == 1){
	caridnpcfuck[strval(tmp)] = -5;
	new filename[32];
	fuckerskin[strval(tmp)]=GetPlayerSkin(playerid);
	format(filename,sizeof(filename),"daddyfoot%i",strval(tmp));
	StartRecordingPlayerData(playerid, PLAYER_RECORDING_TYPE_ONFOOT,filename);
	recording[playerid]=1;
	rids[strval(tmp)]=1;
	new msg[64];
    new filename2[64];
    format(filename2,sizeof(filename2),"daddyskin%i.cfg",strval(tmp));
    new File:fuckingfile=fopen(filename2, io_write);
    new value[64];
    format(value,sizeof(value),"%d",GetPlayerSkin(playerid));
    fwrite(fuckingfile,value);
    fclose(fuckingfile);
	isnpcincar[strval(tmp)] = 0;
	format(msg,sizeof(msg),"Creating On-Foot NPC with ID %d... Use /knpc again when done",strval(tmp));
	SendClientMessage(playerid,0x00FF0000,msg);
	pnpcid[playerid]=strval(tmp);
	for(new i;i<MAX_PLAYERS;i++){
	GetPlayerName(i,strfuck,sizeof(strfuck));
	new fuckername[32];
	format(fuckername,sizeof(fuckername),"Kurence%d",strval(tmp));
	if (!strcmp(fuckername,strfuck)) Kick(i);
	}
	}
	else if(GetPlayerState(playerid) == 2){
	new filename[32];
	isnpcincar[strval(tmp)] = 1;
	format(filename,sizeof(filename),"daddycar%d",strval(tmp));
	StartRecordingPlayerData(playerid, PLAYER_RECORDING_TYPE_DRIVER, filename);
    recording[playerid]=2;
   	rids[strval(tmp)]=1;
    new msg[64];
   	fuckerskin[strval(tmp)]=GetPlayerSkin(playerid);
	format(msg,sizeof(msg),"Creating In-Car NPC with ID %d... Use /knpc again when done",strval(tmp));
	SendClientMessage(playerid,0x00FF0000,msg);
    caridnpcfuck[strval(tmp)] = GetPlayerVehicleID(playerid);
    new filename2[64];
    format(filename2,sizeof(filename2),"daddycar%d.cfg",strval(tmp));
    new File:fuckingfile=fopen(filename2, io_write);
    new value[64];
    format(value,sizeof(value),"%d",GetPlayerVehicleID(playerid));
    fwrite(fuckingfile,value);
    fclose(fuckingfile);
    format(filename2,sizeof(filename2),"daddyskin%d.cfg",strval(tmp));
    fuckingfile=fopen(filename2, io_write);
    format(value,sizeof(value),"%d",GetPlayerSkin(playerid));
    fwrite(fuckingfile,value);
    fclose(fuckingfile);
   	pnpcid[playerid]=strval(tmp);
   	for(new i;i<MAX_PLAYERS;i++){
	GetPlayerName(i,strfuck,sizeof(strfuck));
	new fuckername[32];
	format(fuckername,sizeof(fuckername),"Kurence%d",strval(tmp));
	if (!strcmp(fuckername,strfuck)) Kick(i);
	}
	}
	}
	return 1;
	}
	return 0;
}
public OnPlayerConnect(playerid){
pnpcid[playerid]=-1;
if(IsPlayerNPC(playerid)) SpawnPlayer(playerid);
GetPlayerName(playerid,strfuck,sizeof(strfuck));
if(!strcmp("Kurence",strfuck,false,7)){
split(strfuck,namesplit,'e');
if(n00b==1){
GetPlayerName(playerid,strfuck,sizeof(strfuck));
bitch[playerid] = Create3DTextLabel(strfuck,0x28BA9AFF,0,0,0,200,-1,0);
Attach3DTextLabelToPlayer(bitch[playerid],playerid,0,0,0.3);
}
if(GetVehicleModel(caridnpcfuck[strval(namesplit[2])])!=0) PutPlayerInVehicle(playerid,caridnpcfuck[strval(namesplit[2])],0);
}
return 1;
}
public OnPlayerEnterVehicle(playerid,vehicleid){
if(recording[playerid] == 1){
StopRecordingPlayerData(playerid);
recording[playerid] = 5;
new filenamefuck[64],daddyslittlegirl[64];
format(filenamefuck,sizeof(filenamefuck),"npcmodes/recordings/daddyfoot%d.rec",pnpcid[playerid]);
file_delete(filenamefuck);
format(filenamefuck,sizeof(filenamefuck),"npcmodes/recordings/daddycar%d.rec",pnpcid[playerid]);
file_delete(filenamefuck);
format(filenamefuck,sizeof(filenamefuck),"scriptfiles/daddyfoot%d.rec",pnpcid[playerid]);
format(daddyslittlegirl,sizeof(daddyslittlegirl),"npcmodes/recordings/daddyfoot%d.rec",pnpcid[playerid]);
file_move(filenamefuck,daddyslittlegirl);
new fuckernamelulz[32];
format(fuckernamelulz,sizeof(fuckernamelulz),"Kurence%d",pnpcid[playerid]);
format(daddyslittlegirl,sizeof(daddyslittlegirl),"daddyfoot%d",pnpcid[playerid]);
ConnectNPC(fuckernamelulz,daddyslittlegirl);
rids[pnpcid[playerid]]=0;
pnpcid[playerid]=-1;
}
return 1;
}

public OnPlayerDisconnect(playerid,reason){
GetPlayerName(playerid,strfuck,sizeof(strfuck));
if(!strcmp("Kurence",strfuck,false,7) && n00b==1 && IsPlayerNPC(playerid)){
Delete3DTextLabel(bitch[playerid]);
}
if(recording[playerid]!=5){
StopRecordingPlayerData(playerid);
recording[playerid] = 5;
if(pnpcid[playerid]!=-1)rids[pnpcid[playerid]]=0;
pnpcid[playerid]=-1;
}
return 1;
}
public lulz(){
for(new i;i<MAX_PLAYERS;i++){
GetPlayerName(i,strfuck,sizeof(strfuck));
if(!strcmp("Kurence",strfuck,false,7)){
split(strfuck,namesplit,'e');
if(GetPlayerSkin(i) != fuckerskin[strval(namesplit[2])]){
SetPlayerSkin(i,fuckerskin[strval(namesplit[2])]);
}
}
}
}
public OnPlayerStateChange(playerid,newstate,oldstate){ // The same as OnPlayerExitVehicle (
if(oldstate==PLAYER_STATE_DRIVER && newstate==PLAYER_STATE_ONFOOT){
if(recording[playerid] == 2){
StopRecordingPlayerData(playerid);
recording[playerid] = 5;
new filenamefuck[64],daddyslittlegirl[64];
format(filenamefuck,sizeof(filenamefuck),"npcmodes/recordings/daddycar%d.rec",pnpcid[playerid]);
file_delete(filenamefuck);
format(filenamefuck,sizeof(filenamefuck),"npcmodes/recordings/daddyfoot%d.rec",pnpcid[playerid]);
file_delete(filenamefuck);
format(filenamefuck,sizeof(filenamefuck),"scriptfiles/daddycar%d.rec",pnpcid[playerid]);
format(daddyslittlegirl,sizeof(daddyslittlegirl),"npcmodes/recordings/daddycar%d.rec",pnpcid[playerid]);
file_move(filenamefuck,daddyslittlegirl);
new fuckernamelulz[32];
format(fuckernamelulz,sizeof(fuckernamelulz),"Kurence%d",pnpcid[playerid]);
format(daddyslittlegirl,sizeof(daddyslittlegirl),"daddycar%d",pnpcid[playerid]);
ConnectNPC(fuckernamelulz,daddyslittlegirl);
for(new i;i<MAX_PLAYERS;i++){
GetPlayerName(i,strfuck,sizeof(strfuck));
new namelulzomg[32];
format(namelulzomg,sizeof(namelulzomg),"Kurence%d",pnpcid[playerid]);
if (!strcmp(namelulzomg,strfuck)) PutPlayerInVehicle(i,caridnpcfuck[pnpcid[playerid]],0);
}
rids[pnpcid[playerid]]=0;
pnpcid[playerid]=-1;
}
}
return 1;
}
strtok(const string[], &index)
{
	new length = strlen(string);
	while ((index < length) && (string[index] <= ' '))
	{
		index++;
	}

	new offset = index;
	new result[20];
	while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
	{
		result[index - offset] = string[index];
		index++;
	}
	result[index - offset] = EOS;
	return result;
}
stock split(const strsrc[], strdest[][], delimiter)
{
    new i, li;
    new aNum;
    new len;
    while(i <= strlen(strsrc))
    {
        if(strsrc[i] == delimiter || i == strlen(strsrc))
        {
            len = strmid(strdest[aNum], strsrc, li, i, 128);
            strdest[aNum][len] = 0;
            li = i+1;
            aNum++;
        }
        i++;
    }
    return 1;
}
Reply
#2

Use SetPlayerVirtualWorld under OnPlayerConnect if IsPlayerNPC(playerid).
Reply
#3

Not working..
Код:
public OnPlayerConnect(playerid){
pnpcid[playerid]=-1;
if(IsPlayerNPC(playerid)) SpawnPlayer(playerid);
GetPlayerName(playerid,strfuck,sizeof(strfuck));
if(!strcmp("Kurence",strfuck,false,7)){
split(strfuck,namesplit,'e');
if(n00b==1){
GetPlayerName(playerid,strfuck,sizeof(strfuck));
bitch[playerid] = Create3DTextLabel(strfuck,0x28BA9AFF,0,0,0,200,-1,0);
Attach3DTextLabelToPlayer(bitch[playerid],playerid,0,0,0.3);
SetPlayerVirtualWorld(playerid, 2);
}
if(GetVehicleModel(caridnpcfuck[strval(namesplit[2])])!=0) PutPlayerInVehicle(playerid,caridnpcfuck[strval(namesplit[2])],0);
}
return 1;
}
Reply
#4

I wrote wrong. Not the 1. viertual world. The 2. VW need.
Reply
#5

Quote:
Originally Posted by Riky35800
Посмотреть сообщение
Not working..
Код:
public OnPlayerConnect(playerid){
pnpcid[playerid]=-1;
if(IsPlayerNPC(playerid)) SpawnPlayer(playerid);
GetPlayerName(playerid,strfuck,sizeof(strfuck));
if(!strcmp("Kurence",strfuck,false,7)){
split(strfuck,namesplit,'e');
if(n00b==1){
GetPlayerName(playerid,strfuck,sizeof(strfuck));
bitch[playerid] = Create3DTextLabel(strfuck,0x28BA9AFF,0,0,0,200,-1,0);
Attach3DTextLabelToPlayer(bitch[playerid],playerid,0,0,0.3);
SetPlayerVirtualWorld(playerid, 2);
}
if(GetVehicleModel(caridnpcfuck[strval(namesplit[2])])!=0) PutPlayerInVehicle(playerid,caridnpcfuck[strval(namesplit[2])],0);
}
return 1;
}
pawn Код:
public OnPlayerConnect(playerid){
pnpcid[playerid]=-1;
if(IsPlayerNPC(playerid)) SpawnPlayer(playerid);
SetPlayerVirtualWorld(playerid, 1); // Virtual World
GetPlayerName(playerid,strfuck,sizeof(strfuck));
if(!strcmp("Kurence",strfuck,false,7)){ //Kurence is name in server
split(strfuck,namesplit,'e');
if(n00b==1){
GetPlayerName(playerid,strfuck,sizeof(strfuck));
bitch[playerid] = Create3DTextLabel(strfuck,0x28BA9AFF,0,0,0,200,-1,0);
Attach3DTextLabelToPlayer(bitch[playerid],playerid,0,0,0.3);
}
if(GetVehicleModel(caridnpcfuck[strval(namesplit[2])])!=0) PutPlayerInVehicle(playerid,caridnpcfuck[strval(namesplit[2])],0);
}
return 1;
}
Reply
#6

Not work :/
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)